Skip to content
trentm edited this page Apr 4, 2012 · 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
---

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'}

This is informed a little bit by Jekyll's Front Matter and Python-Markdown's Meta-Data. See initial discussion on issue #77.

(Return to Extras page.)

Clone this wiki locally