Commit 64948d2
committed
fix: decode HTML entities before slugifying header IDs
When a markdown header contains HTML entities (e.g. `# <othertext`),
`header_id_from_text` passed the raw entity string to `_slugify` before
HTML-decoding it. The `&` and `;` were stripped as non-word characters
but the entity name letters (e.g. `lt`) were kept, silently corrupting
the generated ID (`ltothertext` instead of `othertext`).
Fix: call `html.unescape()` on the header text before slugifying so that
entity characters are resolved to their actual Unicode code points first,
then stripped (or kept) by the slug logic as any other character would be.
Closes #6491 parent ee81a6b commit 64948d2
4 files changed
Lines changed: 13 additions & 1 deletion
File tree
- lib
- test/tm-cases
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
| |||
1578 | 1579 | | |
1579 | 1580 | | |
1580 | 1581 | | |
1581 | | - | |
| 1582 | + | |
1582 | 1583 | | |
1583 | 1584 | | |
1584 | 1585 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
0 commit comments