Ticket #78 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

bbmarkup failure

Reported by: lemming110 Owned by: somebody
Priority: minor Milestone: 0.1
Component: Uncategorized Version: devel
Keywords: Cc:
Blocked By: Blocking:

Description

djangobb_forum.markups.bbmarkup.bbcode does not convert '[*]' to '<li>'. Below is the diff to fix this.

diff -r d8c4ceeaebe0 djangobb/djangobb_forum/markups/bbmarkup.py
--- a/djangobb/djangobb_forum/markups/bbmarkup.py	Tue Jan 12 08:38:44 2010 +0200
+++ b/djangobb/djangobb_forum/markups/bbmarkup.py	Thu Feb 04 12:51:43 2010 -0500
@@ -29,7 +29,7 @@ BBCODE_RULES = [ (r'\[url\](.+?)\[/url\]
         (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'\[\\*\]\s?(.*?)\n', r'<li>\1</li>'),
         (r'\[br\]', r'<br />') ]
 
 BBCODE_RULES += getattr(settings, 'BBMARKUP_EXTRA_RULES', [])

Change History

comment:1 Changed 2 years ago by lemming110

I take it back the patch above does not work. It work in a python shell but not djangobb. There appears to be some strange interaction with the '\n' character at the end of the line.

comment:2 Changed 2 years ago by lemming110

Output from a python shell

In [63]: bbmarkup.bbcode("[*] lll\n")
Out[63]: u'[*] lll<br />'

In [64]: bbmarkup.bbcode("[*] lll\n", linebr=False)
Out[64]: u'<li>lll</li>'

It turns out that the \n is removed before the re substitution by the linesbreaksbr routine. The follow change applies the [*] rule before replacing the newlines.

diff -r d8c4ceeaebe0 djangobb/djangobb_forum/markups/bbmarkup.py
--- a/djangobb/djangobb_forum/markups/bbmarkup.py	Tue Jan 12 08:38:44 2010 +0200
+++ b/djangobb/djangobb_forum/markups/bbmarkup.py	Thu Feb 04 14:59:10 2010 -0500
@@ -29,8 +29,9 @@ BBCODE_RULES = [ (r'\[url\](.+?)\[/url\]
         (r'\[small\](.+?)\[/small\]', r'<small>\1</small>'),
         (r'\[list\](.+?)\[/list\]', r'<ul>\1</ul>'),
         (r'\[list\=(.+?)\](.+?)\[/list\]', r'<ol start="\1">\2</ol>'),
+        (r'\[br\]', r'<br />'),
         (r'\[\*\]\s?(.*?)\n', r'<li>\1</li>'),
-        (r'\[br\]', r'<br />') ]
+        ]
 
 BBCODE_RULES += getattr(settings, 'BBMARKUP_EXTRA_RULES', [])
 
@@ -71,10 +72,11 @@ def bbcode(value, linebr=True, code_pars
     """
 
     value = escape(value)
+    value =  BBCODE_RULES_COMPILED[-1][0].sub(BBCODE_RULES_COMPILED[-1][1], 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:
+    for bbset in BBCODE_RULES_COMPILED[:-1]:
         value = bbset[0].sub(bbset[1], value)
 
     return mark_safe(value)

comment:3 Changed 2 years ago by slav0nic

  • Status changed from new to closed
  • Resolution set to fixed

test it with [237]
not elegant, but work, i'm don't have time for refactoring bbmarkup =\

Note: See TracTickets for help on using tickets.