Commits

Sergey Maranchuk committed 552ca71

corrected last commit

Comments (0)

Files changed (1)

bbmarkup/__init__.py

     value = matchobj.group(1)
     value = value.replace('[', '[')
     value = value.replace(']', ']')
-    value = value.replace('<br/>', '')
+    value = value.replace('<br />', '\n')
     return "<pre><code>%s</code></pre>" % value
 
 
     >>> 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>'
     >>> bbmarkup.bbcode("[code]print 123\nprint '<br/>'[/code]")
-    u'<pre><code>print 123<br />print &#39;&lt;br/&gt;&#39;</code></pre>'
+    u'<pre><code>print 123\nprint &#39;&lt;br/&gt;&#39;</code></pre>'
     """
 
     value = escape(value)
+    if linebr:
+        value = linebreaksbr(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:
-        value = linebreaksbr(value)
 
     return mark_safe(value)