diff --git a/judge/jinja2/markdown/__init__.py b/judge/jinja2/markdown/__init__.py index b91679c..3387ddf 100644 --- a/judge/jinja2/markdown/__init__.py +++ b/judge/jinja2/markdown/__init__.py @@ -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 = "
" \ - + "{summary}" \ - + "{detail}
" + html = ( + '
' + + '{summary}' + + "{detail}
" + ) 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) diff --git a/judge/jinja2/markdown/math.py b/judge/jinja2/markdown/math.py index dcde0d1..96e2878 100644 --- a/judge/jinja2/markdown/math.py +++ b/judge/jinja2/markdown/math.py @@ -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)