aboutsummaryrefslogtreecommitdiffstats
path: root/mdx_wikilink.py
diff options
context:
space:
mode:
authorArtem Yunusov <nedrlab@gmail.com>2008-08-02 04:08:13 +0500
committerArtem Yunusov <nedrlab@gmail.com>2008-08-02 04:08:13 +0500
commite54a1868b38c53073eb54df313962a105819b03e (patch)
tree9710069e572ed8e743be4a01096579a5e15f4ad4 /mdx_wikilink.py
parent13d25f86f61bbce247a12b845c3675b57274a13e (diff)
downloadmarkdown-e54a1868b38c53073eb54df313962a105819b03e.tar.gz
markdown-e54a1868b38c53073eb54df313962a105819b03e.tar.bz2
markdown-e54a1868b38c53073eb54df313962a105819b03e.zip
Some other extensions ported to ElementTree, litle bugfix in core.
Diffstat (limited to 'mdx_wikilink.py')
-rwxr-xr-x[-rw-r--r--]mdx_wikilink.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/mdx_wikilink.py b/mdx_wikilink.py
index 46d6c3f..47037a6 100644..100755
--- a/mdx_wikilink.py
+++ b/mdx_wikilink.py
@@ -69,6 +69,7 @@ Dependencies:
'''
import markdown
+from markdown import etree
class WikiLinkExtension (markdown.Extension) :
def __init__(self, configs):
@@ -91,24 +92,25 @@ class WikiLinkExtension (markdown.Extension) :
WIKILINK_PATTERN = WikiLinks(WIKILINK_RE, self.config)
WIKILINK_PATTERN.md = md
md.inlinePatterns.append(WIKILINK_PATTERN)
+
class WikiLinks (markdown.BasePattern) :
def __init__(self, pattern, config):
markdown.BasePattern.__init__(self, pattern)
self.config = config
- def handleMatch(self, m, doc) :
+ def handleMatch(self, m):
if m.group('escape') == '\\':
- a = doc.createTextNode(m.group('camelcase'))
+ a = m.group('camelcase')
else:
base_url, end_url, html_class = self._getMeta()
url = '%s%s%s'% (base_url, m.group('camelcase'), end_url)
label = m.group('camelcase').replace('_', ' ')
- a = doc.createElement('a')
- a.appendChild(doc.createTextNode(label))
- a.setAttribute('href', url)
+ a = etree.Element('a')
+ a.text = label
+ a.set('href', url)
if html_class:
- a.setAttribute('class', html_class)
+ a.set('class', html_class)
return a
def _getMeta(self):
@@ -124,6 +126,9 @@ class WikiLinks (markdown.BasePattern) :
if self.md.Meta.has_key('wiki_html_class'):
html_class = self.md.Meta['wiki_html_class'][0]
return base_url, end_url, html_class
+
+ def type(self):
+ return "WLink"
def makeExtension(configs=None) :