from multimark import markdown_to_man
markdown_to_man("**bold** and *italic*")'.PP\n\\f[B]bold\\f[] and \\f[I]italic\\f[]\n'
Parse CommonMark/GFM and render as a groff man page.
Usage
Produces groff-format output suitable for use with the man command or inclusion in manual page source files. Inline formatting maps to font switching requests (\f[B], \f[I], \f[CR]), paragraphs use .PP, and headings use .SH or .SS macros.
The output is a fragment and does not include a .TH title header. Wrap it in your own man page structure to produce a complete manual page.
text: strThe Markdown string to parse and render. Must be a Python str.
hardbreaks: bool = FalseRender soft line breaks as hard breaks (.br). By default, this is False.
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 = FalseAllow raw HTML to pass through. Since groff is the target format, raw HTML is typically irrelevant. By default, this is False.
footnotes: bool = FalseEnable footnote syntax parsing. By default, this is False.
extensions: Sequence[str] = ()
A sequence of GFM extension names to enable. Valid names are "table", "strikethrough", "autolink", "tagfilter", and "tasklist".
width: int = 0The column at which to wrap output lines. Set to 0 (the default) to disable line wrapping entirely.
options: int = 0Options.SMART | Options.UNSAFE). Merged via OR with any boolean keyword arguments set to True. Defaults to 0.
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.
strRender a paragraph with bold and italic:
'.PP\n\\f[B]bold\\f[] and \\f[I]italic\\f[]\n'
Render a heading:
Wrap at 72 columns:
long_paragraph = "This is a long paragraph of text. " * 10
print(markdown_to_man(long_paragraph, width=72)).PP
This is a long paragraph of text. This is a long paragraph of text. This
is a long paragraph of text. This is a long paragraph of text. This is a
long paragraph of text. This is a long paragraph of text. This is a long
paragraph of text. This is a long paragraph of text. This is a long
paragraph of text. This is a long paragraph of text.