nixos-render-docs: move escaping functions to new modules

these modules will be extended with more functionality. md will
ultimately contain MD-related code such as parsers and converter base
classes. docbook will contain renderers.
This commit is contained in:
pennae 2023-01-25 19:29:02 +01:00
parent be6a25368f
commit 986e48ca22
3 changed files with 28 additions and 25 deletions

View file

@ -0,0 +1,12 @@
_xml_id_translate_table = {
ord('*'): ord('_'),
ord('<'): ord('_'),
ord(' '): ord('_'),
ord('>'): ord('_'),
ord('['): ord('_'),
ord(']'): ord('_'),
ord(':'): ord('_'),
ord('"'): ord('_'),
}
def make_xml_id(s: str) -> str:
return s.translate(_xml_id_translate_table)