diff --git a/mdit_py_plugins/amsmath/__init__.py b/mdit_py_plugins/amsmath/__init__.py index 197f1cc..5aa82bb 100644 --- a/mdit_py_plugins/amsmath/__init__.py +++ b/mdit_py_plugins/amsmath/__init__.py @@ -68,7 +68,7 @@ def amsmath_plugin(md: MarkdownIt, *, renderer: Optional[Callable[[str], str]] = {"alt": ["paragraph", "reference", "blockquote", "list", "footnote_def"]}, ) - _renderer = lambda content: escapeHtml(content) if renderer is None else renderer + _renderer = (lambda content: escapeHtml(content)) if renderer is None else renderer def render_amsmath_block(self, tokens, idx, options, env): content = _renderer(str(tokens[idx].content)) diff --git a/tests/test_amsmath.py b/tests/test_amsmath.py index 55b4987..fe48cf1 100644 --- a/tests/test_amsmath.py +++ b/tests/test_amsmath.py @@ -27,6 +27,23 @@ def test_plugin_parse(data_regression): data_regression.check([t.as_dict() for t in tokens]) +def test_custom_renderer(data_regression): + md = MarkdownIt().use(amsmath_plugin, renderer=lambda x: x + "!") + output = md.render("\\begin{equation}\na\n\\end{equation}") + assert ( + output.strip() + == dedent( + """\ +