File tree Expand file tree Collapse file tree
lib/render-content/plugins Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ const GithubSlugger = require('github-slugger')
22const Entities = require ( 'html-entities' ) . XmlEntities
33const toString = require ( 'hast-util-to-string' )
44const visit = require ( 'unist-util-visit' )
5+ const slugger = new GithubSlugger ( )
56const entities = new Entities ( )
67
78const matcher = node => (
@@ -14,12 +15,13 @@ module.exports = function useEnglishHeadings ({ englishHeadings }) {
1415 if ( ! englishHeadings ) return
1516 return tree => {
1617 visit ( tree , matcher , node => {
18+ slugger . reset ( )
1719 // Get the plain text content of the heading node
1820 const text = toString ( node )
1921 // find English heading in the collection
2022 const englishHeading = englishHeadings [ entities . encode ( text ) ]
2123 // get English slug
22- const englishSlug = GithubSlugger . slug ( englishHeading )
24+ const englishSlug = slugger . slug ( englishHeading )
2325 // use English slug for heading ID and link
2426 node . properties . id = englishSlug
2527 } )
You can’t perform that action at this time.
0 commit comments