Show More
@@ -18,6 +18,7 b" REFLINK_PATTERN = re.compile(r'^\\d+$')" | |||
|
18 | 18 | MULTI_NEWLINES_PATTERN = re.compile(r'(\r?\n){2,}') |
|
19 | 19 | ONE_NEWLINE = '\n' |
|
20 | 20 | REGEX_URL = re.compile(r'https?\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?') |
|
21 | LINE_BREAK_HTML = '<div class="br"></div>' | |
|
21 | 22 | |
|
22 | 23 | |
|
23 | 24 | class TextFormatter(): |
@@ -50,8 +51,8 b' class AutolinkPattern():' | |||
|
50 | 51 | |
|
51 | 52 | |
|
52 | 53 | class QuotePattern(TextFormatter): |
|
53 | name = 'q' | |
|
54 |
preview_left = '<span class=" |
|
|
54 | name = '>q' | |
|
55 | preview_left = '<span class="quote">' | |
|
55 | 56 | preview_right = '</span>' |
|
56 | 57 | |
|
57 | 58 | format_left = '[quote]' |
@@ -161,7 +162,10 b' def render_quote(tag_name, value, option' | |||
|
161 | 162 | if source: |
|
162 | 163 | result = '<div class="multiquote"><div class="quote-header">%s</div><div class="quote-text">%s</div></div>' % (source, value) |
|
163 | 164 | else: |
|
164 | result = '<span class="quote">>%s</span>' % value | |
|
165 | # Insert a ">" at the start of every line | |
|
166 | result = '<span class="quote">>{}</span>'.format( | |
|
167 | value.replace(LINE_BREAK_HTML, | |
|
168 | '{}>'.format(LINE_BREAK_HTML))) | |
|
165 | 169 | |
|
166 | 170 | return result |
|
167 | 171 | |
@@ -197,7 +201,7 b' class Parser:' | |||
|
197 | 201 | def __init__(self): |
|
198 | 202 | # The newline hack is added because br's margin does not work in all |
|
199 | 203 | # browsers except firefox, when the div's does. |
|
200 |
self.parser = bbcode.Parser(newline= |
|
|
204 | self.parser = bbcode.Parser(newline=LINE_BREAK_HTML) | |
|
201 | 205 | |
|
202 | 206 | self.parser.add_formatter('post', render_reflink, strip=True) |
|
203 | 207 | self.parser.add_formatter('thread', render_multithread, strip=True) |
@@ -15,7 +15,8 b'' | |||
|
15 | 15 | <p>[thread]123[/thread] — {% trans 'Add post to this thread' %}</p> |
|
16 | 16 | <p>[s]<span class="strikethrough">{% trans 'Strikethrough text' %}</span>[/s]</p> |
|
17 | 17 | <p>[comment]<span class="comment">{% trans 'Comment' %}</span>[/comment]</p> |
|
18 |
<p>[quote]<span class=" |
|
|
18 | <p>[quote]<span class="quote">>{% trans 'Quote' %}</span>[/quote]</p> | |
|
19 | <p>[quote source=src]<div class="multiquote"><div class="quote-header">src</div><div class="quote-text">{% trans 'Quote' %}</div></div><br />[/quote]</p> | |
|
19 | 20 | <br/> |
|
20 | 21 | <p>{% trans 'You can try pasting the text and previewing the result here:' %} <a href="{% url 'preview' %}">{% trans 'Preview' %}</a></p> |
|
21 | 22 | {% endblock %} |
General Comments 0
You need to be logged in to leave comments.
Login now