mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-09 17:52:32 +08:00
fix(import/utils.handleH1): fix stripping of all <h1> tags that match title
now it will only strip the very first tag that if it matches the title, otherwise it gets turned into a h2 tag fixes #1016
This commit is contained in:
parent
e1c949aa10
commit
1de9bc7c6f
@ -1,10 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
function handleH1(content: string, title: string) {
|
||||
let isFirstH1Handled = false;
|
||||
|
||||
content = content.replace(/<h1[^>]*>([^<]*)<\/h1>/gi, (match, text) => {
|
||||
if (title.trim() === text.trim()) {
|
||||
if (title.trim() === text.trim() && !isFirstH1Handled) {
|
||||
isFirstH1Handled = true;
|
||||
return ""; // remove whole H1 tag
|
||||
} else {
|
||||
isFirstH1Handled = true;
|
||||
return `<h2>${text}</h2>`;
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user