added pandoc as renderer

This commit is contained in:
2026-02-08 18:03:05 -05:00
parent a56cd665b0
commit 164cb5d980
6 changed files with 33 additions and 9 deletions

View File

@@ -3,6 +3,7 @@ from __future__ import annotations
import re
import markdown as md_lib
import subprocess
from .errors import ValidationIssue
@@ -81,5 +82,22 @@ def convert_markdown(
except Exception as exc: # pragma: no cover - depends on markdown internals
issues.append(ValidationIssue(f"Markdown conversion failed: {exc}", context=context))
return None
if renderer == "pandoc":
try:
result = subprocess.run(
["pandoc", "--from=markdown", "--to=html5"],
input=markdown_text,
text=True,
capture_output=True,
check=True,
)
return result.stdout
except FileNotFoundError as exc:
issues.append(ValidationIssue(f"pandoc is not available: {exc}", context=context))
return None
except subprocess.CalledProcessError as exc:
stderr = exc.stderr.strip() if exc.stderr else ""
issues.append(ValidationIssue(f"Pandoc conversion failed: {stderr}", context=context))
return None
issues.append(ValidationIssue(f"Unknown renderer: {renderer}", context=context))
return None