Temporary change to wait for cached frontend

This commit is contained in:
cuom1999 2022-07-30 21:01:37 +07:00
parent 627cf37996
commit 427e391416
2 changed files with 9 additions and 7 deletions

View file

@ -20,14 +20,13 @@ logger = logging.getLogger("judge.html")
NOFOLLOW_WHITELIST = settings.NOFOLLOW_EXCLUDED
class CodeSafeInlineGrammar(mistune.InlineGrammar):
double_emphasis = re.compile(r"^\*{2}([\s\S]+?)()\*{2}(?!\*)") # **word**
emphasis = re.compile(r"^\*((?:\*\*|[^\*])+?)()\*(?!\*)") # *word*
class AwesomeInlineGrammar(
MathInlineGrammar, CodeSafeInlineGrammar
):
class AwesomeInlineGrammar(MathInlineGrammar, CodeSafeInlineGrammar):
pass
@ -126,9 +125,11 @@ class AwesomeRenderer(MathRenderer, mistune.Renderer):
def create_spoiler(value, style):
respoiler = re.compile(r"(^\|\|(.+)\s+([\s\S]+?)\s*\|\|)", re.MULTILINE)
matches = re.findall(respoiler, value)
html = "<details><summary style=\"color: brown\">" \
+ "<span class=\"spoiler-summary\">{summary}</span>" \
html = (
'<details><summary style="color: brown">'
+ '<span class="spoiler-summary">{summary}</span>'
+ "</summary>{detail}</details>"
)
for entire, summary, detail in matches:
detail = markdown(detail, style)
@ -136,6 +137,7 @@ def create_spoiler(value, style):
value = value.replace(entire, new_html)
return value
@registry.filter
def markdown(value, style, math_engine=None, lazy_load=False, hard_wrap=False):
styles = settings.MARKDOWN_STYLES.get(style, settings.MARKDOWN_DEFAULT_STYLE)

View file

@ -65,5 +65,5 @@ class MathRenderer(mistune.Renderer):
def math(self, 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)