Options

CommonMark/GFM parsing and rendering options.

Usage

Source

Options

An IntFlag enumeration of all option flags supported by the cmark-gfm library. Options can be combined using the bitwise OR operator (|) and passed to any renderer’s options= parameter. This provides a composable, lower-level alternative to the named boolean keyword arguments available on each renderer function.

Most users will prefer the named keyword arguments (e.g., smart=True) for common options. The Options bitmask is useful when you need to combine multiple flags into a single reusable value, or when working with GFM-specific flags that do not have dedicated keyword arguments.

Examples

Combine multiple flags with the | operator:

from multimark import markdown_to_html, Options

opts = Options.SMART | Options.UNSAFE
markdown_to_html('"Hello" -- world', options=opts)
'<p>“Hello” – world</p>\n'

Mix a bitmask with named keyword arguments (they are OR’d together):

text = "Here's some *text* to convert"
markdown_to_html(text, options=Options.SMART, footnotes=True)
'<p>Here’s some <em>text</em> to convert</p>\n'

Use GFM-specific flags that have no keyword shortcut:

markdown_to_html(
    "~~deleted~~",
    options=Options.STRIKETHROUGH_DOUBLE_TILDE,
    extensions=["strikethrough"],
)
'<p><del>deleted</del></p>\n'