v0.5.3
- Мелкие исправления увеличивающие работу конвертера
This commit is contained in:
+3
-8
@@ -2,9 +2,10 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from xml.sax.saxutils import escape as _xml_escape
|
||||
|
||||
from mdexport.labels import sanitize_label
|
||||
|
||||
|
||||
def escape_text(s: str) -> str:
|
||||
if not s:
|
||||
@@ -12,11 +13,5 @@ def escape_text(s: str) -> str:
|
||||
return _xml_escape(s, {"\"": """, "'": "'"})
|
||||
|
||||
|
||||
_LABEL_RE = re.compile(r"[^\w\-]+", re.UNICODE)
|
||||
|
||||
|
||||
def xml_id(name: str | None, prefix: str = "obj") -> str:
|
||||
if not name:
|
||||
return prefix
|
||||
cleaned = _LABEL_RE.sub("-", name.strip()).strip("-")
|
||||
return f"{prefix}-{cleaned or 'x'}"
|
||||
return sanitize_label(name, prefix, "-")
|
||||
|
||||
Reference in New Issue
Block a user