Skip to content

Commit 8474289

Browse files
committed
Swapped : for - when emitting html footnote ref labels.
1 parent 4bf57ea commit 8474289

File tree

3 files changed

+45
-45
lines changed

3 files changed

+45
-45
lines changed

src/html.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static bool S_put_footnote_backref(cmark_html_renderer *renderer, cmark_strbuf *
6464
return false;
6565
renderer->written_footnote_ix = renderer->footnote_ix;
6666

67-
cmark_strbuf_puts(html, "<a href=\"#fnref:");
67+
cmark_strbuf_puts(html, "<a href=\"#fnref-");
6868
houdini_escape_href(html, node->as.literal.data, node->as.literal.len);
6969
cmark_strbuf_puts(html, "\" class=\"footnote-backref\">↩</a>");
7070

@@ -74,9 +74,9 @@ static bool S_put_footnote_backref(cmark_html_renderer *renderer, cmark_strbuf *
7474
char n[32];
7575
snprintf(n, sizeof(n), "%d", i);
7676

77-
cmark_strbuf_puts(html, " <a href=\"#fnref:");
77+
cmark_strbuf_puts(html, " <a href=\"#fnref-");
7878
houdini_escape_href(html, node->as.literal.data, node->as.literal.len);
79-
cmark_strbuf_puts(html, ":");
79+
cmark_strbuf_puts(html, "-");
8080
cmark_strbuf_puts(html, n);
8181
cmark_strbuf_puts(html, "\" class=\"footnote-backref\">↩<sup class=\"footnote-ref\">");
8282
cmark_strbuf_puts(html, n);
@@ -410,7 +410,7 @@ static int S_render_node(cmark_html_renderer *renderer, cmark_node *node,
410410
}
411411
++renderer->footnote_ix;
412412

413-
cmark_strbuf_puts(html, "<li id=\"fn:");
413+
cmark_strbuf_puts(html, "<li id=\"fn-");
414414
houdini_escape_href(html, node->as.literal.data, node->as.literal.len);
415415
cmark_strbuf_puts(html, "\">\n");
416416
} else {
@@ -423,15 +423,15 @@ static int S_render_node(cmark_html_renderer *renderer, cmark_node *node,
423423

424424
case CMARK_NODE_FOOTNOTE_REFERENCE:
425425
if (entering) {
426-
cmark_strbuf_puts(html, "<sup class=\"footnote-ref\"><a href=\"#fn:");
426+
cmark_strbuf_puts(html, "<sup class=\"footnote-ref\"><a href=\"#fn-");
427427
houdini_escape_href(html, node->parent_footnote_def->as.literal.data, node->parent_footnote_def->as.literal.len);
428-
cmark_strbuf_puts(html, "\" id=\"fnref:");
428+
cmark_strbuf_puts(html, "\" id=\"fnref-");
429429
houdini_escape_href(html, node->parent_footnote_def->as.literal.data, node->parent_footnote_def->as.literal.len);
430430

431431
if (node->footnote.ref_ix > 1) {
432432
char n[32];
433433
snprintf(n, sizeof(n), "%d", node->footnote.ref_ix);
434-
cmark_strbuf_puts(html, ":");
434+
cmark_strbuf_puts(html, "-");
435435
cmark_strbuf_puts(html, n);
436436
}
437437

test/extensions.txt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -672,31 +672,31 @@ Hi!
672672

673673
[^unused]: This is unused.
674674
.
675-
<p>This is some text!<sup class="footnote-ref"><a href="#fn:1" id="fnref:1">1</a></sup>. Other text.<sup class="footnote-ref"><a href="#fn:footnote" id="fnref:footnote">2</a></sup>.</p>
676-
<p>Here's a thing<sup class="footnote-ref"><a href="#fn:other-note" id="fnref:other-note">3</a></sup>.</p>
677-
<p>And another thing<sup class="footnote-ref"><a href="#fn:codeblock-note" id="fnref:codeblock-note">4</a></sup>.</p>
675+
<p>This is some text!<sup class="footnote-ref"><a href="#fn-1" id="fnref-1">1</a></sup>. Other text.<sup class="footnote-ref"><a href="#fn-footnote" id="fnref-footnote">2</a></sup>.</p>
676+
<p>Here's a thing<sup class="footnote-ref"><a href="#fn-other-note" id="fnref-other-note">3</a></sup>.</p>
677+
<p>And another thing<sup class="footnote-ref"><a href="#fn-codeblock-note" id="fnref-codeblock-note">4</a></sup>.</p>
678678
<p>This doesn't have a referent[^nope].</p>
679679
<p>Hi!</p>
680680
<section class="footnotes">
681681
<ol>
682-
<li id="fn:1">
683-
<p>Some <em>bolded</em> footnote definition. <a href="#fnref:1" class="footnote-backref">↩</a></p>
682+
<li id="fn-1">
683+
<p>Some <em>bolded</em> footnote definition. <a href="#fnref-1" class="footnote-backref">↩</a></p>
684684
</li>
685-
<li id="fn:footnote">
685+
<li id="fn-footnote">
686686
<blockquote>
687687
<p>Blockquotes can be in a footnote.</p>
688688
</blockquote>
689689
<pre><code>as well as code blocks
690690
</code></pre>
691-
<p>or, naturally, simple paragraphs. <a href="#fnref:footnote" class="footnote-backref">↩</a></p>
691+
<p>or, naturally, simple paragraphs. <a href="#fnref-footnote" class="footnote-backref">↩</a></p>
692692
</li>
693-
<li id="fn:other-note">
694-
<p>no code block here (spaces are stripped away) <a href="#fnref:other-note" class="footnote-backref">↩</a></p>
693+
<li id="fn-other-note">
694+
<p>no code block here (spaces are stripped away) <a href="#fnref-other-note" class="footnote-backref">↩</a></p>
695695
</li>
696-
<li id="fn:codeblock-note">
696+
<li id="fn-codeblock-note">
697697
<pre><code>this is now a code block (8 spaces indentation)
698698
</code></pre>
699-
<a href="#fnref:codeblock-note" class="footnote-backref">↩</a>
699+
<a href="#fnref-codeblock-note" class="footnote-backref">↩</a>
700700
</li>
701701
</ol>
702702
</section>
@@ -711,12 +711,12 @@ This footnote is referenced[^a-footnote] multiple times, in lots of different pl
711711

712712
[^a-footnote]: This footnote definition should have three backrefs.
713713
.
714-
<p>This is some text. It has a footnote<sup class="footnote-ref"><a href="#fn:a-footnote" id="fnref:a-footnote">1</a></sup>.</p>
715-
<p>This footnote is referenced<sup class="footnote-ref"><a href="#fn:a-footnote" id="fnref:a-footnote:2">1</a></sup> multiple times, in lots of different places.<sup class="footnote-ref"><a href="#fn:a-footnote" id="fnref:a-footnote:3">1</a></sup></p>
714+
<p>This is some text. It has a footnote<sup class="footnote-ref"><a href="#fn-a-footnote" id="fnref-a-footnote">1</a></sup>.</p>
715+
<p>This footnote is referenced<sup class="footnote-ref"><a href="#fn-a-footnote" id="fnref-a-footnote-2">1</a></sup> multiple times, in lots of different places.<sup class="footnote-ref"><a href="#fn-a-footnote" id="fnref-a-footnote-3">1</a></sup></p>
716716
<section class="footnotes">
717717
<ol>
718-
<li id="fn:a-footnote">
719-
<p>This footnote definition should have three backrefs. <a href="#fnref:a-footnote" class="footnote-backref">↩</a> <a href="#fnref:a-footnote:2" class="footnote-backref">↩<sup class="footnote-ref">2</sup></a> <a href="#fnref:a-footnote:3" class="footnote-backref">↩<sup class="footnote-ref">3</sup></a></p>
718+
<li id="fn-a-footnote">
719+
<p>This footnote definition should have three backrefs. <a href="#fnref-a-footnote" class="footnote-backref">↩</a> <a href="#fnref-a-footnote-2" class="footnote-backref">↩<sup class="footnote-ref">2</sup></a> <a href="#fnref-a-footnote-3" class="footnote-backref">↩<sup class="footnote-ref">3</sup></a></p>
720720
</li>
721721
</ol>
722722
</section>
@@ -729,11 +729,11 @@ Hello[^"><script>alert(1)</script>]
729729

730730
[^"><script>alert(1)</script>]: pwned
731731
.
732-
<p>Hello<sup class="footnote-ref"><a href="#fn:%22%3E%3Cscript%3Ealert(1)%3C/script%3E" id="fnref:%22%3E%3Cscript%3Ealert(1)%3C/script%3E">1</a></sup></p>
732+
<p>Hello<sup class="footnote-ref"><a href="#fn-%22%3E%3Cscript%3Ealert(1)%3C/script%3E" id="fnref-%22%3E%3Cscript%3Ealert(1)%3C/script%3E">1</a></sup></p>
733733
<section class="footnotes">
734734
<ol>
735-
<li id="fn:%22%3E%3Cscript%3Ealert(1)%3C/script%3E">
736-
<p>pwned <a href="#fnref:%22%3E%3Cscript%3Ealert(1)%3C/script%3E" class="footnote-backref">↩</a></p>
735+
<li id="fn-%22%3E%3Cscript%3Ealert(1)%3C/script%3E">
736+
<p>pwned <a href="#fnref-%22%3E%3Cscript%3Ealert(1)%3C/script%3E" class="footnote-backref">↩</a></p>
737737
</li>
738738
</ol>
739739
</section>

test/regression.txt

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ A footnote in a paragraph[^1]
175175

176176
[^1]: a footnote
177177
.
178-
<p>A footnote in a paragraph<sup class="footnote-ref"><a href="#fn:1" id="fnref:1">1</a></sup></p>
178+
<p>A footnote in a paragraph<sup class="footnote-ref"><a href="#fn-1" id="fnref-1">1</a></sup></p>
179179
<table>
180180
<thead>
181181
<tr>
@@ -185,15 +185,15 @@ A footnote in a paragraph[^1]
185185
</thead>
186186
<tbody>
187187
<tr>
188-
<td>foot <sup class="footnote-ref"><a href="#fn:1" id="fnref:1:2">1</a></sup></td>
188+
<td>foot <sup class="footnote-ref"><a href="#fn-1" id="fnref-1-2">1</a></sup></td>
189189
<td>note</td>
190190
</tr>
191191
</tbody>
192192
</table>
193193
<section class="footnotes">
194194
<ol>
195-
<li id="fn:1">
196-
<p>a footnote <a href="#fnref:1" class="footnote-backref">↩</a> <a href="#fnref:1:2" class="footnote-backref">↩<sup class="footnote-ref">2</sup></a></p>
195+
<li id="fn-1">
196+
<p>a footnote <a href="#fnref-1" class="footnote-backref">↩</a> <a href="#fnref-1-2" class="footnote-backref">↩<sup class="footnote-ref">2</sup></a></p>
197197
</li>
198198
</ol>
199199
</section>
@@ -279,14 +279,14 @@ This is some text. It has a citation.[^citation]
279279

280280
[^citation]: This is a long winded parapgraph that also has another citation.[^another-citation]
281281
.
282-
<p>This is some text. It has a citation.<sup class="footnote-ref"><a href="#fn:citation" id="fnref:citation">1</a></sup></p>
282+
<p>This is some text. It has a citation.<sup class="footnote-ref"><a href="#fn-citation" id="fnref-citation">1</a></sup></p>
283283
<section class="footnotes">
284284
<ol>
285-
<li id="fn:citation">
286-
<p>This is a long winded parapgraph that also has another citation.<sup class="footnote-ref"><a href="#fn:another-citation" id="fnref:another-citation">2</a></sup> <a href="#fnref:citation" class="footnote-backref">↩</a></p>
285+
<li id="fn-citation">
286+
<p>This is a long winded parapgraph that also has another citation.<sup class="footnote-ref"><a href="#fn-another-citation" id="fnref-another-citation">2</a></sup> <a href="#fnref-citation" class="footnote-backref">↩</a></p>
287287
</li>
288-
<li id="fn:another-citation">
289-
<p>My second citation. <a href="#fnref:another-citation" class="footnote-backref">↩</a></p>
288+
<li id="fn-another-citation">
289+
<p>My second citation. <a href="#fnref-another-citation" class="footnote-backref">↩</a></p>
290290
</li>
291291
</ol>
292292
</section>
@@ -301,14 +301,14 @@ This is some text. It has two footnotes references, side-by-side without any spa
301301

302302
[^footnote2]: Goodbye.
303303
.
304-
<p>This is some text. It has two footnotes references, side-by-side without any spaces,<sup class="footnote-ref"><a href="#fn:footnote1" id="fnref:footnote1">1</a></sup><sup class="footnote-ref"><a href="#fn:footnote2" id="fnref:footnote2">2</a></sup> which are definitely not link references.</p>
304+
<p>This is some text. It has two footnotes references, side-by-side without any spaces,<sup class="footnote-ref"><a href="#fn-footnote1" id="fnref-footnote1">1</a></sup><sup class="footnote-ref"><a href="#fn-footnote2" id="fnref-footnote2">2</a></sup> which are definitely not link references.</p>
305305
<section class="footnotes">
306306
<ol>
307-
<li id="fn:footnote1">
308-
<p>Hello. <a href="#fnref:footnote1" class="footnote-backref">↩</a></p>
307+
<li id="fn-footnote1">
308+
<p>Hello. <a href="#fnref-footnote1" class="footnote-backref">↩</a></p>
309309
</li>
310-
<li id="fn:footnote2">
311-
<p>Goodbye. <a href="#fnref:footnote2" class="footnote-backref">↩</a></p>
310+
<li id="fn-footnote2">
311+
<p>Goodbye. <a href="#fnref-footnote2" class="footnote-backref">↩</a></p>
312312
</li>
313313
</ol>
314314
</section>
@@ -325,15 +325,15 @@ It has another footnote that contains many different characters (the autolinker
325325

326326
[^widely-cited]: this renders properly.
327327
.
328-
<p>This is some text. Sometimes the autolinker splits up text into multiple nodes, hoping it will find a hyperlink, so this text has a footnote whose reference label begins with a <code>w</code>.<sup class="footnote-ref"><a href="#fn:widely-cited" id="fnref:widely-cited">1</a></sup></p>
329-
<p>It has another footnote that contains many different characters (the autolinker was also breaking on <code>_</code>).<sup class="footnote-ref"><a href="#fn:sphinx-of-black-quartz_judge-my-vow-0123456789" id="fnref:sphinx-of-black-quartz_judge-my-vow-0123456789">2</a></sup></p>
328+
<p>This is some text. Sometimes the autolinker splits up text into multiple nodes, hoping it will find a hyperlink, so this text has a footnote whose reference label begins with a <code>w</code>.<sup class="footnote-ref"><a href="#fn-widely-cited" id="fnref-widely-cited">1</a></sup></p>
329+
<p>It has another footnote that contains many different characters (the autolinker was also breaking on <code>_</code>).<sup class="footnote-ref"><a href="#fn-sphinx-of-black-quartz_judge-my-vow-0123456789" id="fnref-sphinx-of-black-quartz_judge-my-vow-0123456789">2</a></sup></p>
330330
<section class="footnotes">
331331
<ol>
332-
<li id="fn:widely-cited">
333-
<p>this renders properly. <a href="#fnref:widely-cited" class="footnote-backref">↩</a></p>
332+
<li id="fn-widely-cited">
333+
<p>this renders properly. <a href="#fnref-widely-cited" class="footnote-backref">↩</a></p>
334334
</li>
335-
<li id="fn:sphinx-of-black-quartz_judge-my-vow-0123456789">
336-
<p>so does this. <a href="#fnref:sphinx-of-black-quartz_judge-my-vow-0123456789" class="footnote-backref">↩</a></p>
335+
<li id="fn-sphinx-of-black-quartz_judge-my-vow-0123456789">
336+
<p>so does this. <a href="#fnref-sphinx-of-black-quartz_judge-my-vow-0123456789" class="footnote-backref">↩</a></p>
337337
</li>
338338
</ol>
339339
</section>

0 commit comments

Comments
 (0)