Temporary change to wait for cached frontend
This commit is contained in:
parent
627cf37996
commit
427e391416
2 changed files with 9 additions and 7 deletions
|
@ -20,14 +20,13 @@ logger = logging.getLogger("judge.html")
|
||||||
|
|
||||||
NOFOLLOW_WHITELIST = settings.NOFOLLOW_EXCLUDED
|
NOFOLLOW_WHITELIST = settings.NOFOLLOW_EXCLUDED
|
||||||
|
|
||||||
|
|
||||||
class CodeSafeInlineGrammar(mistune.InlineGrammar):
|
class CodeSafeInlineGrammar(mistune.InlineGrammar):
|
||||||
double_emphasis = re.compile(r"^\*{2}([\s\S]+?)()\*{2}(?!\*)") # **word**
|
double_emphasis = re.compile(r"^\*{2}([\s\S]+?)()\*{2}(?!\*)") # **word**
|
||||||
emphasis = re.compile(r"^\*((?:\*\*|[^\*])+?)()\*(?!\*)") # *word*
|
emphasis = re.compile(r"^\*((?:\*\*|[^\*])+?)()\*(?!\*)") # *word*
|
||||||
|
|
||||||
|
|
||||||
class AwesomeInlineGrammar(
|
class AwesomeInlineGrammar(MathInlineGrammar, CodeSafeInlineGrammar):
|
||||||
MathInlineGrammar, CodeSafeInlineGrammar
|
|
||||||
):
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -126,9 +125,11 @@ class AwesomeRenderer(MathRenderer, mistune.Renderer):
|
||||||
def create_spoiler(value, style):
|
def create_spoiler(value, style):
|
||||||
respoiler = re.compile(r"(^\|\|(.+)\s+([\s\S]+?)\s*\|\|)", re.MULTILINE)
|
respoiler = re.compile(r"(^\|\|(.+)\s+([\s\S]+?)\s*\|\|)", re.MULTILINE)
|
||||||
matches = re.findall(respoiler, value)
|
matches = re.findall(respoiler, value)
|
||||||
html = "<details><summary style=\"color: brown\">" \
|
html = (
|
||||||
+ "<span class=\"spoiler-summary\">{summary}</span>" \
|
'<details><summary style="color: brown">'
|
||||||
+ "</summary>{detail}</details>"
|
+ '<span class="spoiler-summary">{summary}</span>'
|
||||||
|
+ "</summary>{detail}</details>"
|
||||||
|
)
|
||||||
|
|
||||||
for entire, summary, detail in matches:
|
for entire, summary, detail in matches:
|
||||||
detail = markdown(detail, style)
|
detail = markdown(detail, style)
|
||||||
|
@ -136,6 +137,7 @@ def create_spoiler(value, style):
|
||||||
value = value.replace(entire, new_html)
|
value = value.replace(entire, new_html)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
@registry.filter
|
@registry.filter
|
||||||
def markdown(value, style, math_engine=None, lazy_load=False, hard_wrap=False):
|
def markdown(value, style, math_engine=None, lazy_load=False, hard_wrap=False):
|
||||||
styles = settings.MARKDOWN_STYLES.get(style, settings.MARKDOWN_DEFAULT_STYLE)
|
styles = settings.MARKDOWN_STYLES.get(style, settings.MARKDOWN_DEFAULT_STYLE)
|
||||||
|
|
|
@ -65,5 +65,5 @@ class MathRenderer(mistune.Renderer):
|
||||||
|
|
||||||
def math(self, math):
|
def math(self, math):
|
||||||
if self.mathoid is None or not math:
|
if self.mathoid is None or not math:
|
||||||
return r"$%s$" % mistune.escape(str(math))
|
return r"~%s~" % mistune.escape(str(math))
|
||||||
return self.mathoid.inline_math(math)
|
return self.mathoid.inline_math(math)
|
||||||
|
|
Loading…
Reference in a new issue