Browse Source

fix: issue with Custom Header IDs (#4527)

Fix the issue described in discussion #3502 regarding header links and TOC failing to properly generate when header ID is custom defined.
pull/4546/head
broxen 3 years ago
committed by GitHub
parent
commit
db73b650c9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions
  1. 5
      server/modules/rendering/html-core/renderer.js

5
server/modules/rendering/html-core/renderer.js

@ -201,10 +201,11 @@ module.exports = {
let headers = []
$('h1,h2,h3,h4,h5,h6').each((i, elm) => {
let headerSlug = uslug($(elm).text())
// -> If custom ID is defined, try to use that instead
if ($(elm).attr('id')) {
return
headerSlug = $(elm).attr('id')
}
let headerSlug = uslug($(elm).text())
// -> Cannot start with a number (CSS selector limitation)
if (headerSlug.match(/^\d/)) {

Loading…
Cancel
Save