MacDownApp / MacDownApp/macdown

Commented headings are erroneously included in the [toc]

Open
#980 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rich Text Format
Stars
9.8k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Hi,

the parser erroneously includes hidden headings in the [toc], which causes the [toc] to contain the wrong headings (i.e. hidden headings).

Also the links in the [toc] refer to the wrong section (e.g. a link to #toc_2 is generated, but the generated markup only contains anchors up to #toc_1)

Input:
```markdown
[toc]

# Heading 1
This is some text

# Heading 2
This is some text
```

Expected output:
```html

Heading 1

This is some text

Heading 2

This is some text


```

Actual output:
```html

Heading 1

This is some text

Heading 2

This is some text


```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue in MacDown with the provided Markdown input, then trace the Markdown parser and [toc] generation entry point to see how commented headings are counted. Done means the commented heading is absent from the table of contents and the remaining links use matching anchors such as #toc_0 and #toc_1.

Written by the indexing model from the issue text.

Assessment

Tech stack
markdown
Domain
content
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.