Bindings to the very fast MD4C markdown parser.
Clients¶
-
load
(path=None)¶ Load pre-build or custom libraries.
Parameters: path (str) – Location of the dll or dylib. Note
Only
Dawin
systems are supported out of the box.Follow the project’s instructions to build your own.
Parsers¶
-
class
Base
(*args, flags=0)¶ Bases:
abc.ABC
Source for all parsers.
For custom parsers, overwrite
_leave()
,_track()
, and_get()
. Create a_parse_(tag)
method for every handled tag. All valid tags can be found inBlock
andSpan
with trailing underscores stripped.Flags:
strike_through
|underline
.-
_track
(type, data)¶ Simple text will be directed here.
-
_leave
(type, info)¶ Exiting tags will triger this.
-
_get
()¶ Should return the final result.
-
get
(value)¶ Parse the value and get the result.
-
Details¶
Objects from here will be passed to callbacks as additional information.
-
class
Attribute
¶ - Wraps strings that are outside of a normal text flow and are propagated within various detailed structures, but still may contain string portions of different types like e.g. entities.
Name Type Description text bytes
n/a size int
n/a substr_types int
n/a substr_offsets int
n/a
-
class
Ul
¶ Name Type Description is_tight int
Non-zero if tight list, zero if loose. mark str
Item bullet character of the list, e.g. -
,+
,+
.
-
class
Ol
¶ Name Type Description start int
First index of the ordered list. is_tight int
Non-zero if tight list, zero if loose. mark_delimiter str
Character delimiting the item marks in md source, e.g. .
or)
-
class
Li
¶ Name Type Description is_task int
Can be non-zero only with Spec
’stask_lists
.task_mark str
If is_task
, it’sx
,X
or single space.None
otherwise.task_mark_offset int
If is_task
, offset in the input of the char between(
and)
.
Flags¶
-
class
Spec
¶ An enumeration.
-
collapse_whitespace
= 1¶
-
permissive_at_xheaders
= 2¶
-
permissive_url_autolinks
= 4¶
-
permissive_email_autolinks
= 8¶
-
no_indented_code_blocks
= 16¶
-
no_html_blocks
= 32¶
-
no_html_spans
= 64¶
-
tables
= 256¶
-
strike_through
= 512¶
-
permissive_www_autolinks
= 1024¶
-
task_lists
= 2048¶
-
latex_math_spans
= 4096¶
-
wiki_links
= 8192¶
-
underline
= 16384¶
-
permissive_autolinks
= 1036¶
-
no_html
= 96¶
-
Enums¶
-
class
Block
¶ An enumeration.
-
code
= 7¶
-
doc
= 0¶
-
h
= 6¶
-
hr
= 5¶
-
html
= 8¶
-
li
= 4¶
-
ol
= 3¶
-
p
= 9¶
-
quote
= 1¶
-
table
= 10¶
-
tbody
= 12¶
-
td
= 15¶
-
th
= 14¶
-
thead
= 11¶
-
tr
= 13¶
-
ul
= 2¶
-
-
class
Span
¶ An enumeration.
-
a
= 2¶
-
code
= 4¶
-
del_
= 5¶
-
em
= 0¶
-
img
= 3¶
-
latex_math
= 6¶
-
latex_math_display
= 7¶
-
strong
= 1¶
-
u
= 9¶
-
wiki_link
= 8¶
-