Show More
@@ -10,6 +10,8 import boards | |||
|
10 | 10 | |
|
11 | 11 | |
|
12 | 12 | REFLINK_PATTERN = re.compile(r'\d+') |
|
13 | MULTI_NEWLINES_PATTERN = re.compile(r'(\r?\n){2,}') | |
|
14 | ONE_NEWLINE = '\n' | |
|
13 | 15 | |
|
14 | 16 | |
|
15 | 17 | class TextFormatter(): |
@@ -126,6 +128,14 def render_reflink(tag_name, value, opti | |||
|
126 | 128 | return u'>>%s' % value |
|
127 | 129 | |
|
128 | 130 | |
|
131 | def preparse_text(text): | |
|
132 | """ | |
|
133 | Performs manual parsing before the bbcode parser is used. | |
|
134 | """ | |
|
135 | ||
|
136 | return MULTI_NEWLINES_PATTERN.sub(ONE_NEWLINE, text) | |
|
137 | ||
|
138 | ||
|
129 | 139 | def bbcode_extended(markup): |
|
130 | 140 | parser = bbcode.Parser() |
|
131 | 141 | parser.add_formatter('post', render_reflink, strip=True) |
@@ -139,7 +149,9 def bbcode_extended(markup): | |||
|
139 | 149 | u'<span class="strikethrough">%(value)s</span>') |
|
140 | 150 | parser.add_simple_formatter('code', |
|
141 | 151 | u'<pre><code>%(value)s</pre></code>') |
|
142 | return parser.format(markup) | |
|
152 | ||
|
153 | text = preparse_text(markup) | |
|
154 | return parser.format(text) | |
|
143 | 155 | |
|
144 | 156 | formatters = [ |
|
145 | 157 | QuotePattern, |
General Comments 0
You need to be logged in to leave comments.
Login now