1
SemanticWikiLinks Extension for Python-Markdown
2
===============================================
4
Adds support for semantic (wiki)links (RDFa).
6
Converts links of style `[[rel :: target | label ]]`, where `rel` and `label`
9
Customizable with `make_link` option as to what the actual element is.
15
pip install git+git://github.com/aleray/mdx_semanticwikilinks.git
21
>>> text = "Some text with a [[WikiLink]]."
22
>>> html = markdown.markdown(text, ['semanticwikilinks'])
24
<p>Some text with a <a href="WikiLink">WikiLink</a>.</p>
26
>>> text = "[[http://activearchives.org/]], [[#id|anchor]], [[../index.html|a relative link]], [[/|an absolute link]], [[/index.html|another absolute link]]"
27
>>> html = markdown.markdown(text, ['semanticwikilinks'])
29
<p><a href="http://activearchives.org/">http://activearchives.org/</a>, <a href="#id">anchor</a>, <a href="../index.html">a relative link</a>, <a href="/">an absolute link</a>, <a href="/index.html">another absolute link</a></p>
31
Define a custom URL builder:
33
>>> def make_rdfa(md, rel, target, label):
34
... # `md` is the Markdown instance
35
... elt = etree.Element("span")
36
... elt.set("property", rel)
37
... elt.set("value", target)
38
... elt.text = label or target
41
>>> md = markdown.Markdown(extensions=['semanticwikilinks'],
42
... extension_configs={'semanticwikilinks' : [('make_link', make_rdfa)]})
43
>>> html = md.convert('[[ Speaker :: Sherry Turkle | Second Self ]]')
45
<p><span property="aa:Speaker" value="Sherry Turkle">Second Self</span></p>
47
Change the default namespace (which is "aa"):
49
>>> md = markdown.Markdown(extensions=['semanticwikilinks'],
50
... extension_configs={'semanticwikilinks' : [('namespace', 'mynamespace')]})
51
>>> html = md.convert('[[ Speaker :: Sherry Turkle | Second Self ]]')
53
<p><a href="Sherry Turkle" rel="mynamespace:Speaker">Second Self</a></p>
58
- An optional function to wikify names? (It is already possible to achieve
59
this with the custom `make_link` function).
65
* [Markdown 2.0+](http://www.freewisdom.org/projects/python-markdown/)
71
- 2011, 2012 [The active archives contributors](http://activearchives.org/)
72
- 2011, 2012 [Michael Murtaugh](http://automatist.org/)
73
- 2011, 2012 [Alexandre Leray](http://stdin.fr/)
77
This software is released under the modified BSD License.
78
See LICENSE.md for details.