Skip to content

Build your personal knowledge base with Trilium Notes

more flexible heading regex

zadamc60f25fb7c52
diff --git a/src/public/app/widgets/toc.js b/src/public/app/widgets/toc.js
index 1e9dfeb4c9..0c49d545f2 100644
--- a/src/public/app/widgets/toc.js
+++ b/src/public/app/widgets/toc.js
@@ -126,7 +126,7 @@ export default class TocWidget extends CollapsibleWidget {
getToc(html) {
// Regular expression for headings <h1>...</h1> using non-greedy
// matching and backreferences
- const headingTagsRegex = /<h(\d+)>(.*?)<\/h\1>/g;
+ const headingTagsRegex = /<h(\d+)[^>]*>(.*?)<\/h\1>/g;
// Use jquery to build the table rather than html text, since it makes
// it easier to set the onclick event that will be executed with the