Repository: roniemartinez/latex2mathml (language: python)

Issue:
\frac without curly braces inconsistent with Mathjax
Mathjax renders these two \fracs the same, as 1/2 x:

`\frac 1 2 x + \frac 12x`

but latex2mathml converts the second one into 12/x.

Reference cdelker/ziamath#6.


Discussion / hints:

Fix patch:
diff --git a/latex2mathml/tokenizer.py b/latex2mathml/tokenizer.py
index e8ba230..dd7ef63 100644
--- a/latex2mathml/tokenizer.py
+++ b/latex2mathml/tokenizer.py
@@ -18,7 +18,7 @@
     (\\(?:begin|end|operatorname){{[a-zA-Z]+\*?}}) |    # begin, end or operatorname
     #  color, fbox, href, hbox, mbox, style, text, textbf, textit, textrm, textsf, texttt
     (\\(?:color|fbox|hbox|href|mbox|style|text|textbf|textit|textrm|textsf|texttt))\s*{{([^}}]*)}} |
-    (\\[cdt]?frac)([.\d])([.\d])? |                     # fractions
+    (\\[cdt]?frac)\s*([.\d])\s*([.\d])? |               # fractions
     (\\math[a-z]+)({{)([a-zA-Z])(}}) |                  # commands starting with math
     (\\[a-zA-Z]+) |                                     # other commands
     (\S)                                                # non-space character
diff --git a/pyproject.toml b/pyproject.toml
index 41b5627..0795ac1 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
 [tool.poetry]
 name = "latex2mathml"
-version = "3.75.2"
+version = "3.75.3"
 repository = "https://github.com/roniemartinez/latex2mathml"
 description = "Pure Python library for LaTeX to MathML conversion"
 authors = ["Ronie Martinez <ronmarti18@gmail.com>"]


Test patch:
diff --git a/tests/test_tokenizer.py b/tests/test_tokenizer.py
index 828f5c2..d043156 100644
--- a/tests/test_tokenizer.py
+++ b/tests/test_tokenizer.py
@@ -515,6 +515,9 @@
         pytest.param(r"\frac.2", [r"\frac", ".", "2"], id="issue-245-3"),
         pytest.param(r"\frac123", [r"\frac", "1", "2", "3"], id="issue-245-4"),
         pytest.param(r"\color{}ab", [r"\color", "", "a", "b"], id="empty-color"),
+        pytest.param(
+            r"\frac 1 2 3 + \frac 123", [r"\frac", "1", "2", "3", "+", r"\frac", "1", "2", "3"], id="issue-386"
+        ),
     ],
 )
 def test_tokenize(latex: str, expected: list) -> None: