Debian Codegraph @

org/testdata/footnotes_in_headline.html

raw
1 <nav>
2 <ul>
3 <li><a href="#headline-1">Title <sup class="footnote-reference">1</sup></a>
4 </li>
5 </ul>
6 </nav>
7 <div id="outline-container-headline-1" class="outline-2">
8 <h2 id="headline-1">
9 Title <sup class="footnote-reference"><a id="footnote-reference-1" href="#footnote-1">1</a></sup>
10 </h2>
11 </div>
12 <div class="footnotes">
13 <hr class="footnotes-separatator"/>
14 <div class="footnote-definitions">
15 <div class="footnote-definition">
16 <sup id="footnote-1"><a href="#footnote-reference-1">1</a></sup>
17 <div class="footnote-body">
18 <p>this test file just exists to reproduce a bug with footnotes in headlines - that only happens in very specific circumstances.
19 The TLDR is:</p>
20 <ul>
21 <li>HTMLWriter.footnotes should be a pointer field. I didn&#39;t notice my error as go translated my pointer-method calls on
22 non-pointer values rather than complaining - i.e. <code class="verbatim">footnotes.add()</code> transparently gets translated to <code class="verbatim">(&amp;footnotes).add()</code> (<a href="https://golang.org/ref/spec#Calls">docs</a>).</li>
23 <li>Headlines have to be htmlified twice - once for the outline and once for the headline itself. To do so we have to copy the writer</li>
24 <li>Copying the writer copies footnotes - which contains a map and a slice. Changes to the map will always be reflected in the original map.
25 Changes to the slice will only be reflected if the slice doesn&#39;t grow.</li>
26 <li>We can thus end up with a footnote being in the mapping but not the slice - and get an index out of range error.</li>
27 </ul>
28 </div>
29 </div>
30 </div>
31 </div>