Show More
@@ -119,6 +119,15 class CodePattern(TextFormatter): | |||
|
119 | 119 | format_right = '[/code]' |
|
120 | 120 | |
|
121 | 121 | |
|
122 | class HintPattern(TextFormatter): | |
|
123 | name = 'hint' | |
|
124 | preview_left = '<span class="hint">' | |
|
125 | preview_right = '</span>' | |
|
126 | ||
|
127 | format_left = '[hint]' | |
|
128 | format_right = '[/hint]' | |
|
129 | ||
|
130 | ||
|
122 | 131 | def render_reflink(tag_name, value, options, parent, context): |
|
123 | 132 | result = '>>%s' % value |
|
124 | 133 | |
@@ -165,6 +174,15 def render_quote(tag_name, value, option | |||
|
165 | 174 | return result |
|
166 | 175 | |
|
167 | 176 | |
|
177 | def render_hint(tag_name, value, options, parent, context): | |
|
178 | if 'hint' in options: | |
|
179 | hint = options['hint'] | |
|
180 | result = '<span class="hint" title="{}">{}</span>'.format(hint, value) | |
|
181 | else: | |
|
182 | result = value | |
|
183 | return result | |
|
184 | ||
|
185 | ||
|
168 | 186 | def render_notification(tag_name, value, options, parent, content): |
|
169 | 187 | username = value.lower() |
|
170 | 188 | |
@@ -199,6 +217,7 formatters = [ | |||
|
199 | 217 | CommentPattern, |
|
200 | 218 | StrikeThroughPattern, |
|
201 | 219 | CodePattern, |
|
220 | HintPattern, | |
|
202 | 221 | ] |
|
203 | 222 | |
|
204 | 223 | |
@@ -218,6 +237,7 class Parser: | |||
|
218 | 237 | |
|
219 | 238 | self.parser.add_formatter('post', render_reflink, strip=True) |
|
220 | 239 | self.parser.add_formatter('quote', render_quote, strip=True) |
|
240 | self.parser.add_formatter('hint', render_hint, strip=True) | |
|
221 | 241 | self.parser.add_formatter('user', render_notification, strip=True) |
|
222 | 242 | self.parser.add_formatter('tag', render_tag, strip=True) |
|
223 | 243 | self.parser.add_formatter('spoiler', render_spoiler, strip=True) |
General Comments 0
You need to be logged in to leave comments.
Login now