snosov1 / toc-org

toc-org is an Emacs utility to have an up-to-date table of contents in the org files without exporting (useful primarily for readme files on GitHub)
GNU General Public License v3.0
292 stars 29 forks source link

fails to ignore pounds in markdown code fences #91

Open masukomi opened 1 year ago

masukomi commented 1 year ago

if it sees a # in a codefence it assumes that it's a heading.

CleanShot 2023-08-29 at 12 22 22@2x

(screenshot instead of text because escaping codefences in a codefence is a dark art... or something)

snosov1 commented 1 year ago

Yup, sounds lilke an issue.

In org, I believe, one should use '* to escape star signs within codeblocks.

In markdown, I don't think they have escape symbols per se. But I believe, you can workaround it by either using tabs/4 spaces to distinguish a code block (that way you can't specify the language, though).

This should be a normal header

# This shouldn't be a header

Or you could add a space before the # within a three-backticks section (toc-org, supposedly, will ignore it), like so

 # reboot

(Not sure if you can see the source of this comment)

snosov1 commented 1 year ago

The cleanest way to fix it without relying on some kind of escape mechanics is to pre-process the source to eliminate all codeblocks, but, for now, I'm not 100% sure I should do this, since both markups seem to have at least some sort of escape mechanics