handle toc and anchorlink

This commit is contained in:
Elan Ruusamäe 2012-06-20 01:24:02 +02:00
parent fc6886b4b4
commit 4784fc2080
2 changed files with 13 additions and 5 deletions

View file

@ -1,4 +1,14 @@
This page tries to use each supported markup element at least once.
{{{
'''Index'''
[[TableOfContents(2)]]
}}}
'''Index'''
[[TableOfContents(2)]]
= Headers = = Headers =
== Header 2 == == Header 2 ==
=== Header 3 === === Header 3 ===
@ -24,6 +34,7 @@ print code.colorize("abc", 1 + 1)
foo = new something(1, "soo\nice") foo = new something(1, "soo\nice")
}}} }}}
= Hyperlinks = = Hyperlinks =
== Internal == == Internal ==
{{{ {{{

View file

@ -177,11 +177,8 @@ class Formatter(FormatterBase):
return '' return ''
def anchorlink(self, on, name='', **kw): def anchorlink(self, on, name='', **kw):
id = kw.get('id',None) # kw.id not supported, we hope the anchor matches existing heading on page
extra = '' return ('[[#', ']]') [not on]
if id:
extra = ' id="%s"' % id
return ('<link anchor="%s"%s>' % (name, extra) ,'</link>') [not on]
def underline(self, on, **kw): def underline(self, on, **kw):
return ['__', '__'][not on] return ['__', '__'][not on]