aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaylan Limberg <waylan@gmail.com>2008-09-20 00:45:46 -0400
committerWaylan Limberg <waylan@gmail.com>2008-09-20 00:45:46 -0400
commit56cd793408ae2667e631d8913653eb5fec568545 (patch)
tree4012da2d1360ba1e5cb1eb5ed85c6e28bd670836
parent41cc4c02e57ed1b25f12e78e3f34ddf64a81f392 (diff)
downloadmarkdown-56cd793408ae2667e631d8913653eb5fec568545.tar.gz
markdown-56cd793408ae2667e631d8913653eb5fec568545.tar.bz2
markdown-56cd793408ae2667e631d8913653eb5fec568545.zip
Removed old 'wikilink' extension.
-rw-r--r--markdown_extensions/wikilink.py139
-rw-r--r--test-markdown.py2
-rw-r--r--tests/extensions-x-wikilink/wikilinks.html7
-rw-r--r--tests/extensions-x-wikilink/wikilinks.txt8
4 files changed, 1 insertions, 155 deletions
diff --git a/markdown_extensions/wikilink.py b/markdown_extensions/wikilink.py
deleted file mode 100644
index fd0b62f..0000000
--- a/markdown_extensions/wikilink.py
+++ /dev/null
@@ -1,139 +0,0 @@
-#!/usr/bin/env python
-
-'''
-WikiLink Extention for Python-Markdown
-======================================
-
-Converts CamelCase words to relative links. Requires Python-Markdown 1.6+
-
-Basic usage:
-
- >>> import markdown
- >>> text = "Some text with a WikiLink."
- >>> md = markdown.markdown(text, ['wikilink'])
- >>> md
- u'<p>Some text with a <a href="/WikiLink/" class="wikilink">WikiLink</a>.\\n</p>'
-
-To define custom settings the simple way:
-
- >>> md = markdown.markdown(text,
- ... ['wikilink(base_url=/wiki/,end_url=.html,html_class=foo)']
- ... )
- >>> md
- u'<p>Some text with a <a href="/wiki/WikiLink.html" class="foo">WikiLink</a>.\\n</p>'
-
-Custom settings the complex way:
-
- >>> md = markdown.Markdown(
- ... extensions = ['wikilink'],
- ... extension_configs = {'wikilink': [
- ... ('base_url', 'http://example.com/'),
- ... ('end_url', '.html'),
- ... ('html_class', '') ]},
- ... safe_mode = True)
- >>> md.convert(text)
- u'<p>Some text with a <a href="http://example.com/WikiLink.html">WikiLink</a>.\\n</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', 'wikilink'])
- >>> md.convert(text)
- u'<p>Some text with a <a href="http://example.com/WikiLink.html">WikiLink</a>.\\n</p>'
-
-MetaData should not carry over to next document:
-
- >>> md.convert("No MetaData here.")
- u'<p>No <a href="/MetaData/" class="wikilink">MetaData</a> here.\\n</p>'
-
-From the command line:
-
- python markdown.py -x wikilink(base_url=http://example.com/,end_url=.html,html_class=foo) src.txt
-
-By [Waylan Limberg](http://achinghead.com/).
-
-Project website: http://achinghead.com/markdown-wikilinks/
-Contact: waylan [at] gmail [dot] com
-
-License: [BSD](http://www.opensource.org/licenses/bsd-license.php)
-
-Version: 0.6 (May 2, 2008)
-
-Dependencies:
-* [Python 2.3+](http://python.org)
-* [Markdown 1.6+](http://www.freewisdom.org/projects/python-markdown/)
-'''
-
-import markdown
-
-class WikiLinkExtension (markdown.Extension) :
- def __init__(self, configs):
- # set extension defaults
- self.config = {
- 'base_url' : ['/', 'String to append to beginning or URL.'],
- 'end_url' : ['/', 'String to append to end of URL.'],
- 'html_class' : ['wikilink', 'CSS hook. Leave blank for none.']
- }
-
- # Override defaults with user settings
- for key, value in configs :
- self.setConfig(key, value)
-
- def extendMarkdown(self, md, md_globals):
- self.md = md
-
- # append to end of inline patterns
- WIKILINK_RE = r'''(?P<escape>\\|\b)(?P<camelcase>([A-Z]+[a-z-_]+){2,})\b'''
- 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):
- if m.group('escape') == '\\':
- 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 = markdown.etree.Element('a')
- a.text = markdown.AtomicString(label)
- a.set('href', url)
- if html_class:
- a.set('class', html_class)
- return a
-
- def _getMeta(self):
- """ Return meta data or config data. """
- base_url = self.config['base_url'][0]
- end_url = self.config['end_url'][0]
- html_class = self.config['html_class'][0]
- if hasattr(self.md, 'Meta'):
- if self.md.Meta.has_key('wiki_base_url'):
- base_url = self.md.Meta['wiki_base_url'][0]
- if self.md.Meta.has_key('wiki_end_url'):
- end_url = self.md.Meta['wiki_end_url'][0]
- 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) :
- return WikiLinkExtension(configs=configs)
-
-if __name__ == "__main__":
- import doctest
- doctest.testmod()
-
diff --git a/test-markdown.py b/test-markdown.py
index e3a55b8..c96d60b 100644
--- a/test-markdown.py
+++ b/test-markdown.py
@@ -371,7 +371,7 @@ testDirectory("tests/extensions-x-tables")
#testDirectory("tests/extensions-x-ext1-ext2")
testDirectory("tests/safe_mode", measure_time=True, safe_mode="escape")
testDirectory("tests/extensions-x-codehilite")
-testDirectory("tests/extensions-x-wikilink")
+testDirectory("tests/extensions-x-wikilinks")
print "\n### Final result ###"
if len(failedTests):
diff --git a/tests/extensions-x-wikilink/wikilinks.html b/tests/extensions-x-wikilink/wikilinks.html
deleted file mode 100644
index 65080d1..0000000
--- a/tests/extensions-x-wikilink/wikilinks.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<p>Some text with a <a class="wikilink" href="/WikiLink/">WikiLink</a>.</p>
-<p>And a <a href="http://example.com/RealLink">RealLink</a>.</p>
-<p>
- <a href="http://example.com/And_A_AutoLink">http://example.com/And_A_AutoLink</a>
-</p>
-<p>And a <a href="/MarkdownLink/" title="A MarkdownLink">MarkdownLink</a> for completeness.</p>
-
diff --git a/tests/extensions-x-wikilink/wikilinks.txt b/tests/extensions-x-wikilink/wikilinks.txt
deleted file mode 100644
index d707526..0000000
--- a/tests/extensions-x-wikilink/wikilinks.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-Some text with a WikiLink.
-
-And a <a href="http://example.com/RealLink">RealLink</a>.
-
-<http://example.com/And_A_AutoLink>
-
-And a [MarkdownLink](/MarkdownLink/ "A MarkdownLink") for
-completeness.