Skip to content

Commit

Permalink
Merge pull request #393 from Tencent/fix-header-anchor-id
Browse files Browse the repository at this point in the history
Fix header anchor
  • Loading branch information
jiawei686 authored Feb 17, 2023
2 parents 21a505a + d28c488 commit b0dfb53
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/hooks/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ export default class Header extends ParagraphBase {
const replaceFootNote = /~fn#([0-9]+)#/g;
anchorID = this.generateIDNoDup(headerTextRaw.replace(replaceFootNote, ''));
}
anchorID = `safe_${anchorID}`; // transform header id to avoid being sanitized
const safeAnchorID = `safe_${anchorID}`; // transform header id to avoid being sanitized
const sign = this.$engine.md5(`${level}-${processedText.sign}-${anchorID}-${dataLines}`);
const result = [
`<h${level} id="${anchorID}" data-sign="${sign}" data-lines="${dataLines}">`,
`<h${level} id="${safeAnchorID}" data-sign="${sign}" data-lines="${dataLines}">`,
this.$getAnchor(anchorID),
`${html}`,
`</h${level}>`,
Expand Down

0 comments on commit b0dfb53

Please sign in to comment.