From db73b650c96fc7404531421fd3b2ab7dd4b1b374 Mon Sep 17 00:00:00 2001 From: broxen Date: Fri, 1 Oct 2021 17:22:55 -0700 Subject: [PATCH] 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. --- server/modules/rendering/html-core/renderer.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/modules/rendering/html-core/renderer.js b/server/modules/rendering/html-core/renderer.js index 6ec35a66..697c0ff4 100644 --- a/server/modules/rendering/html-core/renderer.js +++ b/server/modules/rendering/html-core/renderer.js @@ -201,10 +201,11 @@ module.exports = { let headers = [] $('h1,h2,h3,h4,h5,h6').each((i, elm) => { - if ($(elm).attr('id')) { - return - } let headerSlug = uslug($(elm).text()) + // -> If custom ID is defined, try to use that instead + if ($(elm).attr('id')) { + headerSlug = $(elm).attr('id') + } // -> Cannot start with a number (CSS selector limitation) if (headerSlug.match(/^\d/)) {