Submit
Path:
~
/
/
proc
/
thread-self
/
root
/
proc
/
thread-self
/
root
/
usr
/
lib
/
python2.7
/
site-packages
/
markdown
/
extensions
/
File Content:
wikilinks.pyc
� �(�Sc @@ s� d Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l Z d � Z d e f d � � YZ d e f d � � YZ d d � Z d S( ue WikiLinks Extension for Python-Markdown ====================================== Converts [[WikiLinks]] to relative links. Requires Python-Markdown 2.0+ Basic usage: >>> import markdown >>> text = "Some text with a [[WikiLink]]." >>> html = markdown.markdown(text, ['wikilinks']) >>> print html <p>Some text with a <a class="wikilink" href="/WikiLink/">WikiLink</a>.</p> Whitespace behavior: >>> print markdown.markdown('[[ foo bar_baz ]]', ['wikilinks']) <p><a class="wikilink" href="/foo_bar_baz/">foo bar_baz</a></p> >>> print markdown.markdown('foo [[ ]] bar', ['wikilinks']) <p>foo bar</p> To define custom settings the simple way: >>> print markdown.markdown(text, ... ['wikilinks(base_url=/wiki/,end_url=.html,html_class=foo)'] ... ) <p>Some text with a <a class="foo" href="/wiki/WikiLink.html">WikiLink</a>.</p> Custom settings the complex way: >>> md = markdown.Markdown( ... extensions = ['wikilinks'], ... extension_configs = {'wikilinks': [ ... ('base_url', 'http://example.com/'), ... ('end_url', '.html'), ... ('html_class', '') ]}, ... safe_mode = True) >>> print md.convert(text) <p>Some text with a <a href="http://example.com/WikiLink.html">WikiLink</a>.</p> Use MetaData with mdx_meta.py (Note the blank html_class in MetaData): >>> text = """wiki_base_url: http://example.com/ ... wiki_end_url: .html ... wiki_html_class: ... ... Some text with a [[WikiLink]].""" >>> md = markdown.Markdown(extensions=['meta', 'wikilinks']) >>> print md.convert(text) <p>Some text with a <a href="http://example.com/WikiLink.html">WikiLink</a>.</p> MetaData should not carry over to next document: >>> print md.convert("No [[MetaData]] here.") <p>No <a class="wikilink" href="/MetaData/">MetaData</a> here.</p> Define a custom URL builder: >>> def my_url_builder(label, base, end): ... return '/bar/' >>> md = markdown.Markdown(extensions=['wikilinks'], ... extension_configs={'wikilinks' : [('build_url', my_url_builder)]}) >>> print md.convert('[[foo]]') <p><a class="wikilink" href="/bar/">foo</a></p> From the command line: python markdown.py -x wikilinks(base_url=http://example.com/,end_url=.html,html_class=foo) src.txt By [Waylan Limberg](http://achinghead.com/). License: [BSD](http://www.opensource.org/licenses/bsd-license.php) Dependencies: * [Python 2.3+](http://python.org) * [Markdown 2.0+](http://packages.python.org/Markdown/) i ( t absolute_import( t unicode_literalsi ( t Extensioni ( t Pattern( t etreeNc C@ s&