Skip to content
Open
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
3 changes: 3 additions & 0 deletions blag/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from markdown import Markdown
from markdown.extensions import Extension
from markdown.treeprocessors import Treeprocessor
from l2m4m import LaTeX2MathMLExtension


logger = logging.getLogger(__name__)

Expand All @@ -35,6 +37,7 @@ def markdown_factory() -> Markdown:
"codehilite",
"smarty",
MarkdownLinkExtension(),
LaTeX2MathMLExtension(),
],
output_format="html",
)
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies = [
"jinja2",
"markdown",
"pygments",
"l2m4m",
]

[project.scripts]
Expand Down
14 changes: 14 additions & 0 deletions tests/test_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,17 @@ def test_smarty_code() -> None:
assert "mdash" not in html
assert "ndash" not in html
assert "hellip" not in html

def test_l2m4m_extension() -> None:
"""Test LaTeX math rendering via l2m4m extension."""
md = markdown_factory()
markdown_input = (
"Quick math: $E = mc^2$\n"
)
expected_output_fragments = [
'math display="inline"',
]
html, _ = convert_markdown(md, markdown_input)

for fragment in expected_output_fragments:
assert fragment in html