Fossil

Check-in [773cef5cf7]
Login

Check-in [773cef5cf7]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:If there are issues with footnotes then set TH1 variable <var>$footnotes_issues_counters</var> to a space separated list of integers that count for "misref", "unref" and "joins". This eliminates the need for JavaScript for the case when a custom skin wants to [forum:/forumpost/119b0be29a2b096b|warn about issues with footnotes] in the header of a page.<br> Also fix counting of "joins": count the number of unique labels that have multiple definitions (and not the number of such definitions).
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | markdown-footnotes
Files: files | file ages | folders
SHA3-256: 773cef5cf78a80e95e166a72620f51dd12ee8e75a9467e5e97bd5c493cb60a69
User & Date: george 2022-02-20 23:00:54.135
Original Comment: If the are issues with footnotes then set TH1 variable <var>$footnotes_issues_counters</var> as a space separated list of integers that counts for "misref", "unref" and "joins". This eliminates the need for JavaScript for the case when a custom skin wants to [forum:/forumpost/119b0be29a2b096b|warn about issues with footnotes] in the header of a page.<br> Also fix counting of "joins": count the number of unique labels that have multiple definitions (and not the number of such definitions).
Context
2022-02-21
04:29
Impose a limit on the depth of nesting of inline footnotes. Also add a few test cases: for depth limiting and HTML hijacking. ... (check-in: f4ff013ace user: george tags: markdown-footnotes)
2022-02-20
23:00
If there are issues with footnotes then set TH1 variable <var>$footnotes_issues_counters</var> to a space separated list of integers that count for "misref", "unref" and "joins". This eliminates the need for JavaScript for the case when a custom skin wants to [forum:/forumpost/119b0be29a2b096b|warn about issues with footnotes] in the header of a page.<br> Also fix counting of "joins": count the number of unique labels that have multiple definitions (and not the number of such definitions). ... (check-in: 773cef5cf7 user: george tags: markdown-footnotes)
2022-02-19
01:16
Parse inline footnotes even if a renderer does not define a callback for rendering of footnote markers. This seems more correct even though the current implementation of backlink processor does define such callback as an empty function. ... (check-in: e06c12d176 user: george tags: markdown-footnotes)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/markdown.c.
1146
1147
1148
1149
1150
1151
1152
1153
1154

1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
*/
size_t is_footnote_classlist(const char * const data, size_t size, int bBlank){
  const char *p;
  const char * const end = data+size;
  if( data==end || *data != '.' ) return 0;
  for(p=data+1; p!=end; p++){
    if( fossil_isalnum(*p) || *p=='-' ) continue;
    if( *p==':' ){
      if( p[-1]=='.' ) break;

      p++;
      if( bBlank ){
        if( p==end || !fossil_isspace(*p) ) break;
      }
      return p-data;
    }
    if( *p=='.' && p[-1]!='.' ) continue;
    break;
  }
  return 0;
}

/* Adds unlabeled footnote to the rndr.
 * If text is blank then returns 0,
 * otherwise returns the address of the added footnote. */







<
|
>






<
|







1146
1147
1148
1149
1150
1151
1152

1153
1154
1155
1156
1157
1158
1159
1160

1161
1162
1163
1164
1165
1166
1167
1168
*/
size_t is_footnote_classlist(const char * const data, size_t size, int bBlank){
  const char *p;
  const char * const end = data+size;
  if( data==end || *data != '.' ) return 0;
  for(p=data+1; p!=end; p++){
    if( fossil_isalnum(*p) || *p=='-' ) continue;

    if( p[-1]=='.' ) break;
    if( *p==':' ){
      p++;
      if( bBlank ){
        if( p==end || !fossil_isspace(*p) ) break;
      }
      return p-data;
    }

    if( *p!='.' ) break;
  }
  return 0;
}

/* Adds unlabeled footnote to the rndr.
 * If text is blank then returns 0,
 * otherwise returns the address of the added footnote. */
2697
2698
2699
2700
2701
2702
2703

2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727

          /* free memory buffer */
          blob_reset(&y->text);
          if( k!=i ) blob_reset(&y->id);
        }
        blob_append_string(&list, "</ul>\n");
        x->text = list;

      }
      i = j;
    }
    if( nDups ){  /* clean rndr.notes.all from invalidated footnotes */
      const int n = rndr.notes.nLbled - nDups;
      struct Blob filtered = empty_blob;
      blob_reserve(&filtered, n*sizeof(struct footnote));
      for(i=0; i<rndr.notes.nLbled; i++){
        if( blob_size(&fn[i].id) ){
          blob_append(&filtered, (char*)(fn+i), sizeof(struct footnote));
        }
      }
      blob_reset( allNotes );
      rndr.notes.all = filtered;
      rndr.notes.nLbled = n;
      assert( COUNT_FOOTNOTES(allNotes) == rndr.notes.nLbled );
      g.ftntsIssues[2] += nDups;
    }
  }
  fn = CAST_AS_FOOTNOTES( allNotes );
  for(i=0; i<rndr.notes.nLbled; i++){
    fn[i].index = i;
  }
  assert( rndr.notes.nMarks==0 );







>
















<







2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719

2720
2721
2722
2723
2724
2725
2726

          /* free memory buffer */
          blob_reset(&y->text);
          if( k!=i ) blob_reset(&y->id);
        }
        blob_append_string(&list, "</ul>\n");
        x->text = list;
        g.ftntsIssues[2]++;
      }
      i = j;
    }
    if( nDups ){  /* clean rndr.notes.all from invalidated footnotes */
      const int n = rndr.notes.nLbled - nDups;
      struct Blob filtered = empty_blob;
      blob_reserve(&filtered, n*sizeof(struct footnote));
      for(i=0; i<rndr.notes.nLbled; i++){
        if( blob_size(&fn[i].id) ){
          blob_append(&filtered, (char*)(fn+i), sizeof(struct footnote));
        }
      }
      blob_reset( allNotes );
      rndr.notes.all = filtered;
      rndr.notes.nLbled = n;
      assert( COUNT_FOOTNOTES(allNotes) == rndr.notes.nLbled );

    }
  }
  fn = CAST_AS_FOOTNOTES( allNotes );
  for(i=0; i<rndr.notes.nLbled; i++){
    fn[i].index = i;
  }
  assert( rndr.notes.nMarks==0 );
Changes to src/style.c.
779
780
781
782
783
784
785





786
787
788
789
790
791
792
  stylesheet_url_var();
  image_url_var("logo");
  image_url_var("background");
  if( !login_is_nobody() ){
    Th_Store("login", g.zLogin);
  }
  Th_MaybeStore("current_feature", feature_from_page_path(local_zCurrentPage) );





}

/*
** Draw the header.
*/
void style_header(const char *zTitleFormat, ...){
  va_list ap;







>
>
>
>
>







779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
  stylesheet_url_var();
  image_url_var("logo");
  image_url_var("background");
  if( !login_is_nobody() ){
    Th_Store("login", g.zLogin);
  }
  Th_MaybeStore("current_feature", feature_from_page_path(local_zCurrentPage) );
  if( g.ftntsIssues[0] || g.ftntsIssues[1] || g.ftntsIssues[2] ){
    char buf[64];
    sprintf(&buf[0],"%i %i %i",g.ftntsIssues[0],g.ftntsIssues[1],g.ftntsIssues[2]);
    Th_Store("footnotes_issues_counters", buf);
  }
}

/*
** Draw the header.
*/
void style_header(const char *zTitleFormat, ...){
  va_list ap;