Commit 7d45b34d authored by glondu's avatar glondu

Amelioration de la gestion des listes.

darcs-hash:20060430083810-68412-37999d5a03d60545b55775e8f40ae1c010351d88.gz
parent 35cedcfd
......@@ -22,13 +22,14 @@ class Formatter(FormatterBase):
self._in_code_line = 0
self._code_area_state = [0, -1, -1, 0]
self._nested_lists = []
self._did_para = 0
self._did_para = False
self._url = None
self._text = None # XXX does not work with links in headings!!!!!
def startDocument(self, pagename):
line = u"*" * (len(pagename)+2) + u'\n'
return u"%s %s \n%s" % (line, pagename, line)
self._did_para = True
return u"%s %s \n%s\n" % (line, pagename, line)
def endDocument(self):
return u'\n'
......@@ -72,7 +73,7 @@ class Formatter(FormatterBase):
return u' [%s]' % (self._url)
def text(self, text):
self._did_para = 0
self._did_para = False
if self._text is not None:
self._text.append(text)
return text
......@@ -91,30 +92,31 @@ class Formatter(FormatterBase):
def highlight(self, on):
return u''
def number_list(self, on, type=None, start=None):
def _list(self, on, bullet):
if on:
self._nested_lists.append(1)
return [u'\n', u'\n\n'][not self._did_para]
self._nested_lists.append(bullet)
if self._did_para:
self._did_para = False
return u''
else:
return u'\n'
else:
self._nested_lists.pop()
if not self._did_para:
self._did_para = 1
return u'\n'
return u''
if self._did_para:
return u''
else:
self._did_para = True
return u'\n'
def number_list(self, on, type=None, start=None):
return self._list(on, 1)
def bullet_list(self, on):
if on:
self._nested_lists.append(0)
return [u'\n', u'\n\n'][not self._did_para]
else:
self._nested_lists.pop()
if not self._did_para:
self._did_para = 1
return u'\n'
return u''
return self._list(on, 0)
def listitem(self, on, **kw):
if on:
self._did_para = False
if self._nested_lists:
number = self._nested_lists[-1]
if number:
......@@ -122,14 +124,15 @@ class Formatter(FormatterBase):
self._nested_lists[-1] = number + 1
else:
bullet = '*'
self._did_para = 1
return ' %s%s ' % (' ' * (len(self._nested_lists)-1), bullet)
else:
self._did_para = 1
return u' * '
else:
self._did_para = 1
return u'\n'
if self._did_para:
return u''
else:
self._did_para = True
return u'\n'
def sup(self, on):
return u'^'
......@@ -185,11 +188,19 @@ class Formatter(FormatterBase):
def paragraph(self, on):
FormatterBase.paragraph(self, on)
if self._did_para:
on = 0
return [u'\n', u''][not on]
if on:
self._did_para = False
return u''
else:
if self._did_para or self._nested_lists:
self._did_para = True
return u'\n'
else:
self._did_para = True
return u'\n\n'
def linebreak(self, preformatted=1):
self._did_para = True
return u'\n'
def smiley(self, text):
......
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