diff options
author | DS <commits@sidhion.com> | 2024-03-21 02:53:14 -0700 |
---|---|---|
committer | DS <commits@sidhion.com> | 2024-03-21 07:59:55 -0700 |
commit | cf94a85e99cb71743308ccd3781656df23fd98c9 (patch) | |
tree | ecc295cbd37841b4c3bb7bbb0e9d4dd6b375a08f | |
parent | b2f29564730e757d24d154272e8e50fc2a831980 (diff) |
doc: fix code to generate links for headings in the manual
-rw-r--r-- | doc/anchor-use.js | 2 | ||||
-rw-r--r-- | pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/html.py | 5 |
2 files changed, 3 insertions, 4 deletions
diff --git a/doc/anchor-use.js b/doc/anchor-use.js index 06ec24883aa3a..a45c4e2be68d8 100644 --- a/doc/anchor-use.js +++ b/doc/anchor-use.js @@ -1,3 +1,3 @@ document.addEventListener('DOMContentLoaded', function(event) { - anchors.add('h1:not(div.note h1, div.warning h1, div.tip h1, div.caution h1, div.important h1), h2:not(div.note h2, div.warning h2, div.tip h2, div.caution h2, div.important h2), h3:not(div.note h3, div.warning h3, div.tip h3, div.caution h3, div.important h3), h4:not(div.note h4, div.warning h4, div.tip h4, div.caution h4, div.important h4), h5:not(div.note h5, div.warning h5, div.tip h5, div.caution h5, div.important h5), h6:not(div.note h6, div.warning h6, div.tip h6, div.caution h6, div.important h6)'); + anchors.add('h1[id]:not(div.note h1, div.warning h1, div.tip h1, div.caution h1, div.important h1), h2[id]:not(div.note h2, div.warning h2, div.tip h2, div.caution h2, div.important h2), h3[id]:not(div.note h3, div.warning h3, div.tip h3, div.caution h3, div.important h3), h4[id]:not(div.note h4, div.warning h4, div.tip h4, div.caution h4, div.important h4), h5[id]:not(div.note h5, div.warning h5, div.tip h5, div.caution h5, div.important h5), h6[id]:not(div.note h6, div.warning h6, div.tip h6, div.caution h6, div.important h6)'); }); diff --git a/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/html.py b/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/html.py index 3ee10a60568dd..2e43a6a2be876 100644 --- a/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/html.py +++ b/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/html.py @@ -181,7 +181,7 @@ class HTMLRenderer(Renderer): if hstyle: hstyle = f'style="{escape(hstyle, True)}"' if anchor := cast(str, token.attrs.get('id', '')): - anchor = f'<span id="{escape(anchor, True)}"></span>' + anchor = f'id="{escape(anchor, True)}"' result = self._close_headings(hlevel) tag = self._heading_tag(token, tokens, i) toc_fragment = self._build_toc(tokens, i) @@ -192,8 +192,7 @@ class HTMLRenderer(Renderer): f' <div class="titlepage">' f' <div>' f' <div>' - f' <{htag} class="title" {hstyle}>' - f' {anchor}' + f' <{htag} {anchor} class="title" {hstyle}>' ) def heading_close(self, token: Token, tokens: Sequence[Token], i: int) -> str: heading = self._headings[-1] |