implement also numbered list
This commit is contained in:
parent
b4286ab450
commit
c15568c652
2 changed files with 32 additions and 10 deletions
|
@ -46,3 +46,20 @@ sixth line!
|
||||||
* item 2, with gap
|
* item 2, with gap
|
||||||
* item 3
|
* item 3
|
||||||
* item 3.1
|
* 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
|
||||||
|
|
|
@ -26,7 +26,8 @@ class Formatter(FormatterBase):
|
||||||
self.in_pre = 0
|
self.in_pre = 0
|
||||||
self._text = None # XXX does not work with links in headings!!!!!
|
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={"'": "'", '"': """}):
|
def _escape(self, text, extra_mapping={"'": "'", '"': """}):
|
||||||
return saxutils.escape(text, extra_mapping)
|
return saxutils.escape(text, extra_mapping)
|
||||||
|
@ -103,22 +104,26 @@ class Formatter(FormatterBase):
|
||||||
return ['**', '**'][not on]
|
return ['**', '**'][not on]
|
||||||
|
|
||||||
def number_list(self, on, type=None, start=None, **kw):
|
def number_list(self, on, type=None, start=None, **kw):
|
||||||
result = ''
|
# list type not supported
|
||||||
if self.in_p:
|
if on:
|
||||||
result = self.paragraph(0)
|
self.list_depth += 1
|
||||||
return result + ['<ol>', '</ol>\n'][not on]
|
self.list_type = '-'
|
||||||
|
else:
|
||||||
|
self.list_depth -= 1
|
||||||
|
|
||||||
|
return ['', '\n'][on]
|
||||||
|
|
||||||
def bullet_list(self, on, **kw):
|
def bullet_list(self, on, **kw):
|
||||||
# fill: ' * '
|
|
||||||
if on:
|
if on:
|
||||||
self.bullet_depth += 1
|
self.list_depth += 1
|
||||||
|
self.list_type = '*'
|
||||||
else:
|
else:
|
||||||
self.bullet_depth -= 1
|
self.list_depth -= 1
|
||||||
|
|
||||||
return ['\n', ''][not on]
|
return ['', '\n'][on]
|
||||||
|
|
||||||
def listitem(self, on, **kw):
|
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):
|
def code(self, on, **kw):
|
||||||
""" `typewriter` or {{{typerwriter}}, for code blocks i hope codeblock works """
|
""" `typewriter` or {{{typerwriter}}, for code blocks i hope codeblock works """
|
||||||
|
|
Loading…
Reference in a new issue