Redesign UI
This commit is contained in:
parent
516646ae85
commit
881c165ef5
18 changed files with 569 additions and 286 deletions
27
judge/jinja2/markdown/spoiler.py
Normal file
27
judge/jinja2/markdown/spoiler.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
import re
|
||||
import mistune
|
||||
|
||||
|
||||
class SpoilerInlineGrammar(mistune.InlineGrammar):
|
||||
spoiler = re.compile(r'^\|\|(.+?)\s+([\s\S]+?)\s*\|\|')
|
||||
|
||||
|
||||
class SpoilerInlineLexer(mistune.InlineLexer):
|
||||
grammar_class = SpoilerInlineGrammar
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.default_rules.insert(0, 'spoiler')
|
||||
super(SpoilerInlineLexer, self).__init__(*args, **kwargs)
|
||||
|
||||
def output_spoiler(self, m):
|
||||
return self.renderer.spoiler(m.group(1), m.group(2))
|
||||
|
||||
|
||||
class SpoilerRenderer(mistune.Renderer):
|
||||
def spoiler(self, summary, text):
|
||||
return '''<details>
|
||||
<summary style="color: brown">
|
||||
<span class="spoiler-summary">%s</span>
|
||||
</summary>
|
||||
<div class="spoiler-text">%s</div>
|
||||
</details>''' % (summary, text)
|
Loading…
Add table
Add a link
Reference in a new issue