##// END OF EJS Templates
Changed parser to show quotes and reflinks as they are posted, not with borders and '#' character.
neko259 -
r90:8f1d0214 default
parent child Browse files
Show More
@@ -19,7 +19,7 b' class QuotePattern(Pattern):'
19 def handleMatch(self, m):
19 def handleMatch(self, m):
20 quote_element = etree.Element('span')
20 quote_element = etree.Element('span')
21 quote_element.set('class', 'quote')
21 quote_element.set('class', 'quote')
22 quote_element.text = m.group(3)
22 quote_element.text = m.group(2)
23
23
24 return quote_element
24 return quote_element
25
25
@@ -29,7 +29,7 b' class ReflinkPattern(Pattern):'
29 ref_element = etree.Element('a')
29 ref_element = etree.Element('a')
30 post_id = m.group(4)
30 post_id = m.group(4)
31 ref_element.set('href', '#' + str(post_id))
31 ref_element.set('href', '#' + str(post_id))
32 ref_element.text = '#' + post_id
32 ref_element.text = m.group(2)
33
33
34 return ref_element
34 return ref_element
35
35
@@ -54,8 +54,8 b' class CommentPattern(Pattern):'
54
54
55 class NeboardMarkdown(markdown.Extension):
55 class NeboardMarkdown(markdown.Extension):
56 AUTOLINK_PATTERN = r'(https?://\S+)'
56 AUTOLINK_PATTERN = r'(https?://\S+)'
57 QUOTE_PATTERN = r'^(>){1}(.+)'
57 QUOTE_PATTERN = r'^(?<!>)(>[^>]+)$'
58 REFLINK_PATTERN = r'((&gt;){2}(\d+))'
58 REFLINK_PATTERN = r'((>>)(\d+))'
59 SPOILER_PATTERN = r'%%(.+)%%'
59 SPOILER_PATTERN = r'%%(.+)%%'
60 COMMENT_PATTERN = r'^(//(.+))'
60 COMMENT_PATTERN = r'^(//(.+))'
61
61
@@ -67,10 +67,12 b' class NeboardMarkdown(markdown.Extension'
67 comment = CommentPattern(self.COMMENT_PATTERN, md)
67 comment = CommentPattern(self.COMMENT_PATTERN, md)
68
68
69 md.inlinePatterns[u'autolink_ext'] = autolink
69 md.inlinePatterns[u'autolink_ext'] = autolink
70 md.inlinePatterns.add(u'reflink', reflink, '<entity')
71 md.inlinePatterns.add(u'quote', quote, '<entity')
72 md.inlinePatterns[u'spoiler'] = spoiler
70 md.inlinePatterns[u'spoiler'] = spoiler
73 md.inlinePatterns[u'comment'] = comment
71 md.inlinePatterns[u'comment'] = comment
72 md.inlinePatterns[u'reflink'] = reflink
73 md.inlinePatterns[u'quote'] = quote
74
75 del md.parser.blockprocessors['quote']
74
76
75
77
76 def makeExtension(configs=None):
78 def makeExtension(configs=None):
@@ -80,4 +82,4 b' neboard_extension = makeExtension()'
80
82
81
83
82 def markdown_extended(markup):
84 def markdown_extended(markup):
83 return markdown.markdown(markup, [neboard_extension])
85 return markdown.markdown(markup, [neboard_extension], safe_mode=True)
@@ -211,7 +211,7 b' class Post(models.Model):'
211 title = models.CharField(max_length=TITLE_MAX_LENGTH)
211 title = models.CharField(max_length=TITLE_MAX_LENGTH)
212 pub_time = models.DateTimeField()
212 pub_time = models.DateTimeField()
213 text = MarkupField(default_markup_type=DEFAULT_MARKUP_TYPE,
213 text = MarkupField(default_markup_type=DEFAULT_MARKUP_TYPE,
214 escape_html=True)
214 escape_html=False)
215 image = thumbs.ImageWithThumbsField(upload_to=_update_image_filename,
215 image = thumbs.ImageWithThumbsField(upload_to=_update_image_filename,
216 blank=True, sizes=(IMAGE_THUMB_SIZE,))
216 blank=True, sizes=(IMAGE_THUMB_SIZE,))
217 poster_ip = models.IPAddressField()
217 poster_ip = models.IPAddressField()
@@ -189,9 +189,8 b' blockquote {'
189 }
189 }
190
190
191 .quote {
191 .quote {
192 color: greenyellow;
192 color: #92cf38;
193 padding-left: 5px;
193 padding-left: 5px;
194 border-left: solid 2px greenyellow;
195 }
194 }
196
195
197 .spoiler {
196 .spoiler {
@@ -204,7 +203,7 b' blockquote {'
204 }
203 }
205
204
206 .comment {
205 .comment {
207 color: darkseagreen;
206 color: #5dbcb7;
208 }
207 }
209
208
210 a:hover {
209 a:hover {
General Comments 0
You need to be logged in to leave comments. Login now