Diff
Not logged in

Differences From Artifact [6a4fedf87b]:

To Artifact [61eb8871b0]:


381
382
383
384
385
386
387
388
389


390
391
392
393
394
395
396
397
398
399
400
401
402
403

404
405
406



407
408



409

410
411
412
413
414
415




416
417
418
419
420

421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436




437




438
439
440
441
442
443
444
445

446
447

448
449
450
451
452
453
454
455
381
382
383
384
385
386
387


388
389
390
391
392
393
394
395
396
397
398
399
400
401
402

403
404
405
406
407
408
409
410
411
412
413
414

415
416
417




418
419
420
421
422
423
424
425

426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446

447
448
449
450
451
452
453
454
455
456
457

458
459

460

461
462
463
464
465
466
467







-
-
+
+













-
+



+
+
+


+
+
+
-
+


-
-
-
-
+
+
+
+




-
+
















+
+
+
+
-
+
+
+
+







-
+

-
+
-







  const char * const unique = ((struct MarkdownToHtml*)opaque)->unique.c;
  assert( nUsed >= 0 );
  /* expect BUGs if the following yields compiler warnings */

  if( iMark < 0 ){                     /* misreferences */
    assert( iMark == -1 );
    if( !nUsed ) return;
    BLOB_APPEND_LITERAL(ob,"<li class='misreferences'>"
                              "<sup class='footnote-backrefs'>");
    BLOB_APPEND_LITERAL(ob,"<li class='fn-misreference'>"
                              "<sup class='fn-backrefs'>");
    if( nUsed == 1 ){
      blob_appendf(ob,"<a id='misreference%s-a' "
                      "href='#misref%s-a'>^</a>", unique, unique);
    }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='misreference%s-%c' "
              "href='#misref%s-%c'>%c</a>", unique,c, unique,c, c);
      }
      if( i < nUsed ) BLOB_APPEND_LITERAL(ob," &hellip;");
    }
    BLOB_APPEND_LITERAL(ob,"</sup>\nMisreference: use of undefined label.");
    BLOB_APPEND_LITERAL(ob,"</sup>\n<span>Misreference</span>");

  }else if( nUsed ){                   /* a regular footnote */
    char pos[24];
    const char *join = "";
    #define _joined_footnote_indicator "<ul class='fn-joined'>"
    #define _jfi_sz (sizeof(_joined_footnote_indicator)-1)
    assert( text );
    assert( blob_size(text) );
    if( blob_size(text)>=_jfi_sz &&
       !memcmp(blob_buffer(text),_joined_footnote_indicator,_jfi_sz)){
      join = "fn-joined ";

    }
    memset(pos,0,24);
    sprintf(pos, "%s-%i", unique, iMark);

    blob_appendf(ob, "<li id='footnote%s'>", pos);
    BLOB_APPEND_LITERAL(ob,"<sup class='footnote-backrefs'>");
    if( nUsed <= 1 ){
    blob_appendf(ob, "<li id='footnote%s' class='%s", pos, join);

    if( nUsed == 1 ){
      BLOB_APPEND_LITERAL(ob, "fn-monoref'><sup class='fn-backrefs'>");
      blob_appendf(ob,"<a id='footnote%s-a' "
                       "href='#noteref%s-a'>^</a>", pos, pos);
    }else{
      int i;
      blob_append_char(ob, '^');
      BLOB_APPEND_LITERAL(ob, "fn-polyref'><sup class='fn-backrefs'>^");
      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," &hellip;");
    }
    BLOB_APPEND_LITERAL(ob,"</sup>\n");
    if( join[0] ){
      BLOB_APPEND_LITERAL(ob,"<sup class='fn-joined'></sup><ul>");
      blob_append(ob,blob_buffer(text)+_jfi_sz,blob_size(text)-_jfi_sz);
    }else{
    BLOB_APPEND_BLOB(ob, text);
      BLOB_APPEND_BLOB(ob, text);
    }
    #undef _joined_footnote_indicator
    #undef _jfi_sz
  }else{
    /* a footnote was defined but wasn't used */
    /* make.footnote_item() invocations should pass args accordingly */
    const struct Blob * id = text-1;
    assert( text );
    assert( blob_size(text) );
    assert( blob_size(id) );
    BLOB_APPEND_LITERAL(ob,"<li class='unreferenced'>\n[^&nbsp;<code>");
    BLOB_APPEND_LITERAL(ob,"<li class='fn-unreferenced'>\n[^&nbsp;<code>");
    html_escape(ob, blob_buffer(id), blob_size(id));
    BLOB_APPEND_LITERAL(ob, "</code>&nbsp;] "
    BLOB_APPEND_LITERAL(ob, "</code>&nbsp;]<i></i>\n"
        "<i>was defined but is not referenced</i>\n"
        "<pre><code class='language-markdown'>");
    html_escape(ob, blob_buffer(text), blob_size(text));
    BLOB_APPEND_LITERAL(ob,"</code></pre>");
  }
  BLOB_APPEND_LITERAL(ob, "\n</li>\n");
}
static void html_footnotes(