Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion mdit_py_plugins/dollarmath/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ def dollarmath_plugin(
# would be good to allow "proper" math rendering,
# e.g. https://github.com/roniemartinez/latex2mathml

_renderer = lambda content, _: escapeHtml(content) if renderer is None else renderer
_renderer = (
(lambda content, _: escapeHtml(content)) if renderer is None else renderer
)

if label_renderer is None:
_label_renderer = (
Expand Down
5 changes: 5 additions & 0 deletions tests/test_dollarmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ 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(dollarmath_plugin, renderer=lambda x, y: x)
assert md.render("$x$").strip() == '<p><span class="math inline">x</span></p>'


@pytest.mark.parametrize(
"line,title,input,expected",
read_fixture_file(FIXTURE_PATH.joinpath("dollar_math.md")),
Expand Down