Commit da9ecf1e authored by glondu's avatar glondu

Gestion correcte des listes imbriquees.

darcs-hash:20060430052435-68412-3a63ca369df3a90194d92b8983234796b8814729.gz
parent 4f7a0538
......@@ -3,6 +3,7 @@
MoinMoin - "text/plain" Formatter
@copyright: 2000, 2001, 2002 by Jrgen Hermann <jh@web.de>
@copyright: 2006 by Stphane Glondu <glondu@crans.org>
@license: GNU GPL, see COPYING for details.
"""
......@@ -20,7 +21,7 @@ class Formatter(FormatterBase):
self._in_code_area = 0
self._in_code_line = 0
self._code_area_state = [0, -1, -1, 0]
self._in_list = 0
self._nested_lists = []
self._did_para = 0
self._url = None
self._text = None # XXX does not work with links in headings!!!!!
......@@ -92,10 +93,10 @@ class Formatter(FormatterBase):
def number_list(self, on, type=None, start=None):
if on:
self._in_list = 1
self._nested_lists.append(1)
return [u'\n', u'\n\n'][not self._did_para]
else:
self._in_list = 0
self._nested_lists.pop()
if not self._did_para:
self._did_para = 1
return u'\n'
......@@ -103,10 +104,10 @@ class Formatter(FormatterBase):
def bullet_list(self, on):
if on:
self._in_list = -1
self._nested_lists.append(0)
return [u'\n', u'\n\n'][not self._did_para]
else:
self._in_list = 0
self._nested_lists.pop()
if not self._did_para:
self._did_para = 1
return u'\n'
......@@ -114,14 +115,17 @@ class Formatter(FormatterBase):
def listitem(self, on, **kw):
if on:
if self._in_list>0:
self._in_list += 1
if self._nested_lists:
number = self._nested_lists[-1]
if number:
bullet = '%d.' % number
self._nested_lists[-1] = number + 1
else:
bullet = '*'
self._did_para = 1
return ' %d. ' % (self._in_list-1,)
elif self._in_list<0:
self._did_para = 1
return u' * '
return ' %s%s ' % (' ' * (len(self._nested_lists)-1), bullet)
else:
self._did_para = 1
return u' * '
else:
self._did_para = 1
......@@ -231,3 +235,12 @@ class Formatter(FormatterBase):
def lang(self, on, lang_name):
return ''
def langAttr(self, lang=None):
return {}
def open(self, tag, newline=False, attr=None):
return u''
def close(self, tag, newline=False):
return u''
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment