fixes to url parsing

This commit is contained in:
Elan Ruusamäe 2012-06-20 01:07:26 +02:00
parent cfc4285482
commit 7c6fe19324
2 changed files with 54 additions and 6 deletions

View file

@ -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

View file

@ -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 ('<jump href="%s"%s>' % (self._escape(url), str), '</jump>') [not on]
return ('[[%s|' % (self._escape(url)), ']]') [not on]
def attachment_link(self, url, text, **kw):
return '{{%s|%s}}' % (url, text)