Skip to content

text_formatters

Utilities for formatting text.

Functions:

Name Description
promptify

Compose a text from multiple building blocks.

promptify 🔗

promptify(*blocks: str | None, joiner: str = '\n\n') -> str

Compose a text from multiple building blocks.

All building blocks get formatted in advance to ensure that the result text has consistent indentation.

Source code in src/brag/text_formatters.py
def promptify(*blocks: str | None, joiner: str = "\n\n") -> str:
    """Compose a text from multiple building blocks.

    All building blocks get formatted in advance to ensure that the result text has consistent indentation.
    """
    return joiner.join(_dedent_triple_quote_string(block) for block in blocks if block)