From 45890ef3bfa3573102704a71d3dcb96c20a5041c Mon Sep 17 00:00:00 2001 From: redstoneleo Date: Thu, 19 Jan 2023 14:09:59 +0800 Subject: [PATCH] added the dollar signs as equation delimiters Mathjax recognizes TeX math equations by delimiters(https://docs.mathjax.org/en/latest/input/tex/delimiters.html), without delimiters it is nearly impossible for Mathjax to render the equations in webpage. --- mdit_py_plugins/dollarmath/index.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mdit_py_plugins/dollarmath/index.py b/mdit_py_plugins/dollarmath/index.py index 5fe0381..240f279 100644 --- a/mdit_py_plugins/dollarmath/index.py +++ b/mdit_py_plugins/dollarmath/index.py @@ -68,21 +68,21 @@ def dollarmath_plugin( def render_math_inline(self, tokens, idx, options, env) -> str: content = _renderer(str(tokens[idx].content).strip(), {"display_mode": False}) - return f'{content}' + return f'${content}$' def render_math_inline_double(self, tokens, idx, options, env) -> str: content = _renderer(str(tokens[idx].content).strip(), {"display_mode": True}) - return f'
{content}
' + return f'
$${content}$$
' def render_math_block(self, tokens, idx, options, env) -> str: content = _renderer(str(tokens[idx].content).strip(), {"display_mode": True}) - return f'
\n{content}\n
\n' + return f'
$$\n{content}\n$$
\n' def render_math_block_label(self, tokens, idx, options, env) -> str: content = _renderer(str(tokens[idx].content).strip(), {"display_mode": True}) _id = tokens[idx].info label = _label_renderer(tokens[idx].info) - return f'
\n{label}\n{content}\n
\n' + return f'
$$\n{label}\n{content}\n$$
\n' md.add_render_rule("math_inline", render_math_inline) md.add_render_rule("math_inline_double", render_math_inline_double)