From fdae403970d85751a3101c5e072eb463a79d8d6d Mon Sep 17 00:00:00 2001 From: Jeff Andersen Date: Sun, 30 Mar 2025 13:01:48 -0700 Subject: [PATCH] Allow underscores in section header identifiers This allows TOCs generated with other tools (like https://github.com/derlin/bitdowntoc) to be compatible with the rendered output. As-is, these TOC generators render section links with underscores, which are currently broken. --- extension.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension.js b/extension.js index e0e28a2..209d60b 100644 --- a/extension.js +++ b/extension.js @@ -304,7 +304,7 @@ function Slug(string) { string.trim() .toLowerCase() .replace(/\s+/g, '-') // Replace whitespace with - - .replace(/[\]\[\!\'\#\$\%\&\(\)\*\+\,\.\/\:\;\<\=\>\?\@\\\^\_\{\|\}\~\`。,、;:?!…—·ˉ¨‘’“”々~‖∶"'`|〃〔〕〈〉《》「」『』.〖〗【】()[]{}]/g, '') // Remove known punctuators + .replace(/[\]\[\!\'\#\$\%\&\(\)\*\+\,\.\/\:\;\<\=\>\?\@\\\^\{\|\}\~\`。,、;:?!…—·ˉ¨‘’“”々~‖∶"'`|〃〔〕〈〉《》「」『』.〖〗【】()[]{}]/g, '') // Remove known punctuators .replace(/^\-+/, '') // Remove leading - .replace(/\-+$/, '') // Remove trailing - );