API Reference¶
Blazingly fast Markdown parser.
Options
¶
Bases: IntFlag
IntFlag containing flags for enabling pulldown_cmark options.
Examples:
options = (
pyromark.Options.ENABLE_TABLES
| pyromark.Options.ENABLE_MATH
| pyromark.Options.ENABLE_GFM
)
ENABLE_TABLES
class-attribute
instance-attribute
¶
ENABLE_TABLES = 1 << 1
ENABLE_FOOTNOTES
class-attribute
instance-attribute
¶
ENABLE_FOOTNOTES = 1 << 2
ENABLE_STRIKETHROUGH
class-attribute
instance-attribute
¶
ENABLE_STRIKETHROUGH = 1 << 3
ENABLE_TASKLISTS
class-attribute
instance-attribute
¶
ENABLE_TASKLISTS = 1 << 4
ENABLE_SMART_PUNCTUATION
class-attribute
instance-attribute
¶
ENABLE_SMART_PUNCTUATION = 1 << 5
ENABLE_HEADING_ATTRIBUTES
class-attribute
instance-attribute
¶
ENABLE_HEADING_ATTRIBUTES = 1 << 6
ENABLE_YAML_STYLE_METADATA_BLOCKS
class-attribute
instance-attribute
¶
ENABLE_YAML_STYLE_METADATA_BLOCKS = 1 << 7
ENABLE_PLUSES_DELIMITED_METADATA_BLOCKS
class-attribute
instance-attribute
¶
ENABLE_PLUSES_DELIMITED_METADATA_BLOCKS = 1 << 8
ENABLE_OLD_FOOTNOTES
class-attribute
instance-attribute
¶
ENABLE_OLD_FOOTNOTES = 1 << 9 | 1 << 2
ENABLE_MATH
class-attribute
instance-attribute
¶
ENABLE_MATH = 1 << 10
ENABLE_GFM
class-attribute
instance-attribute
¶
ENABLE_GFM = 1 << 11
ENABLE_DEFINITION_LIST
class-attribute
instance-attribute
¶
ENABLE_DEFINITION_LIST = 1 << 12
ENABLE_SUPERSCRIPT
class-attribute
instance-attribute
¶
ENABLE_SUPERSCRIPT = 1 << 13
ENABLE_SUBSCRIPT
class-attribute
instance-attribute
¶
ENABLE_SUBSCRIPT = 1 << 14
ENABLE_WIKILINKS
class-attribute
instance-attribute
¶
ENABLE_WIKILINKS = 1 << 15
Markdown
¶
events
method descriptor
¶
Examples:
for event in md.events(
"# Hello world",
options=(
pyromark.Options.ENABLE_TABLES
| pyromark.Options.ENABLE_MATH
| pyromark.Options.ENABLE_GFM
)
):
# All event types are fully type annotated
# so you will get static type checking
# and Tab completions in your IDE!
match event:
case {"Start": {"Heading": {"level": heading_level}}}:
print(f"Heading with {heading_level} level started")
case {"Text": text}:
print(f"Got {text!r} text")
case {"End": {"Heading": heading_level}}:
print(f"Heading with {heading_level} level ended")
case other_event:
print(f"Got {other_event!r}")
events_with_range
method descriptor
¶
Examples:
for event, range_ in md.events_with_range(
"# Hello world",
options=(
pyromark.Options.ENABLE_TABLES
| pyromark.Options.ENABLE_MATH
| pyromark.Options.ENABLE_GFM
)
):
# All event types are fully type annotated
# so you will get static type checking
# and Tab completions in your IDE!
match event:
case {"Start": {"Heading": {"level": heading_level}}}:
print(
f"Heading with {heading_level} level started, "
f"{range_=}"
)
case {"Text": text}:
print(f"Got {text!r} text, {range_=}")
case {"End": {"Heading": heading_level}}:
print(
f"Heading with {heading_level} level ended, "
f"{range_=}"
)
case other_event:
print(f"Got {other_event!r}, {range_=}")
events
builtin
¶
Examples:
for event in pyromark.events(
"# Hello world",
options=(
pyromark.Options.ENABLE_TABLES
| pyromark.Options.ENABLE_MATH
| pyromark.Options.ENABLE_GFM
)
):
# All event types are fully type annotated
# so you will get static type checking
# and Tab completions in your IDE!
match event:
case {"Start": {"Heading": {"level": heading_level}}}:
print(f"Heading with {heading_level} level started")
case {"Text": text}:
print(f"Got {text!r} text")
case {"End": {"Heading": heading_level}}:
print(f"Heading with {heading_level} level ended")
case other_event:
print(f"Got {other_event!r}")
events_with_range
builtin
¶
Examples:
for event, range_ in pyromark.events_with_range(
"# Hello world",
options=(
pyromark.Options.ENABLE_TABLES
| pyromark.Options.ENABLE_MATH
| pyromark.Options.ENABLE_GFM
)
):
# All event types are fully type annotated
# so you will get static type checking
# and Tab completions in your IDE!
match event:
case {"Start": {"Heading": {"level": heading_level}}}:
print(
f"Heading with {heading_level} level started, {range_=}"
)
case {"Text": text}:
print(f"Got {text!r} text, {range_=}")
case {"End": {"Heading": heading_level}}:
print(
f"Heading with {heading_level} level ended, {range_=}"
)
case other_event:
print(f"Got {other_event!r}, {range_=}")
html
builtin
¶
Examples:
html = pyromark.html(
"# Hello world",
options=(
pyromark.Options.ENABLE_TABLES
| pyromark.Options.ENABLE_MATH
| pyromark.Options.ENABLE_GFM
)
)
assert html == "<h1>Hello world</h1>\n"