Source code for httk.web.renderers.markdown

from pathlib import Path

import markdown

from ._frontmatter import split_front_matter
from .base import RenderResult


[docs] class MarkdownRenderer:
[docs] def render(self, source_path: Path) -> RenderResult: source = source_path.read_text(encoding="utf-8") metadata, body = split_front_matter(source) html = markdown.markdown( body, output_format="html", extensions=["fenced_code", "codehilite", "tables"], ) return RenderResult(html=html, metadata=dict(metadata))