v0.5.3
Example document / build (push) Has been cancelled
Python application / build (push) Has been cancelled

- Мелкие исправления увеличивающие работу конвертера
This commit is contained in:
Igor20264
2026-09-10 10:50:15 +03:00
parent 658036f920
commit f7136bd8bd
95 changed files with 7165 additions and 8771 deletions
+20
View File
@@ -0,0 +1,20 @@
"""Cross-reference slugs shared by the export backends."""
from __future__ import annotations
import re
_LABEL_RE = re.compile(r"[^\w\-]+", re.UNICODE)
def sanitize_label(name: str | None, prefix: str = "obj", separator: str = ":") -> str:
"""
Turn a `%id` caption name into a target usable as an anchor.
`separator` differs per backend: LaTeX `\\label` accepts a colon, an
XML `NCName` does not.
"""
if not name:
return prefix
cleaned = _LABEL_RE.sub("-", name.strip()).strip("-")
return f"{prefix}{separator}{cleaned or 'x'}"