md4c icon indicating copy to clipboard operation
md4c copied to clipboard

Heading auto identifier

Open chowette opened this issue 3 years ago • 1 comments

This PR implement an extension when generating heading. This make possible to link directly to heading. Github, Pandoc and other Markdown libs provide this feature.

Because this is an extension, there is a flag and a command line switch to enable it. MD_FLAG_HEADINGAUTOID and corresponding --fheading-auto-id are added

This PR is a work in progress and the tasks remaining are:

  • [x] identifier generation in HTML

  • [x] identifier transformation like github

    • [x] space changed to -
    • [x] uppercase to lower case
    • [x] Unicode upper case to lower case ΑΓΩ -> αγω
    • [x] identical heading have ending number starting with -1
    • [x] links and footnote are skipped
    • [x] Emojis are treated as ponctuation, Unicode emoji are stripped
  • [ ] identifier transformation like Pandoc

    • [ ] space changed to -
    • [ ] leave _and ., but do not add additional - for surrounding space
    • [ ] uppercase to lower case
    • [ ] Unicode upper case to lower case ΑΓΩ -> αγω
    • [ ] leading chapter numbers are skipped
    • [ ] identical heading have ending number starting with -1
    • [ ] links and footnote are skipped
    • [ ] empty identifier are replaced by section
  • [x] add a Table of Content

    • [x] store heading title and level
    • [ ] numbering (eg: 1.2.3)
    • [x] tag for TOC placement in document
      • [x] [[_TOC_]] like RedCarpet Markdown
      • [x] {:toc} like Kramdown Markdown
      • [x] [toc] like Typora Markdown

Add TOC option to the parser parameter struct for md_parse() and md_html()

  • Increase the abi_version to 1
  • add --table-of-content[=MARK] and --toc[=MARK] option to md2html
  • add --toc-depth=x to limit TOC levels

chowette avatar Apr 12 '22 21:04 chowette

Codecov Report

Merging #175 (a41ab75) into master (e9ff661) will increase coverage by 0.04%. The diff coverage is 92.70%.

@@            Coverage Diff             @@
##           master     #175      +/-   ##
==========================================
+ Coverage   94.32%   94.36%   +0.04%     
==========================================
  Files           3        3              
  Lines        3100     3496     +396     
==========================================
+ Hits         2924     3299     +375     
- Misses        176      197      +21     
Impacted Files Coverage Δ
src/md4c.c 94.27% <92.53%> (+0.04%) :arrow_up:
src/md4c-html.c 95.36% <100.00%> (+0.16%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov[bot] avatar Apr 23 '22 18:04 codecov[bot]