Skip to content

Commit bb67d10

Browse files
authored
🐛 Fix regression in amsmath (#70)
1 parent de7f783 commit bb67d10

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

mdit_py_plugins/amsmath/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def amsmath_plugin(md: MarkdownIt, *, renderer: Optional[Callable[[str], str]] =
6868
{"alt": ["paragraph", "reference", "blockquote", "list", "footnote_def"]},
6969
)
7070

71-
_renderer = lambda content: escapeHtml(content) if renderer is None else renderer
71+
_renderer = (lambda content: escapeHtml(content)) if renderer is None else renderer
7272

7373
def render_amsmath_block(self, tokens, idx, options, env):
7474
content = _renderer(str(tokens[idx].content))

tests/test_amsmath.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,23 @@ def test_plugin_parse(data_regression):
2727
data_regression.check([t.as_dict() for t in tokens])
2828

2929

30+
def test_custom_renderer(data_regression):
31+
md = MarkdownIt().use(amsmath_plugin, renderer=lambda x: x + "!")
32+
output = md.render("\\begin{equation}\na\n\\end{equation}")
33+
assert (
34+
output.strip()
35+
== dedent(
36+
"""\
37+
<div class="math amsmath">
38+
\\begin{equation}
39+
a
40+
\\end{equation}!
41+
</div>
42+
"""
43+
).strip()
44+
)
45+
46+
3047
@pytest.mark.parametrize(
3148
"line,title,input,expected",
3249
read_fixture_file(FIXTURE_PATH.joinpath("fixtures", "amsmath.md")),

0 commit comments

Comments
 (0)