~widelands-dev/widelands-website/trunk

« back to all changes in this revision

Viewing changes to markdownextensions/semanticwikilinks/README.md

  • Committer: kaputtnik
  • Date: 2019-05-30 18:20:02 UTC
  • mto: This revision was merged to the branch mainline in revision 540.
  • Revision ID: kaputtnik-20190530182002-g7l91m1xo28clghv
adjusted README; first commit on the new server

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
SemanticWikiLinks Extension for Python-Markdown
 
2
===============================================
 
3
 
 
4
Adds support for semantic (wiki)links (RDFa).
 
5
 
 
6
Converts links of style `[[rel :: target | label ]]`, where `rel` and `label`
 
7
are optional.
 
8
 
 
9
Customizable with `make_link` option as to what the actual element is.
 
10
 
 
11
 
 
12
Installation
 
13
------------
 
14
 
 
15
    pip install git+git://github.com/aleray/mdx_semanticwikilinks.git
 
16
 
 
17
 
 
18
Usage
 
19
-----
 
20
 
 
21
    >>> text = "Some text with a [[WikiLink]]."
 
22
    >>> html = markdown.markdown(text, ['semanticwikilinks'])
 
23
    >>> print(html)
 
24
    <p>Some text with a <a href="WikiLink">WikiLink</a>.</p>
 
25
 
 
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'])
 
28
    >>> print(html)
 
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>
 
30
 
 
31
Define a custom URL builder:
 
32
 
 
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
 
39
    ...     return elt
 
40
 
 
41
    >>> md = markdown.Markdown(extensions=['semanticwikilinks'],
 
42
    ...         extension_configs={'semanticwikilinks' : [('make_link', make_rdfa)]})
 
43
    >>> html = md.convert('[[ Speaker :: Sherry Turkle | Second Self ]]')
 
44
    >>> print(html)
 
45
    <p><span property="aa:Speaker" value="Sherry Turkle">Second Self</span></p>
 
46
 
 
47
Change the default namespace (which is "aa"):
 
48
 
 
49
    >>> md = markdown.Markdown(extensions=['semanticwikilinks'],
 
50
    ...         extension_configs={'semanticwikilinks' : [('namespace', 'mynamespace')]})
 
51
    >>> html = md.convert('[[ Speaker :: Sherry Turkle | Second Self ]]')
 
52
    >>> print(html)
 
53
    <p><a href="Sherry Turkle" rel="mynamespace:Speaker">Second Self</a></p>
 
54
 
 
55
To do
 
56
-----
 
57
 
 
58
- An optional function to wikify names? (It is already possible to achieve
 
59
this with the custom `make_link` function).
 
60
 
 
61
 
 
62
Dependencies
 
63
------------
 
64
 
 
65
* [Markdown 2.0+](http://www.freewisdom.org/projects/python-markdown/)
 
66
 
 
67
 
 
68
Copyright
 
69
---------
 
70
 
 
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/)
 
74
 
 
75
All rights reserved.
 
76
 
 
77
This software is released under the modified BSD License. 
 
78
See LICENSE.md for details.