3 \ @sdZddlmZddlmZddlmZddlmZddlZej d Z ej d Z Gd d d eZ Gd ddeZ ifddZdS)aW Meta Data Extension for Python-Markdown ======================================= This extension adds Meta Data handling to markdown. Basic Usage: >>> import markdown >>> text = '''Title: A Test Doc. ... Author: Waylan Limberg ... John Doe ... Blank_Data: ... ... The body. This is paragraph one. ... ''' >>> md = markdown.Markdown(['meta']) >>> print md.convert(text)

The body. This is paragraph one.

>>> print md.Meta {u'blank_data': [u''], u'author': [u'Waylan Limberg', u'John Doe'], u'title': [u'A Test Doc.']} Make sure text without Meta Data still works (markdown < 1.6b returns a

). >>> text = ' Some Code - not extra lines of meta data.' >>> md = markdown.Markdown(['meta']) >>> print md.convert(text)

Some Code - not extra lines of meta data.
    
>>> md.Meta {} Copyright 2007-2008 [Waylan Limberg](http://achinghead.com). Project website: Contact: markdown@freewisdom.org License: BSD (see ../LICENSE.md for details) )absolute_import)unicode_literals) Extension) PreprocessorNz1^[ ]{0,3}(?P[A-Za-z0-9_-]+):\s*(?P.*)z^[ ]{4,}(?P.*)c@seZdZdZddZdS) MetaExtensionz* Meta-Data extension for Python-Markdown. cCs|jjdt|ddS)z, Add MetaPreprocessor to Markdown instance. meta_beginN) preprocessorsaddMetaPreprocessor)selfmd md_globalsr%build/lib/markdown/extensions/meta.pyextendMarkdown7szMetaExtension.extendMarkdownN)__name__ __module__ __qualname____doc__rrrrrr4src@seZdZdZddZdS)r z Get Meta-Data. c Csi}d}x|r|jd}|jdkr&Ptj|}|r|jdjj}|jdj}y||j|Wqtk r|g||<YqXq tj|}|r|r||j|jdjq |j d|Pq W||j _ |S)z- Parse Meta-Data and store in Markdown.Meta. Nrkeyvalue) popstripMETA_REmatchgrouplowerappendKeyError META_MORE_REinsertmarkdownMeta)rlinesr rlinem1rm2rrrrun@s*     zMetaPreprocessor.runN)rrrrr+rrrrr =sr cCs t|dS)N)configs)r)r,rrr makeExtension\sr-)r __future__rrrrr rrecompilerr#rr r-rrrr(s