added math frontmatter option

This commit is contained in:
Daniel Fichtinger 2025-07-06 21:09:55 -04:00
parent eacaeba2ab
commit 3037aa88d8
3 changed files with 12 additions and 15 deletions

View file

@ -47,9 +47,7 @@ class ZonaBuilder:
destination=destination,
url=str(destination.relative_to(layout.output)),
)
if path.name.endswith(
".md"
) and not path.is_relative_to(
if path.name.endswith(".md") and not path.is_relative_to(
layout.root / "content" / "static"
):
logger.debug(
@ -72,13 +70,11 @@ class ZonaBuilder:
item.copy = False
name = destination.stem
if name == "index":
item.destination = (
item.destination.with_suffix(".html")
item.destination = item.destination.with_suffix(
".html"
)
else:
relative = path.relative_to(base).with_suffix(
""
)
relative = path.relative_to(base).with_suffix("")
name = relative.stem
item.destination = (
layout.output
@ -90,9 +86,7 @@ class ZonaBuilder:
layout.output
)
item.url = (
""
if rel_url == Path(".")
else rel_url.as_posix()
"" if rel_url == Path(".") else rel_url.as_posix()
)
items.append(item)
self.items = items
@ -118,9 +112,7 @@ class ZonaBuilder:
# write code highlighting stylesheet
if self.config.markdown.syntax_highlighting.enabled:
pygments_style = zmd.get_style_defs(self.config)
pygments_path = (
self.layout.output / "static" / "pygments.css"
)
pygments_path = self.layout.output / "static" / "pygments.css"
util.ensure_parents(pygments_path)
pygments_path.write_text(pygments_style)
for item in self.item_map.values():
@ -137,6 +129,7 @@ class ZonaBuilder:
source=item.source,
layout=self.layout,
item_map=self.item_map,
metadata=item.metadata,
)
# TODO: test this
rendered = templater.render_item(item, raw_html)

View file

@ -31,6 +31,7 @@ from zona import util
from zona.config import ZonaConfig
from zona.layout import Layout
from zona.log import get_logger
from zona.metadata import Metadata
from zona.models import Item
logger = get_logger()
@ -143,6 +144,7 @@ def md_to_html(
source: Path | None = None,
layout: Layout | None = None,
item_map: dict[Path, Item] | None = None,
metadata: Metadata | None = None,
) -> str:
extensions: Sequence[Any] = [
BetterEmExtension(),
@ -163,12 +165,13 @@ def md_to_html(
SaneListExtension(),
MarkdownInHtmlExtension(),
EscapeAllExtension(hardbreak=True),
LaTeX2MathMLExtension(),
]
kwargs: dict[str, Any] = {
"extensions": extensions,
"tab_length": 2,
}
if metadata and metadata.math:
kwargs["extensions"].append(LaTeX2MathMLExtension())
if config:
kwargs["extensions"].extend(
[

View file

@ -24,6 +24,7 @@ class Metadata:
template: str | None = None
post: bool | None = None
draft: bool = False
math: bool = True
def parse_date(raw_date: str | date | object) -> date: