You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
David Lowry-Duda edited this page Dec 20, 2016
·
3 revisions
metadata extra
The metadata extra enables parsing out of a leading metadata block in a
markdown file. A metadata block looks like this:
---
foo: bar
Another-Key: another value
Key-with-long-value: >
can be given with this form. Greater than sign, followed by
a block of intended lines.
A-further-key: some other value.
---
# Rest of markdown document
It is also possible to not use ---, and instead interpret the lines until the first blank line as metadata. Such a metablock looks like:
foo: bar
Another-Key: another value
Key-with-long-value: >
can be given with this form. Greater than sign, followed by
a block of intended lines.
A-further-key: some other value.
# Rest of markdown document
The metadata is returned as a dictionary as the metadata attribute of the returned HTML:
>>> import markdown2
>>> text = """---
... foo: bar
... ---
...
... *hi*
... """
>>> html = markdown2.markdown(text, extras=["metadata"])
>>> html
u'<p><em>hi</em></p>\n'
>>> html.metadata
{u'foo': u'bar'}