Parsing & Rendering#
- humanmark.load(f: TextIO, *, backend=None) humanmark.ast.Fragment #
Parse a markdown file into a
Fragment
.>>> from humanmark import parse >>> with open('README.md', 'rt') as source: ... fragment = load(source)
- Parameters
f – Any file-like object providing read().
backend – The Markdown backend to use to parse this document. [default: markdown-it-py]
- humanmark.loads(content: str, *, backend=None) humanmark.ast.Fragment #
Parse a markdown string into a
Fragment
.>>> from humanmark import parse >>> loads('# This is a header!').pprint() [0000]├─<Fragment()> [0000]│ └─<Header(1)> [0000]│ └─<Text('This is a header!')>
- Parameters
content – A valid markdown document to be parsed.
backend – The Markdown backend to use to parse this document. [default: markdown-it-py]
- humanmark.dump(node: humanmark.ast.Node, f: TextIO, *, renderer=None)#
Renders a HumanMark AST node to the file-like object f.
- Parameters
renderer – An optional renderer to use instead of the default MarkdownRender.
- humanmark.dumps(node: humanmark.ast.Node, *, renderer=None) str #
Renders a HumanMark AST node to a string and returns it.
- Parameters
renderer – An optional renderer to use instead of the default MarkdownRender.