Fossil SCM

For rendering footnote-refs enclose HTML tag "a" inside of tag "sup" (instead of the opposite). Format anchors ids using "footnote%s-%i-%s" template (instead of "footnote-%s%i-%s"). Add highlighting when hovering over a span-bounded footnotes.

george 2022-02-04 17:28 markdown-footnotes
Commit fb999972e441766bee98fdebad7b6d460033665cec3f88c4a98030a8c76c43c7
2 files changed +4 -2 +14 -14
+4 -2
--- src/default.css
+++ src/default.css
@@ -1678,17 +1678,19 @@
16781678
font-weight: bold;
16791679
}
16801680
div.markdown > ol.footnotes > li > .footnote-backrefs > a:target {
16811681
background: gold;
16821682
}
1683
-div.markdown a.noteref:target > sup {
1683
+div.markdown sup > a.noteref:target {
16841684
background: gold;
16851685
}
1686
+div.markdown span.notescope:hover,
16861687
div.markdown span.notescope:target {
16871688
border-bottom: 2px solid gold;
16881689
}
1689
-div.markdown span.notescope:target > a.noteref > sup {
1690
+div.markdown span.notescope:hover > sup > a.noteref,
1691
+div.markdown span.notescope:target > sup > a.noteref {
16901692
background: gold;
16911693
}
16921694
16931695
/* Objects in the "desktoponly" class are invisible on mobile */
16941696
@media screen and (max-width: 600px) {
16951697
--- src/default.css
+++ src/default.css
@@ -1678,17 +1678,19 @@
1678 font-weight: bold;
1679 }
1680 div.markdown > ol.footnotes > li > .footnote-backrefs > a:target {
1681 background: gold;
1682 }
1683 div.markdown a.noteref:target > sup {
1684 background: gold;
1685 }
 
1686 div.markdown span.notescope:target {
1687 border-bottom: 2px solid gold;
1688 }
1689 div.markdown span.notescope:target > a.noteref > sup {
 
1690 background: gold;
1691 }
1692
1693 /* Objects in the "desktoponly" class are invisible on mobile */
1694 @media screen and (max-width: 600px) {
1695
--- src/default.css
+++ src/default.css
@@ -1678,17 +1678,19 @@
1678 font-weight: bold;
1679 }
1680 div.markdown > ol.footnotes > li > .footnote-backrefs > a:target {
1681 background: gold;
1682 }
1683 div.markdown sup > a.noteref:target {
1684 background: gold;
1685 }
1686 div.markdown span.notescope:hover,
1687 div.markdown span.notescope:target {
1688 border-bottom: 2px solid gold;
1689 }
1690 div.markdown span.notescope:hover > sup > a.noteref,
1691 div.markdown span.notescope:target > sup > a.noteref {
1692 background: gold;
1693 }
1694
1695 /* Objects in the "desktoponly" class are invisible on mobile */
1696 @media screen and (max-width: 600px) {
1697
--- src/markdown_html.c
+++ src/markdown_html.c
@@ -333,22 +333,22 @@
333333
const bitfield64_t l = to_base26(locus-1,0);
334334
char pos[32];
335335
336336
/* expect BUGs if the following yields compiler warnings */
337337
memset(pos,0,32);
338
- sprintf(pos, "%s%i-%s", ctx->unique.c, index, l.c);
338
+ sprintf(pos, "%s-%i-%s", ctx->unique.c, index, l.c);
339339
if(span && blob_size(span)) {
340
- BLOB_APPEND_LITERAL(ob,"<span class='notescope' id='noteref-");
340
+ BLOB_APPEND_LITERAL(ob,"<span class='notescope' id='noteref");
341341
blob_appendf(ob,"%s'>",pos);
342342
BLOB_APPEND_BLOB(ob, span);
343343
blob_trim(ob);
344
- BLOB_APPEND_LITERAL(ob,"<a class='noteref' href='#footnote-");
345
- blob_appendf(ob,"%s'><sup>%i</sup></a></span>", pos, index);
344
+ BLOB_APPEND_LITERAL(ob,"<sup><a class='noteref' href='#footnote");
345
+ blob_appendf(ob,"%s'>%i</a></sup></span>", pos, index);
346346
}else{
347347
blob_trim(ob);
348
- BLOB_APPEND_LITERAL(ob,"<a class='noteref' href='#footnote-");
349
- blob_appendf(ob,"%s' id='noteref-%s'><sup>%i</sup></a>",
348
+ BLOB_APPEND_LITERAL(ob,"<sup><a class='noteref' href='#footnote");
349
+ blob_appendf(ob,"%s' id='noteref%s'>%i</a></sup>",
350350
pos, pos, index);
351351
}
352352
return 1;
353353
}
354354
@@ -363,31 +363,31 @@
363363
return;
364364
}
365365
366366
/* expect BUGs if the following yields compiler warnings */
367367
memset(pos,0,24);
368
- sprintf(pos, "%s%i", ctx->unique.c, index);
368
+ sprintf(pos, "%s-%i", ctx->unique.c, index);
369369
370
- blob_appendf(ob, "<li id='footnote-%s'>", pos);
370
+ blob_appendf(ob, "<li id='footnote%s'>", pos);
371371
BLOB_APPEND_LITERAL(ob,"<sup class='footnote-backrefs'>");
372372
if( nUsed <= 1 ){
373
- blob_appendf(ob,"<a id='footnote-%s-a' "
374
- "href='#noteref-%s-a'>^</a>", pos, pos);
373
+ blob_appendf(ob,"<a id='footnote%s-a' "
374
+ "href='#noteref%s-a'>^</a>", pos, pos);
375375
}else{
376376
int i;
377377
blob_append_char(ob, '^');
378378
for(i=0; i<nUsed && i<26; i++){
379379
const int c = i + (unsigned)'a';
380
- blob_appendf(ob," <a id='footnote-%s-%c'"
381
- " href='#noteref-%s-%c'>%c</a>", pos,c, pos,c, c);
380
+ blob_appendf(ob," <a id='footnote%s-%c'"
381
+ " href='#noteref%s-%c'>%c</a>", pos,c, pos,c, c);
382382
}
383383
/* It's unlikely that so many backrefs will be usefull */
384384
/* but maybe for some machine generated documents... */
385385
for(; i<nUsed && i<676; i++){
386386
const bitfield64_t l = to_base26(i,0);
387
- blob_appendf(ob," <a id='footnote-%s-%s'"
388
- " href='#noteref-%s-%s'>%s</a>",
387
+ blob_appendf(ob," <a id='footnote%s-%s'"
388
+ " href='#noteref%s-%s'>%s</a>",
389389
pos,l.c, pos,l.c, l.c);
390390
}
391391
if( i < nUsed ) BLOB_APPEND_LITERAL(ob," &hellip;");
392392
}
393393
BLOB_APPEND_LITERAL(ob,"</sup>\n");
394394
--- src/markdown_html.c
+++ src/markdown_html.c
@@ -333,22 +333,22 @@
333 const bitfield64_t l = to_base26(locus-1,0);
334 char pos[32];
335
336 /* expect BUGs if the following yields compiler warnings */
337 memset(pos,0,32);
338 sprintf(pos, "%s%i-%s", ctx->unique.c, index, l.c);
339 if(span && blob_size(span)) {
340 BLOB_APPEND_LITERAL(ob,"<span class='notescope' id='noteref-");
341 blob_appendf(ob,"%s'>",pos);
342 BLOB_APPEND_BLOB(ob, span);
343 blob_trim(ob);
344 BLOB_APPEND_LITERAL(ob,"<a class='noteref' href='#footnote-");
345 blob_appendf(ob,"%s'><sup>%i</sup></a></span>", pos, index);
346 }else{
347 blob_trim(ob);
348 BLOB_APPEND_LITERAL(ob,"<a class='noteref' href='#footnote-");
349 blob_appendf(ob,"%s' id='noteref-%s'><sup>%i</sup></a>",
350 pos, pos, index);
351 }
352 return 1;
353 }
354
@@ -363,31 +363,31 @@
363 return;
364 }
365
366 /* expect BUGs if the following yields compiler warnings */
367 memset(pos,0,24);
368 sprintf(pos, "%s%i", ctx->unique.c, index);
369
370 blob_appendf(ob, "<li id='footnote-%s'>", pos);
371 BLOB_APPEND_LITERAL(ob,"<sup class='footnote-backrefs'>");
372 if( nUsed <= 1 ){
373 blob_appendf(ob,"<a id='footnote-%s-a' "
374 "href='#noteref-%s-a'>^</a>", pos, pos);
375 }else{
376 int i;
377 blob_append_char(ob, '^');
378 for(i=0; i<nUsed && i<26; i++){
379 const int c = i + (unsigned)'a';
380 blob_appendf(ob," <a id='footnote-%s-%c'"
381 " href='#noteref-%s-%c'>%c</a>", pos,c, pos,c, c);
382 }
383 /* It's unlikely that so many backrefs will be usefull */
384 /* but maybe for some machine generated documents... */
385 for(; i<nUsed && i<676; i++){
386 const bitfield64_t l = to_base26(i,0);
387 blob_appendf(ob," <a id='footnote-%s-%s'"
388 " href='#noteref-%s-%s'>%s</a>",
389 pos,l.c, pos,l.c, l.c);
390 }
391 if( i < nUsed ) BLOB_APPEND_LITERAL(ob," &hellip;");
392 }
393 BLOB_APPEND_LITERAL(ob,"</sup>\n");
394
--- src/markdown_html.c
+++ src/markdown_html.c
@@ -333,22 +333,22 @@
333 const bitfield64_t l = to_base26(locus-1,0);
334 char pos[32];
335
336 /* expect BUGs if the following yields compiler warnings */
337 memset(pos,0,32);
338 sprintf(pos, "%s-%i-%s", ctx->unique.c, index, l.c);
339 if(span && blob_size(span)) {
340 BLOB_APPEND_LITERAL(ob,"<span class='notescope' id='noteref");
341 blob_appendf(ob,"%s'>",pos);
342 BLOB_APPEND_BLOB(ob, span);
343 blob_trim(ob);
344 BLOB_APPEND_LITERAL(ob,"<sup><a class='noteref' href='#footnote");
345 blob_appendf(ob,"%s'>%i</a></sup></span>", pos, index);
346 }else{
347 blob_trim(ob);
348 BLOB_APPEND_LITERAL(ob,"<sup><a class='noteref' href='#footnote");
349 blob_appendf(ob,"%s' id='noteref%s'>%i</a></sup>",
350 pos, pos, index);
351 }
352 return 1;
353 }
354
@@ -363,31 +363,31 @@
363 return;
364 }
365
366 /* expect BUGs if the following yields compiler warnings */
367 memset(pos,0,24);
368 sprintf(pos, "%s-%i", ctx->unique.c, index);
369
370 blob_appendf(ob, "<li id='footnote%s'>", pos);
371 BLOB_APPEND_LITERAL(ob,"<sup class='footnote-backrefs'>");
372 if( nUsed <= 1 ){
373 blob_appendf(ob,"<a id='footnote%s-a' "
374 "href='#noteref%s-a'>^</a>", pos, pos);
375 }else{
376 int i;
377 blob_append_char(ob, '^');
378 for(i=0; i<nUsed && i<26; i++){
379 const int c = i + (unsigned)'a';
380 blob_appendf(ob," <a id='footnote%s-%c'"
381 " href='#noteref%s-%c'>%c</a>", pos,c, pos,c, c);
382 }
383 /* It's unlikely that so many backrefs will be usefull */
384 /* but maybe for some machine generated documents... */
385 for(; i<nUsed && i<676; i++){
386 const bitfield64_t l = to_base26(i,0);
387 blob_appendf(ob," <a id='footnote%s-%s'"
388 " href='#noteref%s-%s'>%s</a>",
389 pos,l.c, pos,l.c, l.c);
390 }
391 if( i < nUsed ) BLOB_APPEND_LITERAL(ob," &hellip;");
392 }
393 BLOB_APPEND_LITERAL(ob,"</sup>\n");
394

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button