Skip to content

Commit

Permalink
fix(markdown): html ids in markdown headings should not start with a …
Browse files Browse the repository at this point in the history
…digit (#1961)
  • Loading branch information
electrolinux committed Mar 21, 2023
1 parent 38f76c6 commit 884f5d8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/runtime/markdown-parser/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ export default function (this: any, _options: MarkdownOptions) {
}

// Remove double dashes and trailing dash from heading ids
// Insert underscore if id start with a digit
if (node.tagName?.startsWith('h') && node.properties.id) {
node.properties.id = node.properties.id
.replace(/-+/g, '-')
.replace(/-$/, '')
.replace(/^-/, '')
.replace(/^(\d)/, '_$1')
}

/**
Expand Down

0 comments on commit 884f5d8

Please sign in to comment.