1. offline
  2. django-bbmarkup

Commits

Sergey Maranchuk  committed c672134

added [list] tag

  • Participants
  • Parent commits 13fd2a7
  • Branches default

Comments (0)

Files changed (1)

File bbmarkup/__init__.py

View file
         (r'\[center\](.+?)\[/center\]', r'<div style="text-align: center;">\1</div>'),
         (r'\[big\](.+?)\[/big\]', r'<big>\1</big>'),
         (r'\[small\](.+?)\[/small\]', r'<small>\1</small>'),
+        (r'\[list\](.+?)\[/list\]', r'<ul>\1</ul>'),
+        (r'\[list\=(.+?)\](.+?)\[/list\]', r'<ol start="\1">\2</ol>'),
+        (r'\[\*\]\s?(.*?)\n', r'<li>\1</li>'),
         (r'\[br\]', r'<br />') ]
 
 BBCODE_RULES += getattr(settings, 'BBMARKUP_EXTRA_RULES', [])
     value = matchobj.group(1)
     value = value.replace('[', '&#91;')
     value = value.replace(']', '&#93;')
+    
     return "<pre><code>%s</code></pre>" % value
 
 
     u'<pre><code>print &quot;Lorem &#91;b&#93;imsum&#91;b&#93;&quot;</code></pre>'
     >>> bbcode('[i]Lorem[/i] \\n [s]imsum[/s]')
     u'<em>Lorem</em> <br /> <strike>imsum</strike>'
+    >>> bbmarkup.bbcode('[list] [*] 1\n [*]2\n [*] 3\n[/list]')
+    u'<ul> <li>1</li> <li>2</li> <li>3</li></ul>'
+    >>> bbmarkup.bbcode('[list=2] [*] a\n [*]b\n [*] c\n[/list]')
+    u'<ol start="2"> <li>a</li> <li>b</li> <li>c</li></ol>'
     >>>
     """
 
     value = escape(value)
-    value = re.sub(r'\[code\](.+?)\[/code\]', code_parser, value)
+    value = re.sub(re.compile(r'\[code\](.+?)\[/code\]', re.DOTALL), code_parser, value)
     for bbset in BBCODE_RULES_COMPILED:
         value = bbset[0].sub(bbset[1], value)
     if linebr: