18 lines
404 B
Python
18 lines
404 B
Python
"""XML escape helpers for FODT output."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from xml.sax.saxutils import escape as _xml_escape
|
|
|
|
from mdexport.labels import sanitize_label
|
|
|
|
|
|
def escape_text(s: str) -> str:
|
|
if not s:
|
|
return ""
|
|
return _xml_escape(s, {"\"": """, "'": "'"})
|
|
|
|
|
|
def xml_id(name: str | None, prefix: str = "obj") -> str:
|
|
return sanitize_label(name, prefix, "-")
|