from multimark import markdown_to_plaintext
markdown_to_plaintext("**Hello**, *world*!")'Hello, world!\n'
Parse CommonMark/GFM and render as plain text.
Usage
Removes heading, emphasis, link, and code delimiters while preserving their text. Link destinations and image URLs are omitted; image descriptions are retained. Lists keep their markers and indentation, and paragraphs remain separated by blank lines.
GFM tables retain pipe-table syntax, task lists retain checkbox markers, and strikethrough text is surrounded by single tildes. Math keeps its TeX source between $ or $$ delimiters. Enabled footnotes retain numbered references and definitions. Raw HTML blocks, including their text, are omitted; inline HTML tags are omitted without removing surrounding text.
text: strThe Markdown string to parse and render. Must be a Python str.
hardbreaks: bool = FalseRender soft line breaks as hard breaks (newlines). By default, this is False. When enabled, width-based wrapping is disabled.
smart: bool = FalseConvert straight quotes to curly quotes, -- to en-dashes, --- to em-dashes, and ... to ellipses. By default, this is False.
normalize: bool = FalseConsolidate adjacent text nodes in the parsed AST. By default, this is False.
unsafe: bool = FalseRaw HTML is always omitted, regardless of this flag. By default, this is False.
footnotes: bool = FalseEnable footnote syntax parsing. By default, this is False.
extensions: Sequence[str] = ()A sequence of extension names to enable. Valid names are "table", "strikethrough", "autolink", "tagfilter", "tasklist", and "math".
width: int = 0The column at which to wrap output lines. Set to 0 (the default) to disable line wrapping entirely and preserve soft line breaks. With a positive width, soft line breaks become spaces before wrapping. Code blocks are not wrapped. Ignored when hardbreaks=True.
options: int = 0Options.SMART | Options.UNSAFE). Merged via OR with any boolean keyword arguments set to True. Defaults to 0. Options.NOBREAKS converts soft line breaks to spaces and disables automatic wrapping.
The boolean keyword arguments (smart, unsafe, hardbreaks, etc.) are convenience shortcuts for the most common Options flags. When both styles are provided, they are merged via OR. See markdown_to_html() for a detailed explanation.
str"\n". Output whitespace is not stripped.
Remove inline formatting:
'Hello, world!\n'
Wrap readable text at 72 columns: