htmy.md.core
MD
Bases: Snippet
Component for reading, customizing, and rendering markdown documents.
Source code in htmy/md/core.py
__init__(path_or_text, *, converter=None, renderer=None)
Initialization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path_or_text
|
Text | str | Path
|
The path where the markdown file is located or a markdown |
required |
converter
|
Callable[[str], Component] | None
|
Function that converts an HTML string (the parsed and processed markdown text) into an HTMY component. |
None
|
renderer
|
MarkdownRenderFunction | None
|
Function that get the parsed and converted content and the metadata (if it exists) and turns them into an HTMY component. |
None
|
Source code in htmy/md/core.py
MarkdownParser
Bases: ContextAware
Context-aware markdown parser.
By default, this class uses the markdown
library with a sensible set of
extensions including code highlighing.
Source code in htmy/md/core.py
__init__(md=None)
Initialization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
md
|
MarkdownParserFunction | None
|
The parser function to use. |
None
|
default()
classmethod
parse(text)
Returns the markdown data by parsing the given text.
htmy.md.typing
MarkdownParserFunction: TypeAlias = Callable[[str], ParsedMarkdown]
module-attribute
Callable that converts a markdown string into a ParsedMarkdown
object.
MarkdownRenderFunction: TypeAlias = Callable[[Component, MarkdownMetadataDict | None], Component]
module-attribute
Renderer function definition for markdown data.