added pandoc as renderer
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user