Repository: executablebooks/mdit-py-plugins

Issue:
Update dollarmath to be inline with JS version
I've just created `markdown-it-dollarmath`, and in particular here: https://github.com/executablebooks/markdown-it-dollarmath/commit/e3eb24458137d3efb1c68cfc249fb2e12ed64825, I added the extra token `math_inline_double` and renamed `math_block_eqno` to `math_block_label`.
Also, there is the `labelNormalizer` option and the render hook (and similarly with amsmath).

Note, this will also require a change in myst-parser, so should be followed by a minor (breaking) version release

Should link to the JS plugin demonstration pages as well.

Discussion:
codecov[bot]: # [Codecov](https://codecov.io/gh/executablebooks/mdit-py-plugins/pull/29?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks) Report
> Merging [#29](https://codecov.io/gh/executablebooks/mdit-py-plugins/pull/29?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks) (0f89d23) into [master](https://codecov.io/gh/executablebooks/mdit-py-plugins/commit/70a756d4c42476ec29cb4e06a2a81f83d8b5d435?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks) (70a756d) will **decrease** coverage by `0.08%`.
> The diff coverage is `93.93%`.

[![Impacted file tree graph](https://codecov.io/gh/executablebooks/mdit-py-plugins/pull/29/graphs/tree.svg?width=650&height=150&src=pr&token=x2hkFrk2rb&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks)](https://codecov.io/gh/executablebooks/mdit-py-plugins/pull/29?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks)

```diff
@@            Coverage Diff             @@
##           master      #29      +/-   ##
==========================================
- Coverage   93.41%   93.32%   -0.09%     
==========================================
  Files          24       24              
  Lines        1214     1229      +15     
==========================================
+ Hits         1134     1147      +13     
- Misses         80       82       +2     
```

| Flag | Coverage Δ | |
|---|---|---|
| pytests | `93.32% <93.93%> (-0.09%)` | :arrow_down: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/executablebooks/mdit-py-plugins/pull/29?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks) | Coverage Δ | |
|---|---|---|
| [mdit\_py\_plugins/dollarmath/index.py](https://codecov.io/gh/executablebooks/mdit-py-plugins/pull/29/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks#diff-bWRpdF9weV9wbHVnaW5zL2RvbGxhcm1hdGgvaW5kZXgucHk=) | `90.00% <93.93%> (-0.33%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/executablebooks/mdit-py-plugins/pull/29?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/executablebooks/mdit-py-plugins/pull/29?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks). Last update [70a756d...0f89d23](https://codecov.io/gh/executablebooks/mdit-py-plugins/pull/29?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks).


Patch:
diff --git a/mdit_py_plugins/dollarmath/index.py b/mdit_py_plugins/dollarmath/index.py
index 240bbba..5fe0381 100644
--- a/mdit_py_plugins/dollarmath/index.py
+++ b/mdit_py_plugins/dollarmath/index.py
@@ -1,18 +1,22 @@
 import re
-from typing import Callable
+from typing import Any, Callable, Dict, Optional
 
 from markdown_it import MarkdownIt
-from markdown_it.common.utils import isWhiteSpace
+from markdown_it.common.utils import escapeHtml, isWhiteSpace
 from markdown_it.rules_block import StateBlock
 from markdown_it.rules_inline import StateInline
 
 
 def dollarmath_plugin(
     md: MarkdownIt,
+    *,
     allow_labels: bool = True,
     allow_space: bool = True,
     allow_digits: bool = True,
     double_inline: bool = False,
+    label_normalizer: Optional[Callable[[str], str]] = None,
+    renderer: Optional[Callable[[str, Dict[str, Any]], str]] = None,
+    label_renderer: Optional[Callable[[str], str]] = None,
 ) -> None:
     """Plugin for parsing dollar enclosed math,
     e.g. inline: ``$a=1$``, block: ``$$b=2$$``
@@ -27,39 +31,64 @@ def dollarmath_plugin(
         before/after the opening/closing ``$``, e.g. ``1$`` or ``$2``.
         This is useful when also using currency.
     :param double_inline: Search for double-dollar math within inline contexts
+    :param label_normalizer: Function to normalize the label,
+        by default replaces whitespace with `-`
+    :param renderer: Function to render content: `(str, {"display_mode": bool}) -> str`,
+        by default escapes HTML
+    :param label_renderer: Function to render labels, by default creates anchor
 
     """
+    if label_normalizer is None:
+        label_normalizer = lambda label: re.sub(r"\s+", "-", label)
 
     md.inline.ruler.before(
         "escape",
         "math_inline",
         math_inline_dollar(allow_space, allow_digits, double_inline),
     )
-    md.add_render_rule("math_inline", render_math_inline)
+    md.block.ruler.before(
+        "fence", "math_block", math_block_dollar(allow_labels, label_normalizer)
+    )
 
-    md.block.ruler.before("fence", "math_block", math_block_dollar(allow_labels))
-    md.add_render_rule("math_block", render_math_block)
-    md.add_render_rule("math_block_eqno", render_math_block_eqno)
+    # TODO the current render rules are really just for testing
+    # would be good to allow "proper" math rendering,
+    # e.g. https://github.com/roniemartinez/latex2mathml
 
+    if renderer is None:
+        _renderer = lambda content, _: escapeHtml(content)
+    else:
+        _renderer = renderer
 
-# TODO the current render rules are really just for testing
-# would be good to allow "proper" math rendering, e.g. https://github.com/roniemartinez/latex2mathml
+    if label_renderer is None:
+        _label_renderer = (
+            lambda label: f'<a href="#{label}" class="mathlabel" title="Permalink to this equation">¶</a>'  # noqa: E501
+        )
+    else:
+        _label_renderer = label_renderer
 
+    def render_math_inline(self, tokens, idx, options, env) -> str:
+        content = _renderer(str(tokens[idx].content).strip(), {"display_mode": False})
+        return f'<span class="math inline">{content}</span>'
 
-def render_math_inline(self, tokens, idx, options, env) -> str:
-    return "<{0}>{1}</{0}>".format(
-        "eqn" if tokens[idx].markup == "$$" else "eq", tokens[idx].content
-    )
+    def render_math_inline_double(self, tokens, idx, options, env) -> str:
+        content = _renderer(str(tokens[idx].content).strip(), {"display_mode": True})
+        return f'<div class="math inline">{content}</div>'
 
+    def render_math_block(self, tokens, idx, options, env) -> str:
+        content = _renderer(str(tokens[idx].content).strip(), {"display_mode": True})
+        return f'<div class="math block">\n{content}\n</div>\n'
 
-def render_math_block(self, tokens, idx, options, env) -> str:
-    return "<section>\n<eqn>{0}</eqn>\n</section>\n".format(tokens[idx].content)
+    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'<div id="{_id}" class="math block">\n{label}\n{content}\n</div>\n'
 
+    md.add_render_rule("math_inline", render_math_inline)
+    md.add_render_rule("math_inline_double", render_math_inline_double)
 
-def render_math_block_eqno(self, tokens, idx, options, env) -> str:
-    return '<section>\n<eqn>{0}</eqn>\n<span class="eqno">({1})</span>\n</section>\n'.format(
-        tokens[idx].content, tokens[idx].info
-    )
+    md.add_render_rule("math_block", render_math_block)
+    md.add_render_rule("math_block_label", render_math_block_label)
 
 
 def is_escaped(state: StateInline, back_pos: int, mod: int = 0) -> bool:
@@ -146,7 +175,7 @@ def math_inline_dollar(
         # find closing $
         pos = state.pos + 1 + (1 if is_double else 0)
         found_closing = False
-        while True:
+        while not found_closing:
             try:
                 end = state.srcCharCode.index(0x24, pos)
             except ValueError:
@@ -167,7 +196,6 @@ def math_inline_dollar(
                 end += 1
 
             found_closing = True
-            break
 
         if not found_closing:
             return False
@@ -199,7 +227,9 @@ def math_inline_dollar(
             return False
 
         if not silent:
-            token = state.push("math_inline", "math", 0)
+            token = state.push(
+                "math_inline_double" if is_double else "math_inline", "math", 0
+            )
             token.content = text
             token.markup = "$$" if is_double else "$"
 
@@ -216,6 +246,7 @@ DOLLAR_EQNO_REV = re.compile(r"^\s*\)([^)$\r\n]+?)\(\s*\${2}")
 
 def math_block_dollar(
     allow_labels: bool = True,
+    label_normalizer: Optional[Callable[[str], str]] = None,
 ) -> Callable[[StateBlock, int, int, bool], bool]:
     """Generate block dollar rule."""
 
@@ -249,7 +280,7 @@ def math_block_dollar(
         # search for end of block on same line
         lineText = state.src[startPos:end]
         if len(lineText.strip()) > 3:
-            lineText = state.src[startPos:end]
+
             if lineText.strip().endswith("$$"):
                 haveEndMarker = True
                 end = end - 2 - (len(lineText) - len(lineText.strip()))
@@ -295,13 +326,13 @@ def math_block_dollar(
 
         state.line = nextLine + (1 if haveEndMarker else 0)
 
-        token = state.push("math_block_eqno" if label else "math_block", "math", 0)
+        token = state.push("math_block_label" if label else "math_block", "math", 0)
         token.block = True
         token.content = state.src[startPos + 2 : end]
         token.markup = "$$"
         token.map = [startLine, state.line]
         if label:
-            token.info = label
+            token.info = label if label_normalizer is None else label_normalizer(label)
 
         return True
 
diff --git a/setup.cfg b/setup.cfg
index ee42a10..79eeabd 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -60,4 +60,4 @@ strict_equality = True
 
 [flake8]
 max-line-length = 100
-extend-ignore = E203
+extend-ignore = E203,E731


Test patch:
diff --git a/tests/fixtures/dollar_math.md b/tests/fixtures/dollar_math.md
index dd0f423..a1c2d43 100644
--- a/tests/fixtures/dollar_math.md
+++ b/tests/fixtures/dollar_math.md
@@ -16,35 +16,35 @@ single character inline equation. (valid=True)
 .
 $a$
 .
-<p><eq>a</eq></p>
+<p><span class="math inline">a</span></p>
 .
 
 inline equation with single greek character (valid=True)
 .
 $\\varphi$
 .
-<p><eq>\\varphi</eq></p>
+<p><span class="math inline">\\varphi</span></p>
 .
 
 simple equation starting and ending with numbers. (valid=True)
 .
 $1+1=2$
 .
-<p><eq>1+1=2</eq></p>
+<p><span class="math inline">1+1=2</span></p>
 .
 
 simple equation including special html character. (valid=True)
 .
 $1+1<3$
 .
-<p><eq>1+1<3</eq></p>
+<p><span class="math inline">1+1&lt;3</span></p>
 .
 
 equation including backslashes. (valid=True)
 .
 $a \\backslash$
 .
-<p><eq>a \\backslash</eq></p>
+<p><span class="math inline">a \\backslash</span></p>
 .
 
 use of currency symbol, i.e. digits before/after opening/closing (valid=True)
@@ -58,42 +58,42 @@ use of currency symbol (valid=True)
 .
 If you solve $1+2$ you get $3
 .
-<p>If you solve <eq>1+2</eq> you get $3</p>
+<p>If you solve <span class="math inline">1+2</span> you get $3</p>
 .
 
 inline fraction (valid=True)
 .
 $\\frac{1}{2}$
 .
-<p><eq>\\frac{1}{2}</eq></p>
+<p><span class="math inline">\\frac{1}{2}</span></p>
 .
 
 inline column vector (valid=True)
 .
 $\\begin{pmatrix}x\\\\y\\end{pmatrix}$
 .
-<p><eq>\\begin{pmatrix}x\\\\y\\end{pmatrix}</eq></p>
+<p><span class="math inline">\\begin{pmatrix}x\\\\y\\end{pmatrix}</span></p>
 .
 
 inline bold vector notation (valid=True)
 .
 ${\\tilde\\bold e}_\\alpha$
 .
-<p><eq>{\\tilde\\bold e}_\\alpha</eq></p>
+<p><span class="math inline">{\\tilde\\bold e}_\\alpha</span></p>
 .
 
 exponentiation (valid=True)
 .
 $a^{b}$
 .
-<p><eq>a^{b}</eq></p>
+<p><span class="math inline">a^{b}</span></p>
 .
 
 conjugate complex (valid=True)
 .
 $a^\*b$ with $a^\*$
 .
-<p><eq>a^\*b</eq> with <eq>a^\*</eq></p>
+<p><span class="math inline">a^\*b</span> with <span class="math inline">a^\*</span></p>
 .
 
 Inline multi-line (valid=True)
@@ -101,8 +101,8 @@ Inline multi-line (valid=True)
 a $a
 \not=1$ b
 .
-<p>a <eq>a
-\not=1</eq> b</p>
+<p>a <span class="math inline">a
+\not=1</span> b</p>
 .
 
 Inline multi-line with newline (valid=False)
@@ -119,28 +119,28 @@ single block equation, greek index (valid=True)
 .
 $$e_\\alpha$$
 .
-<section>
-<eqn>e_\\alpha</eqn>
-</section>
+<div class="math block">
+e_\\alpha
+</div>
 .
 
 display equation on its own single line. (valid=True)
 .
-$$1+1=2$$   
+$$1+1=2$$
 .
-<section>
-<eqn>1+1=2</eqn>
-</section>
+<div class="math block">
+1+1=2
+</div>
 .
 
 display equation with number on its own single line. (valid=True)
 .
-$$1+1=2$$ (2)  
+$$1+1=2$$ (2)
 .
-<section>
-<eqn>1+1=2</eqn>
-<span class="eqno">(2)</span>
-</section>
+<div id="2" class="math block">
+<a href="#2" class="mathlabel" title="Permalink to this equation">¶</a>
+1+1=2
+</div>
 .
 
 inline equation followed by block equation. (valid=True)
@@ -149,19 +149,19 @@ ${e}_x$
 
 $$e_\\alpha$$
 .
-<p><eq>{e}_x</eq></p>
-<section>
-<eqn>e_\\alpha</eqn>
-</section>
+<p><span class="math inline">{e}_x</span></p>
+<div class="math block">
+e_\\alpha
+</div>
 .
 
 underline tests (valid=True)
 .
 $$c{\\bold e}_x = a{\\bold e}_\\alpha - b\\tilde{\\bold e}_\\alpha$$
 .
-<section>
-<eqn>c{\\bold e}_x = a{\\bold e}_\\alpha - b\\tilde{\\bold e}_\\alpha</eqn>
-</section>
+<div class="math block">
+c{\\bold e}_x = a{\\bold e}_\\alpha - b\\tilde{\\bold e}_\\alpha
+</div>
 .
 
 non-numeric character before opening $ or
@@ -171,30 +171,30 @@ a$1+1=2$
 $1+1=2$b
 c$x$d
 .
-<p>a<eq>1+1=2</eq>
-<eq>1+1=2</eq>b
-c<eq>x</eq>d</p>
+<p>a<span class="math inline">1+1=2</span>
+<span class="math inline">1+1=2</span>b
+c<span class="math inline">x</span>d</p>
 .
 
 following dollar character '$' is allowed. (valid=True)
 .
-$x$ $ 
+$x$ $
 .
-<p><eq>x</eq> $</p>
+<p><span class="math inline">x</span> $</p>
 .
 
 consecutive inline equations. (valid=True)
 .
 $x$ $y$
 .
-<p><eq>x</eq> <eq>y</eq></p>
+<p><span class="math inline">x</span> <span class="math inline">y</span></p>
 .
 
 inline equation after '-' sign in text. (valid=True)
 .
 so-what is $x$
 .
-<p>so-what is <eq>x</eq></p>
+<p>so-what is <span class="math inline">x</span></p>
 .
 
 display equation with line breaks. (valid=True)
@@ -203,11 +203,9 @@ $$
 1+1=2
 $$
 .
-<section>
-<eqn>
+<div class="math block">
 1+1=2
-</eqn>
-</section>
+</div>
 .
 
 multiple equations (valid=True)
@@ -220,16 +218,12 @@ $$
 b = 2
 $$
 .
-<section>
-<eqn>
+<div class="math block">
 a = 1
-</eqn>
-</section>
-<section>
-<eqn>
+</div>
+<div class="math block">
 b = 2
-</eqn>
-</section>
+</div>
 .
 
 equation followed by a labelled equation (valid=True)
@@ -242,62 +236,58 @@ $$
 b = 2
 $$ (1)
 .
-<section>
-<eqn>
+<div class="math block">
 a = 1
-</eqn>
-</section>
-<section>
-<eqn>
+</div>
+<div id="1" class="math block">
+<a href="#1" class="mathlabel" title="Permalink to this equation">¶</a>
 b = 2
-</eqn>
-<span class="eqno">(1)</span>
-</section>
+</div>
 .
 
 multiline equation. (valid=True)
 .
 $$\\begin{matrix}
- f & = & 2 + x + 3 \\ 
- & = & 5 + x 
+ f & = & 2 + x + 3 \\
+ & = & 5 + x
 \\end{matrix}$$
 .
-<section>
-<eqn>\\begin{matrix}
- f & = & 2 + x + 3 \\ 
- & = & 5 + x 
-\\end{matrix}</eqn>
-</section>
+<div class="math block">
+\\begin{matrix}
+ f &amp; = &amp; 2 + x + 3 \\
+ &amp; = &amp; 5 + x
+\\end{matrix}
+</div>
 .
 
 vector equation. (valid=True)
 .
-$$\\begin{pmatrix}x_2 \\\\ y_2 \\end{pmatrix} = 
+$$\\begin{pmatrix}x_2 \\\\ y_2 \\end{pmatrix} =
 \\begin{pmatrix} A & B \\\\ C & D \\end{pmatrix}\\cdot
 \\begin{pmatrix} x_1 \\\\ y_1 \\end{pmatrix}$$
 .
-<section>
-<eqn>\\begin{pmatrix}x_2 \\\\ y_2 \\end{pmatrix} = 
-\\begin{pmatrix} A & B \\\\ C & D \\end{pmatrix}\\cdot
-\\begin{pmatrix} x_1 \\\\ y_1 \\end{pmatrix}</eqn>
-</section>
+<div class="math block">
+\\begin{pmatrix}x_2 \\\\ y_2 \\end{pmatrix} =
+\\begin{pmatrix} A &amp; B \\\\ C &amp; D \\end{pmatrix}\\cdot
+\\begin{pmatrix} x_1 \\\\ y_1 \\end{pmatrix}
+</div>
 .
 
 display equation with equation number. (valid=True)
 .
 $$f(x) = x^2 - 1$$ (1)
 .
-<section>
-<eqn>f(x) = x^2 - 1</eqn>
-<span class="eqno">(1)</span>
-</section>
+<div id="1" class="math block">
+<a href="#1" class="mathlabel" title="Permalink to this equation">¶</a>
+f(x) = x^2 - 1
+</div>
 .
 
 inline equation following code section. (valid=True)
 .
 `code`$a-b$
 .
-<p><code>code</code><eq>a-b</eq></p>
+<p><code>code</code><span class="math inline">a-b</span></p>
 .
 
 equation following code block. (valid=True)
@@ -309,9 +299,9 @@ $$a+b$$
 .
 <pre><code>code
 </code></pre>
-<section>
-<eqn>a+b</eqn>
-</section>
+<div class="math block">
+a+b
+</div>
 .
 
 numbered equation following code block. (valid=True)
@@ -323,10 +313,10 @@ $$a+b$$(1)
 .
 <pre><code>code
 </code></pre>
-<section>
-<eqn>a+b</eqn>
-<span class="eqno">(1)</span>
-</section>
+<div id="1" class="math block">
+<a href="#1" class="mathlabel" title="Permalink to this equation">¶</a>
+a+b
+</div>
 .
 
 Equations in list. (valid=True)
@@ -336,10 +326,10 @@ Equations in list. (valid=True)
     1. $3+4$
 .
 <ol>
-<li><eq>1+2</eq></li>
-<li><eq>2+3</eq>
+<li><span class="math inline">1+2</span></li>
+<li><span class="math inline">2+3</span>
 <ol>
-<li><eq>3+4</eq></li>
+<li><span class="math inline">3+4</span></li>
 </ol>
 </li>
 </ol>
@@ -349,26 +339,26 @@ Inline sum. (valid=True)
 .
 $\\sum\_{i=1}^n$
 .
-<p><eq>\\sum\_{i=1}^n</eq></p>
+<p><span class="math inline">\\sum\_{i=1}^n</span></p>
 .
 
 Sum without equation number. (valid=True)
 .
 $$\\sum\_{i=1}^n$$
 .
-<section>
-<eqn>\\sum\_{i=1}^n</eqn>
-</section>
+<div class="math block">
+\\sum\_{i=1}^n
+</div>
 .
 
 Sum with equation number. (valid=True)
 .
 $$\\sum\_{i=1}\^n$$ (2)
 .
-<section>
-<eqn>\\sum\_{i=1}\^n</eqn>
-<span class="eqno">(2)</span>
-</section>
+<div id="2" class="math block">
+<a href="#2" class="mathlabel" title="Permalink to this equation">¶</a>
+\\sum\_{i=1}\^n
+</div>
 .
 
 equation number always vertically aligned. (valid=True)
@@ -377,24 +367,24 @@ $${\\bold e}(\\varphi) = \\begin{pmatrix}
 \\cos\\varphi\\\\\\sin\\varphi
 \\end{pmatrix}$$ (3)
 .
-<section>
-<eqn>{\\bold e}(\\varphi) = \\begin{pmatrix}
+<div id="3" class="math block">
+<a href="#3" class="mathlabel" title="Permalink to this equation">¶</a>
+{\\bold e}(\\varphi) = \\begin{pmatrix}
 \\cos\\varphi\\\\\\sin\\varphi
-\\end{pmatrix}</eqn>
-<span class="eqno">(3)</span>
-</section>
+\\end{pmatrix}
+</div>
 .
 
 inline equations in blockquote. (valid=True)
 .
-> see $a = b + c$ 
-> $c^2=a^2+b^2$ (2) 
-> $c^2=a^2+b^2$ 
+> see $a = b + c$
+> $c^2=a^2+b^2$ (2)
+> $c^2=a^2+b^2$
 .
 <blockquote>
-<p>see <eq>a = b + c</eq>
-<eq>c^2=a^2+b^2</eq> (2)
-<eq>c^2=a^2+b^2</eq></p>
+<p>see <span class="math inline">a = b + c</span>
+<span class="math inline">c^2=a^2+b^2</span> (2)
+<span class="math inline">c^2=a^2+b^2</span></p>
 </blockquote>
 .
 
@@ -404,14 +394,14 @@ display equation in blockquote. (valid=True)
 >
 > $$ a+b=c$$ (2)
 >
-> in blockquote. 
+> in blockquote.
 .
 <blockquote>
 <p>formula</p>
-<section>
-<eqn> a+b=c</eqn>
-<span class="eqno">(2)</span>
-</section>
+<div id="2" class="math block">
+<a href="#2" class="mathlabel" title="Permalink to this equation">¶</a>
+a+b=c
+</div>
 <p>in blockquote.</p>
 </blockquote>
 .
@@ -425,15 +415,13 @@ $$ (abc)
 
 - ab $c=1$ d
 .
-<section>
-<eqn>
+<div id="abc" class="math block">
+<a href="#abc" class="mathlabel" title="Permalink to this equation">¶</a>
 a=1 \\
 b=2
-</eqn>
-<span class="eqno">(abc)</span>
-</section>
+</div>
 <ul>
-<li>ab <eq>c=1</eq> d</li>
+<li>ab <span class="math inline">c=1</span> d</li>
 </ul>
 .
 
@@ -443,8 +431,8 @@ dollar '$' characters. (valid=True)
 \\$1+1=2$
 $1+1=2\\$
 .
-<p>\<eq>1+1=2</eq>
-<eq>1+1=2\\</eq></p>
+<p>\<span class="math inline">1+1=2</span>
+<span class="math inline">1+1=2\\</span></p>
 .
 
 empty line between text and display formula is required. (valid=False)
@@ -495,49 +483,49 @@ math-escaping: internal escaped $:
 .
 $p_2 = \$1$
 .
-<p><eq>p_2 = \$1</eq></p>
+<p><span class="math inline">p_2 = \$1</span></p>
 .
 
 math-escaping: double-escaped start $:
 .
 \\$p_2 = 1$
 .
-<p>\<eq>p_2 = 1</eq></p>
+<p>\<span class="math inline">p_2 = 1</span></p>
 .
 
 math-escaping: double-escaped end $:
 .
 $p_2 = \\$a
 .
-<p><eq>p_2 = \\</eq>a</p>
+<p><span class="math inline">p_2 = \\</span>a</p>
 .
 
 Inline double-dollar start:
 .
 $$a=1$$ b
 .
-<p><eqn>a=1</eqn> b</p>
+<p><div class="math inline">a=1</div> b</p>
 .
 
 Inline double-dollar end:
 .
 a $$a=1$$
 .
-<p>a <eqn>a=1</eqn></p>
+<p>a <div class="math inline">a=1</div></p>
 .
 
 Inline double-dollar enclosed:
 .
 a $$a=1$$ (1) b
 .
-<p>a <eqn>a=1</eqn> (1) b</p>
+<p>a <div class="math inline">a=1</div> (1) b</p>
 .
 
 Inline double-dollar, escaped:
 .
 a \$$a=1$$ b
 .
-<p>a $<eq>a=1</eq>$ b</p>
+<p>a $<span class="math inline">a=1</span>$ b</p>
 .
 
 Inline mixed single/double dollars:
@@ -548,9 +536,17 @@ $$
 $$
 i.e., $[\alpha \bar{X}, \infty)$ is a lower 1-sided $1-\alpha$ confidence bound for $\mu$.
 .
-<p>Hence, for <eq>\alpha \in (0, 1)</eq>,
-<eqn>
-  \mathbb P (\alpha \bar{X} \ge \mu) \le \alpha;
-</eqn>
-i.e., <eq>[\alpha \bar{X}, \infty)</eq> is a lower 1-sided <eq>1-\alpha</eq> confidence bound for <eq>\mu</eq>.</p>
+<p>Hence, for <span class="math inline">\alpha \in (0, 1)</span>,
+<div class="math inline">\mathbb P (\alpha \bar{X} \ge \mu) \le \alpha;</div>
+i.e., <span class="math inline">[\alpha \bar{X}, \infty)</span> is a lower 1-sided <span class="math inline">1-\alpha</span> confidence bound for <span class="math inline">\mu</span>.</p>
+.
+
+display equation with label containing whitespace. (valid=True)
+.
+$$1+1=2$$ (a b)
+.
+<div id="a-b" class="math block">
+<a href="#a-b" class="mathlabel" title="Permalink to this equation">¶</a>
+1+1=2
+</div>
 .
diff --git a/tests/test_dollarmath.py b/tests/test_dollarmath.py
index 3db3a78..1cb1b12 100644
--- a/tests/test_dollarmath.py
+++ b/tests/test_dollarmath.py
@@ -49,7 +49,7 @@ def test_block_func():
     block_func(state, 0, 10, False)
     print(tokens[0].as_dict())
     assert tokens[0].as_dict() == {
-        "type": "math_block_eqno",
+        "type": "math_block_label",
         "tag": "math",
         "nesting": 0,
         "attrs": None,
@@ -86,7 +86,7 @@ def test_plugin_parse(data_regression):
     "line,title,input,expected",
     read_fixture_file(FIXTURE_PATH.joinpath("dollar_math.md")),
 )
-def test_dollarmath_fixturess(line, title, input, expected):
+def test_dollarmath_fixtures(line, title, input, expected):
     md = MarkdownIt("commonmark").use(
         dollarmath_plugin, allow_space=False, allow_digits=False, double_inline=True
     )
diff --git a/tests/test_dollarmath/test_plugin_parse.yml b/tests/test_dollarmath/test_plugin_parse.yml
index 338d18c..789cbe7 100644
--- a/tests/test_dollarmath/test_plugin_parse.yml
+++ b/tests/test_dollarmath/test_plugin_parse.yml
@@ -18,7 +18,7 @@
   meta: {}
   nesting: 0
   tag: math
-  type: math_block_eqno
+  type: math_block_label
 - attrs: null
   block: true
   children: null