Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | For rendering a numeric footnote mark enclose HTML tag "a" inside of tag "sup" (instead of the opposite) and format anchor's id using "noteref%s-%i-%s" template (instead of "noteref-%s%i-%s"). Add highlighting when hovering over a span-bounded footnotes. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | markdown-footnotes |
| Files: | files | file ages | folders |
| SHA3-256: |
fb999972e441766bee98fdebad7b6d46 |
| User & Date: | george 2022-02-04 17:28:16.958 |
| Original Comment: | 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. |
Context
|
2022-02-04
| ||
| 19:08 | Add file [/doc/markdown-footnotes/test/markdown-test3.md|test/markdown-test3.md] that is suggested as an accumulator of footnotes-specific test cases. ... (check-in: fe9e6ff9eb user: george tags: markdown-footnotes) | |
| 17:28 | For rendering a numeric footnote mark enclose HTML tag "a" inside of tag "sup" (instead of the opposite) and format anchor's id using "noteref%s-%i-%s" template (instead of "noteref-%s%i-%s"). Add highlighting when hovering over a span-bounded footnotes. ... (check-in: fb999972e4 user: george tags: markdown-footnotes) | |
| 16:54 | Fix documentation so that an example of a referenced footnote definition inside of the fenced code block is not recognized as a real footnote defenition. This demonstrates a subtle gotcha and a possible work-arround of it. ... (check-in: 7229d0f588 user: george tags: markdown-footnotes) | |
Changes
Changes to src/default.css.
| ︙ | ︙ | |||
1676 1677 1678 1679 1680 1681 1682 |
div.content div.markdown > ol.footnotes > li > .footnote-backrefs {
margin-right: 0.5em;
font-weight: bold;
}
div.markdown > ol.footnotes > li > .footnote-backrefs > a:target {
background: gold;
}
| | > > | | 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 |
div.content div.markdown > ol.footnotes > li > .footnote-backrefs {
margin-right: 0.5em;
font-weight: bold;
}
div.markdown > ol.footnotes > li > .footnote-backrefs > a:target {
background: gold;
}
div.markdown sup > a.noteref:target {
background: gold;
}
div.markdown span.notescope:hover,
div.markdown span.notescope:target {
border-bottom: 2px solid gold;
}
div.markdown span.notescope:hover > sup > a.noteref,
div.markdown span.notescope:target > sup > a.noteref {
background: gold;
}
/* Objects in the "desktoponly" class are invisible on mobile */
@media screen and (max-width: 600px) {
.desktoponly {
display: none;
|
| ︙ | ︙ |
Changes to src/markdown_html.c.
| ︙ | ︙ | |||
331 332 333 334 335 336 337 |
){
const struct MarkdownToHtml *ctx = (struct MarkdownToHtml*)opaque;
const bitfield64_t l = to_base26(locus-1,0);
char pos[32];
/* expect BUGs if the following yields compiler warnings */
memset(pos,0,32);
| | | | | | | | | | | | | | | | 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 |
){
const struct MarkdownToHtml *ctx = (struct MarkdownToHtml*)opaque;
const bitfield64_t l = to_base26(locus-1,0);
char pos[32];
/* expect BUGs if the following yields compiler warnings */
memset(pos,0,32);
sprintf(pos, "%s-%i-%s", ctx->unique.c, index, l.c);
if(span && blob_size(span)) {
BLOB_APPEND_LITERAL(ob,"<span class='notescope' id='noteref");
blob_appendf(ob,"%s'>",pos);
BLOB_APPEND_BLOB(ob, span);
blob_trim(ob);
BLOB_APPEND_LITERAL(ob,"<sup><a class='noteref' href='#footnote");
blob_appendf(ob,"%s'>%i</a></sup></span>", pos, index);
}else{
blob_trim(ob);
BLOB_APPEND_LITERAL(ob,"<sup><a class='noteref' href='#footnote");
blob_appendf(ob,"%s' id='noteref%s'>%i</a></sup>",
pos, pos, index);
}
return 1;
}
/* Render a single item of the footnotes list.
* Each backref gets a unique id to enable dynamic styling. */
static void html_footnote_item(
struct Blob *ob, const struct Blob *text, int index, int nUsed, void *opaque
){
const struct MarkdownToHtml *ctx = (struct MarkdownToHtml*)opaque;
char pos[24];
if( index <= 0 || nUsed < 0 || !text || !blob_size(text) ){
return;
}
/* expect BUGs if the following yields compiler warnings */
memset(pos,0,24);
sprintf(pos, "%s-%i", ctx->unique.c, index);
blob_appendf(ob, "<li id='footnote%s'>", pos);
BLOB_APPEND_LITERAL(ob,"<sup class='footnote-backrefs'>");
if( nUsed <= 1 ){
blob_appendf(ob,"<a id='footnote%s-a' "
"href='#noteref%s-a'>^</a>", pos, pos);
}else{
int i;
blob_append_char(ob, '^');
for(i=0; i<nUsed && i<26; i++){
const int c = i + (unsigned)'a';
blob_appendf(ob," <a id='footnote%s-%c'"
" href='#noteref%s-%c'>%c</a>", pos,c, pos,c, c);
}
/* It's unlikely that so many backrefs will be usefull */
/* but maybe for some machine generated documents... */
for(; i<nUsed && i<676; i++){
const bitfield64_t l = to_base26(i,0);
blob_appendf(ob," <a id='footnote%s-%s'"
" href='#noteref%s-%s'>%s</a>",
pos,l.c, pos,l.c, l.c);
}
if( i < nUsed ) BLOB_APPEND_LITERAL(ob," …");
}
BLOB_APPEND_LITERAL(ob,"</sup>\n");
BLOB_APPEND_BLOB(ob, text);
BLOB_APPEND_LITERAL(ob, "\n</li>\n");
|
| ︙ | ︙ |