Sergey Maranchuk committed 13fd2a7

added basic test

Comments (0)

Files changed (3)


 import re
 from django.conf import settings
-from django.utils.html import escape, linebreaks
+from django.utils.html import escape
+from django.template.defaultfilters import linebreaksbr
-__all__ = ['BBCODE_RULES', 'bbcode']
+__all__ = ('BBCODE_RULES', 'bbcode')
 BBCODE_RULES = [ (r'\[url\](.+?)\[/url\]', r'<a href="\1">\1</a>'),
         (r'\[url=(.+?)\](.+?)\[/url\]', r'<a href="\1">\2</a>'),
     >>> data = '[code]print "Lorem [b]imsum[b]"[/code]'
     >>> bbcode(data)
     u'<pre><code>print &quot;Lorem &#91;b&#93;imsum&#91;b&#93;&quot;</code></pre>'
-    >>> bbcode('[i]Lorem[/i] \n [s]imsum[/s]')
+    >>> bbcode('[i]Lorem[/i] \\n [s]imsum[/s]')
     u'<em>Lorem</em> <br /> <strike>imsum</strike>'
+    >>>
     value = escape(value)
     for bbset in BBCODE_RULES_COMPILED:
         value = bbset[0].sub(bbset[1], value)
     if linebr:
-        value = value.replace('\n', '<br />')
+        value = linebreaksbr(value)
     return value


+#needed for tests


+from bbmarkup import bbcode
+__test__ = {"bbcode": bbcode.__doc__}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.