From 9cc8758f0412707bc0fa76f8711f428c3d101403 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Sun, 19 Feb 2023 12:49:01 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20FIX:=20Regression=20in=20dol?= =?UTF-8?q?larmath?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mdit_py_plugins/dollarmath/index.py | 4 +++- tests/test_dollarmath.py | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/mdit_py_plugins/dollarmath/index.py b/mdit_py_plugins/dollarmath/index.py index 9c531da..2663617 100644 --- a/mdit_py_plugins/dollarmath/index.py +++ b/mdit_py_plugins/dollarmath/index.py @@ -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 = ( diff --git a/tests/test_dollarmath.py b/tests/test_dollarmath.py index d10d724..a2e76bd 100644 --- a/tests/test_dollarmath.py +++ b/tests/test_dollarmath.py @@ -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$") == '

x

' + + @pytest.mark.parametrize( "line,title,input,expected", read_fixture_file(FIXTURE_PATH.joinpath("dollar_math.md")), From 3bd49c96e0e122387b22035819e984c6a20d2198 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Sun, 19 Feb 2023 12:51:26 +0100 Subject: [PATCH 2/2] Update test_dollarmath.py --- tests/test_dollarmath.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_dollarmath.py b/tests/test_dollarmath.py index a2e76bd..62f52ef 100644 --- a/tests/test_dollarmath.py +++ b/tests/test_dollarmath.py @@ -83,7 +83,7 @@ def test_plugin_parse(data_regression): def test_custom_renderer(data_regression): md = MarkdownIt().use(dollarmath_plugin, renderer=lambda x, y: x) - assert md.render("$x$") == '

x

' + assert md.render("$x$").strip() == '

x

' @pytest.mark.parametrize(