Skip to content

markdown_output_parser

LangChain output parser that extracts markdown text from a larger text block enclose in triple back quotes.

Classes

MarkdownOutputParser

Bases: BaseOutputParser[str]

Functions

get_format_instructions
get_format_instructions() -> str

Get the format instructions for the markdown content.

Returns:

  • str ( str ) –

    The format instructions.

parse
parse(text: str) -> str
    Parse the input text to extract markdown content enclosed in PEM-style headings.

    Args:
        text (str): The input text containing markdown content.

    Returns:
        str: The extracted markdown content.

    Raises:
        ValueError: If no valid markdown text is found.

    Examples:
        ```python
        parser = MarkdownOutputParser()
        markdown_text = parser.parse("Some text... ----- BEGIN MARKDOWN -----
Title

Content ----- END MARKDOWN ----- More text…”) print(markdown_text) # Output: “# Title Content” ```