Skip to content

Add rtf_rich_text() function for inline text formatting #41

@elong0527

Description

@elong0527

Summary

r2rtf provides rtf_rich_text() function for inline text formatting within table cells. This allows mixing different text styles (bold, italic, etc.) within a single cell.

Expected functionality

# r2rtf example
rtf_rich_text("Normal text {b Bold text} and {i italic text}")

Proposed Python equivalent

# Proposed rtflite implementation
rtf.rich_text("Normal text {b Bold text} and {i italic text}")

Minimal example

import rtflite as rtf
import polars as pl

df = pl.DataFrame({
    "Treatment": ["Placebo", "Drug A"],
    "Response": [
        rtf.rich_text("n=50 {b (75%)}"),
        rtf.rich_text("n=48 {b (92%)}")
    ]
})

doc = rtf.RTFDocument(df=df)
doc.write_rtf("rich_text_example.rtf")

Use case

Clinical reports often need mixed formatting within cells (e.g., "n=50 {b (75%)}" where the percentage is bold).

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions