Fossil

Check-in [ae297bb6]
Login

Check-in [ae297bb6]

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

Overview
Comment:Count overnesting as the fourth type of the footnote-related issues and report accordingly.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | markdown-footnotes
Files: files | file ages | folders
SHA3-256: ae297bb6715738b5a455418290a670e792f19703952fdb282ecda6bb17f0a091
User & Date: george 2022-02-23 12:33:57
Context
2022-04-19
11:41
Merged in latest trunk to simplify code review and ease potential upcoming merge to trunk. ... (check-in: 8a4b099f user: stephan tags: markdown-footnotes)
2022-02-23
12:33
Count overnesting as the fourth type of the footnote-related issues and report accordingly. ... (check-in: ae297bb6 user: george tags: markdown-footnotes)
09:45
Minor refactoring. Move the definition of BLOB_APPEND_LITERAL() macro from markdown_html.c to blob.c so that it could be used outside of markdown_html.c. Also rename it to lowercase for consistency with other API. Within markdown.c use that newly available macro instead of blob_append_string(). Within markdown_html.c use it for footnotes-relevant code. Other invocations of BLOB_APPEND_LITERAL() within markdown_html.c are left intact (they use an alias) in order to simplify the potential merge with the trunk. ... (check-in: c8a8d0c9 user: george tags: markdown-footnotes)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/main.c.

322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
      cson_value *v;
      cson_object *o;
    } reqPayload;              /* request payload object (if any) */
    cson_array *warnings;      /* response warnings */
    int timerId;               /* fetched from fossil_timer_start() */
  } json;
#endif /* FOSSIL_ENABLE_JSON */
  int ftntsIssues[3];     /* Counts for misref, strayed, joined */
  int diffCnt[3];         /* Counts for DIFF_NUMSTAT: files, ins, del */
};

/*
** Macro for debugging:
*/
#define CGIDEBUG(X)  if( g.fDebug ) cgi_debug X







|







322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
      cson_value *v;
      cson_object *o;
    } reqPayload;              /* request payload object (if any) */
    cson_array *warnings;      /* response warnings */
    int timerId;               /* fetched from fossil_timer_start() */
  } json;
#endif /* FOSSIL_ENABLE_JSON */
  int ftntsIssues[4];     /* Counts for misref, strayed, joined, overnested */
  int diffCnt[3];         /* Counts for DIFF_NUMSTAT: files, ins, del */
};

/*
** Macro for debugging:
*/
#define CGIDEBUG(X)  if( g.fDebug ) cgi_debug X

Changes to src/markdown.c.

2786
2787
2788
2789
2790
2791
2792

2793
2794
2795
2796

2797
2798
2799
2800
2801
2802
2803
      */
      const struct footnote *dummy = 0;
      assert( &(dummy->id)  == &(dummy->text) - 1 );
      assert( &(dummy->upc) == &(dummy->text) + 1 );

      for(i=0; i<COUNT_FOOTNOTES(notes); i++){
        const struct footnote* x = CAST_AS_FOOTNOTES(notes) + i;

        if( !x->iMark ) break;
        assert( x->nUsed );
        rndr.make.footnote_item(all_items, &x->text, x->iMark,
                 x->bRndred ? x->nUsed : 0, rndr.make.opaque);

        j = i;
      }
      if( rndr.notes.misref.nUsed ){
        rndr.make.footnote_item(all_items, 0, -1,
                    rndr.notes.misref.nUsed, rndr.make.opaque);
        g.ftntsIssues[0] += rndr.notes.misref.nUsed;
      }







>



|
>







2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
      */
      const struct footnote *dummy = 0;
      assert( &(dummy->id)  == &(dummy->text) - 1 );
      assert( &(dummy->upc) == &(dummy->text) + 1 );

      for(i=0; i<COUNT_FOOTNOTES(notes); i++){
        const struct footnote* x = CAST_AS_FOOTNOTES(notes) + i;
        const int xUsed = x->bRndred ? x->nUsed : 0;
        if( !x->iMark ) break;
        assert( x->nUsed );
        rndr.make.footnote_item(all_items, &x->text, x->iMark,
                                     xUsed, rndr.make.opaque);
        if( !xUsed ) g.ftntsIssues[3]++;  /* an overnested footnote */
        j = i;
      }
      if( rndr.notes.misref.nUsed ){
        rndr.make.footnote_item(all_items, 0, -1,
                    rndr.notes.misref.nUsed, rndr.make.opaque);
        g.ftntsIssues[0] += rndr.notes.misref.nUsed;
      }

Changes to src/style.c.

779
780
781
782
783
784
785
786

787
788

789
790
791
792
793
794
795
  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.
*/







|
>
|
|
>







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] || g.ftntsIssues[3] ){
    char buf[80];
    sprintf(&buf[0],"%i %i %i %i",g.ftntsIssues[0],g.ftntsIssues[1],
                                  g.ftntsIssues[2],g.ftntsIssues[3]);
    Th_Store("footnotes_issues_counters", buf);
  }
}

/*
** Draw the header.
*/

Changes to src/wikiformat.c.

1915
1916
1917
1918
1919
1920
1921
1922

1923
1924
1925
1926

1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
    markdown_to_html(&in, 0, &out);
    safe_html_context( bSafe ? DOCSRC_UNTRUSTED : DOCSRC_TRUSTED );
    safe_html(&out);
    blob_write_to_file(&out, "-");
    blob_reset(&in);
    blob_reset(&out);
  }
  if( bFnLint && (g.ftntsIssues[0] || g.ftntsIssues[1] || g.ftntsIssues[2])){

    fossil_fatal("There were issues with footnotes:\n"
                  " %8i misreference%s\n"
                  " %8i unreferenced\n"
                  " %8i splitted",

                  g.ftntsIssues[0], g.ftntsIssues[0]==1?"":"s",
                  g.ftntsIssues[1],
                  g.ftntsIssues[2]);
  }
}

/*
** Search for a <title>...</title> at the beginning of a wiki page.
** Return true (nonzero) if a title is found.  Return zero if there is
** not title.







|
>



|
>

|
<







1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930

1931
1932
1933
1934
1935
1936
1937
    markdown_to_html(&in, 0, &out);
    safe_html_context( bSafe ? DOCSRC_UNTRUSTED : DOCSRC_TRUSTED );
    safe_html(&out);
    blob_write_to_file(&out, "-");
    blob_reset(&in);
    blob_reset(&out);
  }
  if( bFnLint && (g.ftntsIssues[0] || g.ftntsIssues[1]
      || g.ftntsIssues[2] || g.ftntsIssues[3] )){
    fossil_fatal("There were issues with footnotes:\n"
                  " %8i misreference%s\n"
                  " %8i unreferenced\n"
                  " %8i splitted\n"
                  " %8i overnested",
                  g.ftntsIssues[0], g.ftntsIssues[0]==1?"":"s",
                  g.ftntsIssues[1], g.ftntsIssues[2], g.ftntsIssues[3]);

  }
}

/*
** Search for a <title>...</title> at the beginning of a wiki page.
** Return true (nonzero) if a title is found.  Return zero if there is
** not title.