##// END OF EJS Templates
#12 Added spoilers and comments.
neko259 -
r56:d4201a19 default
parent child Browse files
Show More
@@ -34,23 +34,43 class ReflinkPattern(Pattern):
34 return ref_element
34 return ref_element
35
35
36
36
37 class SpoilerPattern(Pattern):
38 def handleMatch(self, m):
39 quote_element = etree.Element('span')
40 quote_element.set('class', 'spoiler')
41 quote_element.text = m.group(2)
42
43 return quote_element
44
45
46 class CommentPattern(Pattern):
47 def handleMatch(self, m):
48 quote_element = etree.Element('span')
49 quote_element.set('class', 'comment')
50 quote_element.text = '//' + m.group(3)
51
52 return quote_element
53
54
37 class NeboardMarkdown(markdown.Extension):
55 class NeboardMarkdown(markdown.Extension):
38 AUTOLINK_PATTERN = r'(http://\S+)'
56 AUTOLINK_PATTERN = r'(http://\S+)'
39 QUOTE_PATTERN = r'(>){1}(.+)'
57 QUOTE_PATTERN = r'(>){1}(.+)'
40 REFLINK_PATTERN = r'((>){2}(\d+))'
58 REFLINK_PATTERN = r'((>){2}(\d+))'
59 SPOILER_PATTERN = r'%%(.+)%%'
60 COMMENT_PATTERN = r'(//(.+))'
41
61
42 def extendMarkdown(self, md, md_globals):
62 def extendMarkdown(self, md, md_globals):
43 autolink = AutolinkPattern(self.AUTOLINK_PATTERN, md)
63 autolink = AutolinkPattern(self.AUTOLINK_PATTERN, md)
44 quote = QuotePattern(self.QUOTE_PATTERN, md)
64 quote = QuotePattern(self.QUOTE_PATTERN, md)
45 reflink = ReflinkPattern(self.REFLINK_PATTERN, md)
65 reflink = ReflinkPattern(self.REFLINK_PATTERN, md)
66 spoiler = SpoilerPattern(self.SPOILER_PATTERN, md)
67 comment = CommentPattern(self.COMMENT_PATTERN, md)
46
68
47 md.inlinePatterns[u'autolink_ext'] = autolink
69 md.inlinePatterns[u'autolink_ext'] = autolink
48 md.inlinePatterns.add(u'reflink', reflink, '<entity')
70 md.inlinePatterns.add(u'reflink', reflink, '<entity')
49 md.inlinePatterns.add(u'quote', quote, '<entity')
71 md.inlinePatterns.add(u'quote', quote, '<entity')
50 # md.inlinePatterns[u'reflink'] = reflink
72 md.inlinePatterns[u'spoiler'] = spoiler
51 # md.inlinePatterns[u'quote'] = quote
73 md.inlinePatterns[u'comment'] = comment
52
53 # del(md.inlinePatterns[u'entity'])
54
74
55
75
56 def makeExtension(configs=None):
76 def makeExtension(configs=None):
@@ -179,4 +179,17 blockquote {
179 color: greenyellow;
179 color: greenyellow;
180 padding-left: 5px;
180 padding-left: 5px;
181 border-left: solid 2px greenyellow;
181 border-left: solid 2px greenyellow;
182 }
183
184 .spoiler {
185 background: white;
186 color: white;
187 }
188
189 .spoiler:hover {
190 background: black;
191 }
192
193 .comment {
194 color: darkseagreen;
182 } No newline at end of file
195 }
@@ -191,7 +191,20 a {
191 }
191 }
192
192
193 .quote {
193 .quote {
194 color: blue;
194 color: #182F6F;
195 padding-left: 5px;
195 padding-left: 5px;
196 border-left: solid 2px blue;
196 border-left: solid 2px blue;
197 }
198
199 .spoiler {
200 background: black;
201 color: black;
202 }
203
204 .spoiler:hover {
205 background: #ffffff;
206 }
207
208 .comment {
209 color: darkseagreen;
197 } No newline at end of file
210 }
General Comments 0
You need to be logged in to leave comments. Login now