DannyBen / madness

Instant Markdown Server
https://madness.dannyb.co
MIT License
125 stars 17 forks source link

TOC generation (1.1.4) looks inside code blocks #173

Closed franzinc closed 5 months ago

franzinc commented 5 months ago

This

<!-- TOC -->

## All Demo Related Services

AG
......make the following 3 lines a code block
### foo
### bar
### baz

Adds bogus entries for the headings inside the code block to the TOC, which my link checker flags as bad links.

DannyBen commented 5 months ago

Confirmed bug. I did not expect code blocks to have strings that look like markdown headers.

The TOC generation is a simple parser. The problem is here: https://github.com/DannyBen/madness/blob/c333a0179fad34070df6dbc07c45898a9f5ca373/lib/madness/markdown_document.rb#L90

Possible solutions:

  1. Identify code blocks during the parsing loop and skip them
  2. Switch from line-by-line parsing, to working directly with a markdown object
DannyBen commented 5 months ago

This is also fixed in master now. If you can confirm the two fixes, I can release shortly after.

DannyBen commented 5 months ago

Version 1.2.0 is now released with this fix. Thanks for the report.

franzinc commented 4 months ago

Version 1.2.0 is now released with this fix. Thanks for the report.

Fix works. Thank you!