Commit f3bfe05e authored by Alexandre Leray's avatar Alexandre Leray
Browse files

Modified the make_link callback function

It now takes a markdown instnce as its first parameter. this can be
useful to access the Meta extension dictionnary for instance.
parent 5e69797f
Changelog
=========
Version 1.1
-----------
- The make_link function now takes four arguments:
- `md`
: the current Markdown instance
- `rel`
: the value of the rel attribute
- `target`
: the value of the href attribute
- `label`
: the link text, if any given.
Version 1.0
-----------
- Initial release
......@@ -30,7 +30,8 @@ Usage
Define a custom URL builder:
>>> def make_rdfa(rel, target, label):
>>> def make_rdfa(md, rel, target, label):
... # `md` is the Markdown instance
... elt = etree.Element("span")
... elt.set("property", rel)
... elt.set("value", target)
......
......@@ -28,7 +28,8 @@ Usage
Define a custom URL builder:
>>> def make_rdfa(rel, target, label):
>>> def make_rdfa(md, rel, target, label):
... # `md` is the Markdown instance
... elt = etree.Element("span")
... elt.set("property", rel)
... elt.set("value", target)
......@@ -82,6 +83,9 @@ except ImportError: from markdown.util import etree
import re
__version__ = "1.1"
WIKILINK_RE = r"""
\[\[\s*
(?:((?P<namespace>\w+):)?(?P<rel>[^\]#]+?) \s* ::)? \s*
......@@ -91,7 +95,7 @@ WIKILINK_RE = r"""
""".strip()
def make_link(rel, target, label):
def make_link(md, rel, target, label):
a = etree.Element('a')
a.set('href', target)
if rel:
......@@ -138,7 +142,7 @@ class SemanticWikiLinkPattern(markdown.inlinepatterns.Pattern):
if rel:
rel = "%s:%s" % (namespace, d.get("rel"))
return fn(rel, d.get("target"), d.get("label"))
return fn(self.markdown, rel, d.get("target"), d.get("label"))
def makeExtension(configs={}):
......
......@@ -2,11 +2,12 @@
from setuptools import setup
import mdx_semanticwikilinks
setup(
name='mdx_semanticwikilinks',
version='1.0',
version=mdx_semanticwikilinks.__version__,
author='Alexandre Leray',
author_email='alexandre@stdin.fr',
description='Python-Markdown extension to add support for semantic (wiki)links (RDFa)..',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment