mkconvert
Class info¶
Classes¶
| Name | Children | Inherits |
|---|---|---|
| MissingDependencyError mkconvert._core The package a backend needs is not installed. |
||
| UnsupportedOptionError mkconvert._core Options were set that the chosen backend cannot honour. |
||
| UnsupportedOptionWarning mkconvert._core Options were set that the chosen backend cannot honour; they are ignored. |
Re-exported classes¶
| Class | Module | Description |
|---|---|---|
| CmarkgfmParser | mkconvert.parsers.cmarkgfm | cmarkgfm: bindings to cmark-gfm, the reference GFM implementation. |
| ComrakParser | mkconvert.parsers.comrak | Comrak: fast, CommonMark / GFM compliant, supports every common option. |
| HtmdConverter | mkconvert.converters.htmd | htmd: fast Rust converter. |
| HtmlToMarkdownConverter | mkconvert.converters.base | Base class for HTML -> Markdown converters. |
| HtmlToMarkdownOptions | mkconvert.converters.base | Common HTML -> Markdown options, mapped onto every converter. |
| Markdown2Parser | mkconvert.parsers.markdown2 | markdown2: pure-Python Markdown (not CommonMark compliant), many "extras". |
| MarkdownItPyParser | mkconvert.parsers.markdown_it_py | markdown-it-py + mdit-py-plugins: pure Python, CommonMark compliant, pluggable. |
| MarkdownItPyrsParser | mkconvert.parsers.markdown_it_pyrs | markdown-it-pyrs: Rust port of markdown-it. Deprecated, removed in mkconvert 3.0. |
| MarkdownOptions | mkconvert.parsers.base | Common Markdown -> HTML options, mapped onto every parser. |
| MarkdownParser | mkconvert.parsers.base | Base class for Markdown -> HTML parsers. |
| MarkdownifyConverter | mkconvert.converters.markdownify | markdownify: pure-Python converter on top of BeautifulSoup, highly configurable. |
| MarkoParser | mkconvert.parsers.marko | Marko: pure-Python CommonMark parser, extensible. |
| MistuneParser | mkconvert.parsers.mistune | Mistune: fast pure-Python parser (not fully CommonMark compliant). |
| PyromarkParser | mkconvert.parsers.pyromark | Pyromark: bindings to pulldown-cmark, very fast. |
| PythonMarkdownParser | mkconvert.parsers.python_markdown | Python-Markdown with pymdown-extensions (not CommonMark compliant). |
🛈 DocStrings¶
mkconvert: one API over many Markdown parsers, plus HTML -> Markdown conversion.
OnUnsupported
module-attribute
¶
What to do when options are set that a backend cannot honour.
CmarkgfmParser
¶
Bases: MarkdownParser
cmarkgfm: bindings to cmark-gfm, the reference GFM implementation.
Not supported: heading_ids, alerts, math, definition_lists.
With raw_html=False, raw HTML is replaced by <!-- raw HTML omitted -->.
Source code in src/mkconvert/parsers/cmarkgfm.py
__init__
¶
__init__(
options: MarkdownOptions | None = None,
*,
on_unsupported: OnUnsupported = "warn",
tagfilter: bool = False,
github_pre_lang: bool = False,
sourcepos: bool = False,
) -> None
Create a cmarkgfm parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options
|
MarkdownOptions | None
|
Common options. |
None
|
on_unsupported
|
OnUnsupported
|
See |
'warn'
|
tagfilter
|
bool
|
GFM tag filter: escape |
False
|
github_pre_lang
|
bool
|
GitHub-style |
False
|
sourcepos
|
bool
|
Add |
False
|
Source code in src/mkconvert/parsers/cmarkgfm.py
ComrakParser
¶
Bases: MarkdownParser
Comrak: fast, CommonMark / GFM compliant, supports every common option.
Source code in src/mkconvert/parsers/comrak.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
__init__
¶
__init__(
options: MarkdownOptions | None = None,
*,
on_unsupported: OnUnsupported = "warn",
header_id_prefix: str = "",
tagfilter: bool = False,
superscript: bool = False,
subscript: bool = False,
underline: bool = False,
spoiler: bool = False,
greentext: bool = False,
wikilinks: bool = False,
multiline_block_quotes: bool = False,
math_code: bool = False,
relaxed_autolinks: bool = False,
relaxed_tasklist_matching: bool = False,
default_info_string: str | None = None,
github_pre_lang: bool = False,
full_info_string: bool = False,
sourcepos: bool = False,
) -> None
Create a comrak parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options
|
MarkdownOptions | None
|
Common options. |
None
|
on_unsupported
|
OnUnsupported
|
See |
'warn'
|
header_id_prefix
|
str
|
Prefix for heading ids (with |
''
|
tagfilter
|
bool
|
GFM tag filter: escape |
False
|
superscript
|
bool
|
|
False
|
subscript
|
bool
|
|
False
|
underline
|
bool
|
|
False
|
spoiler
|
bool
|
|
False
|
greentext
|
bool
|
|
False
|
wikilinks
|
bool
|
|
False
|
multiline_block_quotes
|
bool
|
|
False
|
math_code
|
bool
|
|
False
|
relaxed_autolinks
|
bool
|
Looser autolink detection (with |
False
|
relaxed_tasklist_matching
|
bool
|
Any character as task list checkmark. |
False
|
default_info_string
|
str | None
|
Language for fenced code blocks without one. |
None
|
github_pre_lang
|
bool
|
GitHub-style |
False
|
full_info_string
|
bool
|
Keep the full info string as |
False
|
sourcepos
|
bool
|
Add |
False
|
Source code in src/mkconvert/parsers/comrak.py
HtmdConverter
¶
Bases: HtmlToMarkdownConverter
htmd: fast Rust converter.
Not supported: emphasis_marker="_".
Source code in src/mkconvert/converters/htmd.py
__init__
¶
__init__(
options: HtmlToMarkdownOptions | None = None,
*,
on_unsupported: OnUnsupported = "warn",
hr_style: Literal["dashes", "asterisks", "underscores"] = "dashes",
link_reference_style: Literal["full", "collapsed", "shortcut"] = "full",
preformatted_code: bool = False,
ul_bullet_spacing: int = 1,
ol_number_spacing: int = 1,
translation_mode: Literal["pure", "faithful"] = "pure",
) -> None
Create an htmd converter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options
|
HtmlToMarkdownOptions | None
|
Common options. |
None
|
on_unsupported
|
OnUnsupported
|
See |
'warn'
|
hr_style
|
Literal['dashes', 'asterisks', 'underscores']
|
|
'dashes'
|
link_reference_style
|
Literal['full', 'collapsed', 'shortcut']
|
Reference link form (with |
'full'
|
preformatted_code
|
bool
|
Keep whitespace of inline |
False
|
ul_bullet_spacing
|
int
|
Spaces after a bullet list marker. |
1
|
ol_number_spacing
|
int
|
Spaces after an ordered list number. |
1
|
translation_mode
|
Literal['pure', 'faithful']
|
|
'pure'
|
Source code in src/mkconvert/converters/htmd.py
HtmlToMarkdownConverter
¶
Bases: Backend[HtmlToMarkdownOptions]
Base class for HTML -> Markdown converters.
Source code in src/mkconvert/converters/base.py
HtmlToMarkdownOptions
¶
Bases: Options
Common HTML -> Markdown options, mapped onto every converter.
Check HtmlToMarkdownConverter.supported_options for what a converter can change.
Source code in src/mkconvert/converters/base.py
bullet_marker
class-attribute
instance-attribute
¶
Marker for unordered list items.
code_block_style
class-attribute
instance-attribute
¶
Fenced or indented code blocks.
code_fence
class-attribute
instance-attribute
¶
Fence for fenced code blocks.
emphasis_marker
class-attribute
instance-attribute
¶
Marker for *emphasis* and **strong**.
heading_style
class-attribute
instance-attribute
¶
# Heading (atx) or underlined headings (setext, h1 / h2 only).
line_break
class-attribute
instance-attribute
¶
<br> as two trailing spaces or a trailing backslash.
link_style
class-attribute
instance-attribute
¶
[text](url) or [text][1] with the URLs collected at the end.
skip_tags
class-attribute
instance-attribute
¶
Tags to drop together with their content, e.g. ("script", "style").
Markdown2Parser
¶
Bases: MarkdownParser
markdown2: pure-Python Markdown (not CommonMark compliant), many "extras".
Not supported: autolinks, math, definition_lists.
Source code in src/mkconvert/parsers/markdown2.py
__init__
¶
__init__(
options: MarkdownOptions | None = None,
*,
on_unsupported: OnUnsupported = "warn",
extras: Mapping[str, Any] | None = None,
highlight: bool = False,
html4tags: bool = False,
) -> None
Create a markdown2 parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options
|
MarkdownOptions | None
|
Common options. |
None
|
on_unsupported
|
OnUnsupported
|
See |
'warn'
|
extras
|
Mapping[str, Any] | None
|
Further markdown2 extras with their settings ( |
None
|
highlight
|
bool
|
Highlight fenced code blocks with Pygments (if installed). |
False
|
html4tags
|
bool
|
HTML4-style tags ( |
False
|
Source code in src/mkconvert/parsers/markdown2.py
MarkdownItPyParser
¶
Bases: MarkdownParser
markdown-it-py + mdit-py-plugins: pure Python, CommonMark compliant, pluggable.
Supports every common option. Further syntax (MkDocs-style !!! admonitions, MyST
directives, attributes, ...) comes from mdit-py-plugins via plugins.
Source code in src/mkconvert/parsers/markdown_it_py.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
__init__
¶
__init__(
options: MarkdownOptions | None = None,
*,
on_unsupported: OnUnsupported = "warn",
plugins: Sequence[Callable[..., None] | tuple[Callable[..., None], dict[str, Any]]] = (),
xhtml: bool = True,
heading_levels: tuple[int, int] = (1, 6),
) -> None
Create a markdown-it-py parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options
|
MarkdownOptions | None
|
Common options. |
None
|
on_unsupported
|
OnUnsupported
|
See |
'warn'
|
plugins
|
Sequence[Callable[..., None] | tuple[Callable[..., None], dict[str, Any]]]
|
Further plugins, each a plugin function or a |
()
|
xhtml
|
bool
|
Self-closing tags with a trailing slash ( |
True
|
heading_levels
|
tuple[int, int]
|
Lowest and highest heading level that get ids
(with |
(1, 6)
|
Source code in src/mkconvert/parsers/markdown_it_py.py
MarkdownItPyrsParser
¶
Bases: MarkdownParser
markdown-it-pyrs: Rust port of markdown-it. Deprecated, removed in mkconvert 3.0.
Use comrak / pyromark (Rust) or markdown-it-py instead.
Not supported: alerts, math, hard_breaks.
Source code in src/mkconvert/parsers/markdown_it_pyrs.py
__init__
¶
__init__(
options: MarkdownOptions | None = None,
*,
on_unsupported: OnUnsupported = "warn",
xhtml: bool = True,
sourcepos: bool = False,
plugins: list[_PLUGIN_NAME] | None = None,
) -> None
Create a markdown-it-pyrs parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options
|
MarkdownOptions | None
|
Common options. |
None
|
on_unsupported
|
OnUnsupported
|
See |
'warn'
|
xhtml
|
bool
|
Self-closing tags with a trailing slash ( |
True
|
sourcepos
|
bool
|
Add |
False
|
plugins
|
list[_PLUGIN_NAME] | None
|
Further plugins / rules to enable. |
None
|
Source code in src/mkconvert/parsers/markdown_it_pyrs.py
MarkdownOptions
¶
Bases: Options
Common Markdown -> HTML options, mapped onto every parser.
The defaults are plain CommonMark (every extension off, raw HTML passed through),
except that a leading front matter block is dropped.
Check MarkdownParser.supported_options for what a parser can enable.
Source code in src/mkconvert/parsers/base.py
alerts
class-attribute
instance-attribute
¶
GitHub alerts: > [!NOTE], > [!WARNING], ...
autolinks
class-attribute
instance-attribute
¶
Link bare URLs (https://..., www.) like GFM's autolink extension.
definition_lists
class-attribute
instance-attribute
¶
Term followed by : definition lines -> <dl>.
footnotes
class-attribute
instance-attribute
¶
text[^1] references and [^1]: ... definitions.
front_matter
class-attribute
instance-attribute
¶
Drop a leading ----delimited front matter block instead of rendering it.
On by default: almost every Markdown file with a leading --- block means front
matter, not a horizontal rule followed by a heading.
hard_breaks
class-attribute
instance-attribute
¶
Render every newline inside a paragraph as <br>.
heading_ids
class-attribute
instance-attribute
¶
Add slug id attributes to headings.
math
class-attribute
instance-attribute
¶
$inline$ and $$display$$ math, rendered as markup for MathJax / KaTeX.
raw_html
class-attribute
instance-attribute
¶
Pass raw HTML through. False escapes or omits it (parser-dependent).
This is not a sanitizer: use mkconvert.sanitize for untrusted input.
smart_punctuation
class-attribute
instance-attribute
¶
Typographic quotes, dashes and ellipses.
strikethrough
class-attribute
instance-attribute
¶
~~text~~ -> <del> (or <s>).
task_lists
class-attribute
instance-attribute
¶
- [x] item -> list items with checkboxes.
gfm
classmethod
¶
GitHub Flavored Markdown: tables, strikethrough, autolinks and task lists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
changes
|
Any
|
Further options to set, e.g. |
{}
|
Source code in src/mkconvert/parsers/base.py
MarkdownParser
¶
Bases: Backend[MarkdownOptions]
Base class for Markdown -> HTML parsers.
Subclasses take MarkdownOptions plus their own keyword-only options, map them onto
the wrapped library once in __init__ and implement _render.
Source code in src/mkconvert/parsers/base.py
MarkdownifyConverter
¶
Bases: HtmlToMarkdownConverter
markdownify: pure-Python converter on top of BeautifulSoup, highly configurable.
Not supported: code_block_style="indented", code_fence="~~~",
link_style="reference".
Source code in src/mkconvert/converters/markdownify.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
__init__
¶
__init__(
options: HtmlToMarkdownOptions | None = None,
*,
on_unsupported: OnUnsupported = "warn",
bullets: str | None = None,
strip: Sequence[str] | None = None,
convert: Sequence[str] | None = None,
autolinks: bool = True,
default_title: bool = False,
code_language: str = "",
code_language_callback: Callable[[Any], str | None] | None = None,
escape_asterisks: bool = True,
escape_underscores: bool = True,
escape_misc: bool = False,
sub_symbol: str = "",
sup_symbol: str = "",
table_infer_header: bool = False,
wrap: bool = False,
wrap_width: int = 80,
strip_document: Literal["strip", "lstrip", "rstrip"] | None = "strip",
) -> None
Create a markdownify converter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options
|
HtmlToMarkdownOptions | None
|
Common options. |
None
|
on_unsupported
|
OnUnsupported
|
See |
'warn'
|
bullets
|
str | None
|
Bullet markers per nesting level, e.g. |
None
|
strip
|
Sequence[str] | None
|
Tags to drop while keeping their content. |
None
|
convert
|
Sequence[str] | None
|
Only convert these tags (keeping the text of all others). |
None
|
autolinks
|
bool
|
|
True
|
default_title
|
bool
|
Use the URL as title of links without one. |
False
|
code_language
|
str
|
Language for fenced code blocks. |
''
|
code_language_callback
|
Callable[[Any], str | None] | None
|
Derive the language from the |
None
|
escape_asterisks
|
bool
|
Escape |
True
|
escape_underscores
|
bool
|
Escape |
True
|
escape_misc
|
bool
|
Escape other Markdown characters in text. |
False
|
sub_symbol
|
str
|
Wrap |
''
|
sup_symbol
|
str
|
Wrap |
''
|
table_infer_header
|
bool
|
Use the first row as table header if there is no |
False
|
wrap
|
bool
|
Wrap paragraphs at |
False
|
wrap_width
|
int
|
Line width for |
80
|
strip_document
|
Literal['strip', 'lstrip', 'rstrip'] | None
|
Strip whitespace around the result. |
'strip'
|
Source code in src/mkconvert/converters/markdownify.py
MarkoParser
¶
Bases: MarkdownParser
Marko: pure-Python CommonMark parser, extensible.
Not supported: math, definition_lists, smart_punctuation.
Source code in src/mkconvert/parsers/marko.py
__init__
¶
__init__(
options: MarkdownOptions | None = None,
*,
on_unsupported: OnUnsupported = "warn",
extensions: Sequence[str | MarkoExtension] = (),
) -> None
Create a Marko parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options
|
MarkdownOptions | None
|
Common options. |
None
|
on_unsupported
|
OnUnsupported
|
See |
'warn'
|
extensions
|
Sequence[str | MarkoExtension]
|
Further Marko extensions, e.g. |
()
|
Source code in src/mkconvert/parsers/marko.py
MissingDependencyError
¶
MistuneParser
¶
Bases: MarkdownParser
Mistune: fast pure-Python parser (not fully CommonMark compliant).
Not supported: alerts, smart_punctuation. autolinks links bare https://
URLs only, not www. ones.
Source code in src/mkconvert/parsers/mistune.py
__init__
¶
__init__(
options: MarkdownOptions | None = None,
*,
on_unsupported: OnUnsupported = "warn",
plugins: Sequence[str | Callable[..., None]] = (),
) -> None
Create a mistune parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options
|
MarkdownOptions | None
|
Common options. |
None
|
on_unsupported
|
OnUnsupported
|
See |
'warn'
|
plugins
|
Sequence[str | Callable[..., None]]
|
Further mistune plugins: names (e.g. |
()
|
Source code in src/mkconvert/parsers/mistune.py
PyromarkParser
¶
Bases: MarkdownParser
Pyromark: bindings to pulldown-cmark, very fast.
Not supported: autolinks, heading_ids (only explicit # Title {#id} via
heading_attributes), hard_breaks and raw_html=False.
Source code in src/mkconvert/parsers/pyromark.py
__init__
¶
__init__(
options: MarkdownOptions | None = None,
*,
on_unsupported: OnUnsupported = "warn",
heading_attributes: bool = False,
superscript: bool = False,
subscript: bool = False,
wikilinks: bool = False,
old_footnotes: bool = False,
highlight: Theme | None = None,
) -> None
Create a pyromark parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options
|
MarkdownOptions | None
|
Common options. |
None
|
on_unsupported
|
OnUnsupported
|
See |
'warn'
|
heading_attributes
|
bool
|
|
False
|
superscript
|
bool
|
|
False
|
subscript
|
bool
|
|
False
|
wikilinks
|
bool
|
|
False
|
old_footnotes
|
bool
|
Footnotes with the older, looser pulldown-cmark syntax. |
False
|
highlight
|
Theme | None
|
Syntax-highlight code blocks with this theme. |
None
|
Source code in src/mkconvert/parsers/pyromark.py
PythonMarkdownParser
¶
Bases: MarkdownParser
Python-Markdown with pymdown-extensions (not CommonMark compliant).
Fenced code blocks are always on. Strikethrough, task lists, autolinks and math
come from pymdown-extensions. Not supported: alerts.
Source code in src/mkconvert/parsers/python_markdown.py
__init__
¶
__init__(
options: MarkdownOptions | None = None,
*,
on_unsupported: OnUnsupported = "warn",
extensions: Sequence[str | Extension] = (),
extension_configs: Mapping[str, Mapping[str, Any]] | None = None,
output_format: Literal["html", "xhtml"] = "html",
) -> None
Create a Python-Markdown parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options
|
MarkdownOptions | None
|
Common options. |
None
|
on_unsupported
|
OnUnsupported
|
See |
'warn'
|
extensions
|
Sequence[str | Extension]
|
Further extensions, e.g. |
()
|
extension_configs
|
Mapping[str, Mapping[str, Any]] | None
|
Settings per extension name; merged over the ones mkconvert uses for the common options. |
None
|
output_format
|
Literal['html', 'xhtml']
|
|
'html'
|
Source code in src/mkconvert/parsers/python_markdown.py
UnsupportedOptionError
¶
UnsupportedOptionWarning
¶
extract_title
¶
Return the text of the first <h1> in html, or None if there is none.
Markup inside the heading (emphasis, permalink anchors) is dropped and entities are unescaped.
Source code in src/mkconvert/utils.py
get_converter
¶
get_converter(
name: str | None = None,
options: HtmlToMarkdownOptions | None = None,
*,
on_unsupported: OnUnsupported = "warn",
**converter_options: Any,
) -> HtmlToMarkdownConverter
Create the converter registered as name (None: the first installed one).
Raises:
| Type | Description |
|---|---|
ValueError
|
Unknown converter name. |
MissingDependencyError
|
The converter's package is not installed. |
UnsupportedOptionError
|
See |
Source code in src/mkconvert/api.py
get_converter_class
¶
get_converter_class(name: str) -> type[HtmlToMarkdownConverter]
get_parser
¶
get_parser(
name: str | None = None,
options: MarkdownOptions | None = None,
*,
on_unsupported: OnUnsupported = "warn",
**parser_options: Any,
) -> MarkdownParser
Create the parser registered as name (None: the first installed one).
Raises:
| Type | Description |
|---|---|
ValueError
|
Unknown parser name. |
MissingDependencyError
|
The parser's package is not installed. |
UnsupportedOptionError
|
See |
Source code in src/mkconvert/api.py
get_parser_class
¶
get_parser_class(name: str) -> type[MarkdownParser]
list_converters
¶
Names of the registered HTML -> Markdown converters, in order of preference.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
available_only
|
bool
|
Only converters whose package is installed. |
False
|
Source code in src/mkconvert/api.py
list_parsers
¶
Names of the registered parsers, in order of preference.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
available_only
|
bool
|
Only parsers whose package is installed. |
False
|
Source code in src/mkconvert/api.py
register_converter
¶
register_parser
¶
Register a MarkdownParser subclass under its name (usable as decorator).
sanitize
¶
sanitize(
html: str, *, extra_attributes: Mapping[str, Set[str]] | None = None, **nh3_options: Any
) -> str
Sanitize HTML with nh3 (needs the nh3 extra).
Uses nh3's safe defaults, which drop e.g. id and class attributes (heading ids,
code block languages). Allow them again with extra_attributes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
html
|
str
|
HTML to clean. |
required |
extra_attributes
|
Mapping[str, Set[str]] | None
|
Attributes to allow in addition to the allowed ones, per tag;
the key |
None
|
nh3_options
|
Any
|
Keyword arguments for |
{}
|
Source code in src/mkconvert/utils.py
split_front_matter
¶
Split a leading ----delimited front matter block off text.
The block may end with --- or .... It is returned unparsed (usually YAML).
Returns:
| Type | Description |
|---|---|
tuple[str | None, str]
|
|
Source code in src/mkconvert/utils.py
to_html
¶
to_html(
text: str,
*,
parser: str | None = None,
options: MarkdownOptions | None = None,
on_unsupported: OnUnsupported = "warn",
**parser_options: Any,
) -> str
Convert Markdown to HTML.
For many conversions with the same settings, create the parser once with
get_parser and call its convert method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Markdown source. |
required |
parser
|
str | None
|
Parser name (see |
None
|
options
|
MarkdownOptions | None
|
Common options; |
None
|
on_unsupported
|
OnUnsupported
|
What to do with options the parser cannot honour:
|
'warn'
|
parser_options
|
Any
|
Parser-specific options, see the parser class. |
{}
|
Source code in src/mkconvert/api.py
to_markdown
¶
to_markdown(
html: str,
*,
converter: str | None = None,
options: HtmlToMarkdownOptions | None = None,
on_unsupported: OnUnsupported = "warn",
**converter_options: Any,
) -> str
Convert HTML to Markdown.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
html
|
str
|
HTML source. |
required |
converter
|
str | None
|
Converter name (see |
None
|
options
|
HtmlToMarkdownOptions | None
|
Common options; |
None
|
on_unsupported
|
OnUnsupported
|
What to do with options the converter cannot honour:
|
'warn'
|
converter_options
|
Any
|
Converter-specific options, see the converter class. |
{}
|