diff --git a/pyproject.toml b/pyproject.toml index c2c63a3..aea7a42 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,6 +10,7 @@ requires-python = ">=3.12" dependencies = [ "dacite>=1.9.2", "jinja2>=3.1.6", + "l2m4m>=1.0.4", "markdown>=3.8.2", "pygments>=2.19.1", "pygments-ashen>=0.1.3", @@ -51,7 +52,7 @@ reportUnusedCallResult = false reportCallInDefaultInitializer = false enableTypeIgnoreComments = true reportIgnoreCommentWithoutRule = false -allowedUntypedLibraries = ["frontmatter", "pygments", "pymdownx"] +allowedUntypedLibraries = ["frontmatter", "pygments", "pymdownx", "l2m4m"] [tool.ruff] line-length = 70 diff --git a/src/zona/markdown.py b/src/zona/markdown.py index 024b48a..a58b334 100644 --- a/src/zona/markdown.py +++ b/src/zona/markdown.py @@ -3,6 +3,7 @@ from collections.abc import Sequence from pathlib import Path from typing import Any, override +from l2m4m import LaTeX2MathMLExtension from markdown import Markdown from markdown.extensions.abbr import AbbrExtension from markdown.extensions.attr_list import AttrListExtension @@ -157,6 +158,7 @@ def md_to_html( SaneListExtension(), MarkdownInHtmlExtension(), EscapeAllExtension(hardbreak=True), + LaTeX2MathMLExtension(), ] kwargs: dict[str, Any] = { "extensions": extensions, diff --git a/uv.lock b/uv.lock index 36f5ca8..311053e 100644 --- a/uv.lock +++ b/uv.lock @@ -65,6 +65,28 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/62/a1/3d680cbfd5f4b8f15abc1d571870c5fc3e594bb582bc3b64ea099db13e56/jinja2-3.1.6-py3-none-any.whl", hash = "sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67", size = 134899, upload-time = "2025-03-05T20:05:00.369Z" }, ] +[[package]] +name = "l2m4m" +version = "1.0.4" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "latex2mathml" }, + { name = "markdown" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/1d/71/2548c288ef1b27f3419285e45430b8f10b9be8f4c34b4d2ecec2d34baf42/l2m4m-1.0.4.tar.gz", hash = "sha256:7fc451edb281604c1eb9d6fa626a8cce874e8a0d3641cca581c20b7544f51396", size = 16567, upload-time = "2024-06-15T16:49:04.798Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f6/8a/500639fe4b0b1dfc7775633b9173d96a474bbc0811578e916595c9b323f0/L2M4M-1.0.4-py3-none-any.whl", hash = "sha256:766e232b28cfdc6397e9c47162a938dba26e5ab90bddec8d82eccb7896ab46d1", size = 14985, upload-time = "2024-06-15T16:49:03.88Z" }, +] + +[[package]] +name = "latex2mathml" +version = "3.78.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/69/33/ad2c3929494ad160f5130ea132ca298627a6c81c70be6bedd1bc806b5b01/latex2mathml-3.78.0.tar.gz", hash = "sha256:712193aa4c6ade1a8e0145dac7bc1f9aafbd54f93046a2356a7e1c05fa0f8b31", size = 73737, upload-time = "2025-05-03T16:51:53.563Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1e/fd/aba08bb9e527168efad57985d7db9a853eb2384b1efa5ca5f3a3794c9cef/latex2mathml-3.78.0-py3-none-any.whl", hash = "sha256:1aeca3dc027b3006ad7b301b7f4a15ffbb4c1451e3dc8c3389e97b37b497e1d6", size = 73673, upload-time = "2025-05-03T16:51:51.991Z" }, +] + [[package]] name = "markdown" version = "3.8.2" @@ -442,6 +464,7 @@ source = { editable = "." } dependencies = [ { name = "dacite" }, { name = "jinja2" }, + { name = "l2m4m" }, { name = "markdown" }, { name = "pygments" }, { name = "pygments-ashen" }, @@ -467,6 +490,7 @@ dev = [ requires-dist = [ { name = "dacite", specifier = ">=1.9.2" }, { name = "jinja2", specifier = ">=3.1.6" }, + { name = "l2m4m", specifier = ">=1.0.4" }, { name = "markdown", specifier = ">=3.8.2" }, { name = "pygments", specifier = ">=2.19.1" }, { name = "pygments-ashen", specifier = ">=0.1.3" },