implement also numbered list

This commit is contained in:
Elan Ruusamäe 2012-06-20 00:38:14 +02:00
parent b4286ab450
commit c15568c652
2 changed files with 32 additions and 10 deletions

View file

@ -46,3 +46,20 @@ sixth line!
* item 2, with gap
* item 3
* item 3.1
= Numbered list =
{{{
1. item 1
i. item 1
i. item 2
}}}
1. item 1
i. item 1
i. item 2
{{{
1. item 2
a. item 1
a. item 2
}}}
1. item 2
a. item 1
a. item 2

View file

@ -26,7 +26,8 @@ class Formatter(FormatterBase):
self.in_pre = 0
self._text = None # XXX does not work with links in headings!!!!!
self.bullet_depth = 0
self.list_depth = 0
self.list_type = None
def _escape(self, text, extra_mapping={"'": "'", '"': """}):
return saxutils.escape(text, extra_mapping)
@ -103,22 +104,26 @@ class Formatter(FormatterBase):
return ['**', '**'][not on]
def number_list(self, on, type=None, start=None, **kw):
result = ''
if self.in_p:
result = self.paragraph(0)
return result + ['<ol>', '</ol>\n'][not on]
# list type not supported
if on:
self.list_depth += 1
self.list_type = '-'
else:
self.list_depth -= 1
return ['', '\n'][on]
def bullet_list(self, on, **kw):
# fill: ' * '
if on:
self.bullet_depth += 1
self.list_depth += 1
self.list_type = '*'
else:
self.bullet_depth -= 1
self.list_depth -= 1
return ['\n', ''][not on]
return ['', '\n'][on]
def listitem(self, on, **kw):
return [(' ' * self.bullet_depth * 2) + '* ', '\n'][not on]
return [(' ' * self.list_depth * 2) + self.list_type + ' ', '\n'][not on]
def code(self, on, **kw):
""" `typewriter` or {{{typerwriter}}, for code blocks i hope codeblock works """