hackmdio / hackmdio/hackmd-io-issues
[TOC] includes headings inside list items (e.g. `- ### Case1`) in the table of contents
- Dominant language
- No language data
- Stars
- 40
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
### Is this a hackmd.io issue?
- [x] Yes, the bug happens on https://hackmd.io
- [ ] No. If it's a self-hosted CodiMD instance, please fire up the issue in the repo of CodiMD: https://github.com/hackmdio/codimd
### Read our Official tutorial
It's on https://hackmd.io/c/tutorials/
or Chinese version: https://hackmd.io/c/tutorials-tw/
### What's the problem
#### Current behaviour
When using `[TOC]`, headings written inside list items are also included in the table of contents.
Reproducible content:
```md
[TOC]
### Section
- ### Case1
- ### Case2
- ### Case3
````
Actual rendered TOC result:
```md
- Section
- Case1
- Case2
- Case3
```
Provide steps to reproduce:
1. Go to [https://hackmd.io](https://hackmd.io)
2. Create a new note
3. Paste the content below:
```md
[TOC]
### Section
- ### Case1
- ### Case2
- ### Case3
```
4. Switch to preview / rendered view
5. Observe that `Case1`, `Case2`, and `Case3` are also included in TOC
> Here is an example: https://hackmd.io/mhkr3m9WR4Kse_ePoV_c6w
> (This never happened before.)
#### Expected behaviour
I would expect only the main section heading to appear in the table of contents:
```md
- Section
```
Headings inside list items such as `- ### Case1` should ideally not be included in TOC, or this behavior should be clearly documented if it is intended.
#### Environment
I use HackMD on:
**Desktop**
* OS: Windows / Ubuntu 24.04 / Android 14
* Browser: Chrome 147.0.7727.56 , FireFox 143.0(64 位元)
**Mobile**
* Device: Xiaomi Pro 13
* OS: Android 14
* Browser: Chrome 146.0.7880.177
#### Additional context
This may be intended Markdown parsing behavior, but from a TOC usability perspective it is surprising and can pollute the generated table of contents.
If this is expected behavior, documentation clarification would be helpful.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.