diff options
Diffstat (limited to 'nixpkgs/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/manual_structure.py')
-rw-r--r-- | nixpkgs/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/manual_structure.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/manual_structure.py b/nixpkgs/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/manual_structure.py index c6e6bf429370..724ca4b72707 100644 --- a/nixpkgs/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/manual_structure.py +++ b/nixpkgs/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/manual_structure.py @@ -201,3 +201,20 @@ class TocEntry(Freezeable): while len(entries) > 1: entries[-2][1].children.append(entries.pop()[1]) return (entries[0][1], examples, figures) + +_xml_id_translate_table = { + ord('*'): ord('_'), + ord('<'): ord('_'), + ord(' '): ord('_'), + ord('>'): ord('_'), + ord('['): ord('_'), + ord(']'): ord('_'), + ord(':'): ord('_'), + ord('"'): ord('_'), +} +# this function is needed to generate option id attributes in the same format as +# the docbook toolchain did to not break existing links. we don't actually use +# xml any more, that's just the legacy we're dealing with and part of our structure +# now. +def make_xml_id(s: str) -> str: + return s.translate(_xml_id_translate_table) |