From b4286ab450314917e80f35c539d9fcdac042c2e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Wed, 20 Jun 2012 00:23:36 +0200 Subject: [PATCH] implement bullet list --- syntaxreference.txt | 14 ++++++++++++++ text_dokuwiki.py | 17 +++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/syntaxreference.txt b/syntaxreference.txt index ffe329c..5b51252 100644 --- a/syntaxreference.txt +++ b/syntaxreference.txt @@ -32,3 +32,17 @@ fourth line sixth line! }}} + += Bullet list = +{{{ + * item 1 + + * item 2, with gap + * item 3 + * item 3.1 +}}} + * item 1 + + * item 2, with gap + * item 3 + * item 3.1 diff --git a/text_dokuwiki.py b/text_dokuwiki.py index 1de78c9..525e1c7 100644 --- a/text_dokuwiki.py +++ b/text_dokuwiki.py @@ -26,6 +26,8 @@ class Formatter(FormatterBase): self.in_pre = 0 self._text = None # XXX does not work with links in headings!!!!! + self.bullet_depth = 0 + def _escape(self, text, extra_mapping={"'": "'", '"': """}): return saxutils.escape(text, extra_mapping) @@ -107,13 +109,16 @@ class Formatter(FormatterBase): return result + ['
    ', '
\n'][not on] def bullet_list(self, on, **kw): - result = '' - if self.in_p: - result = self.paragraph(0) - return result + ['\n'][not on] + # fill: ' * ' + if on: + self.bullet_depth += 1 + else: + self.bullet_depth -= 1 + + return ['\n', ''][not on] def listitem(self, on, **kw): - return ['
  • ', '
  • \n'][not on] + return [(' ' * self.bullet_depth * 2) + '* ', '\n'][not on] def code(self, on, **kw): """ `typewriter` or {{{typerwriter}}, for code blocks i hope codeblock works """ @@ -133,7 +138,7 @@ class Formatter(FormatterBase): result = '' if self.in_p: result = self.paragraph(0) - return result + ['', ''][not on] + return result + ['', '\n'][not on] def paragraph(self, on, **kw): FormatterBase.paragraph(self, on)