From 7c6fe19324a69395af910ab46f5ffed155b2c135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Wed, 20 Jun 2012 01:07:26 +0200 Subject: [PATCH] fixes to url parsing --- syntaxreference.txt | 50 +++++++++++++++++++++++++++++++++++++++++++++ text_dokuwiki.py | 10 ++++----- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/syntaxreference.txt b/syntaxreference.txt index 3edcd1c..9501ff2 100644 --- a/syntaxreference.txt +++ b/syntaxreference.txt @@ -24,6 +24,56 @@ print code.colorize("abc", 1 + 1) foo = new something(1, "soo\nice") }}} += Hyperlinks = +== Internal == +{{{ + * MoinMoin + * MoinMoin/TextFormatting + * MoinMoin/InstallDocs + * ../InstallDocs + * /SubPage + * Self:InterWiki +}}} + * MoinMoin + * MoinMoin/TextFormatting + * MoinMoin/InstallDocs + * ../InstallDocs + * /SubPage + * Self:InterWiki + +{{{ +[#anchorname Anchor Link] +}}} +[#anchorname Anchor Link] + +== External == +{{{ + * http://moinmoin.wikiwikiweb.de/ + * [http://moinmoin.wikiwikiweb.de/] + * [http://moinmoin.wikiwikiweb.de/ MoinMoin Wiki] + * [http://moinmoin.wikiwikiweb.de/wiki/classic/img/moinmoin.png] + * http://moinmoin.wikiwikiweb.de/wiki/classic/img/moinmoin.png + * [http://moinmoin.wikiwikiweb.de/wiki/classic/img/moinmoin.png moinmoin.png] + * MeatBall:InterWiki + * wiki:MeatBall/InterWiki + * [wiki:MeatBall/InterWiki] + * [wiki:MeatBall/InterWiki InterWiki page on MeatBall] + * [file://servername/full/path/to/file/filename%20with%20spaces.txt Click here to read filename with spaces.txt] + * me@privacy.net +}}} + * http://moinmoin.wikiwikiweb.de/ + * [http://moinmoin.wikiwikiweb.de/] + * [http://moinmoin.wikiwikiweb.de/ MoinMoin Wiki] + * [http://moinmoin.wikiwikiweb.de/wiki/classic/img/moinmoin.png] + * http://moinmoin.wikiwikiweb.de/wiki/classic/img/moinmoin.png + * [http://moinmoin.wikiwikiweb.de/wiki/classic/img/moinmoin.png moinmoin.png] + * MeatBall:InterWiki + * wiki:MeatBall/InterWiki + * [wiki:MeatBall/InterWiki] + * [wiki:MeatBall/InterWiki InterWiki page on MeatBall] + * [file://servername/full/path/to/file/filename%20with%20spaces.txt Click here to read filename with spaces.txt] + * me@privacy.net + = Bullet list = {{{ * item 1 diff --git a/text_dokuwiki.py b/text_dokuwiki.py index 98999ef..382b102 100644 --- a/text_dokuwiki.py +++ b/text_dokuwiki.py @@ -28,6 +28,8 @@ class Formatter(FormatterBase): self.list_depth = 0 self.list_type = None + # dokuwiki namespace spearator, ':' or '/', see 'useslash' config + self.ns_sep = '/'; def _escape(self, text, extra_mapping={"'": "'", '"': """}): return saxutils.escape(text, extra_mapping) @@ -61,16 +63,12 @@ class Formatter(FormatterBase): def interwikilink(self, on, interwiki='', pagename='', **kw): if on: - return '[[%s|%s' % (interwiki, pagename) + return '[[%s%s%s|' % (interwiki, self.ns_sep, pagename) else: return ']]' def url(self, on, url='', css=None, **kw): - if css: - str = ' class="%s"' % css - else: - str = '' - return ('' % (self._escape(url), str), '') [not on] + return ('[[%s|' % (self._escape(url)), ']]') [not on] def attachment_link(self, url, text, **kw): return '{{%s|%s}}' % (url, text)