mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
remove H1 from the text during import if it matches note title
This commit is contained in:
parent
fe6f19e611
commit
a5e38165ef
@ -273,6 +273,8 @@ async function importTar(importContext, fileBuffer, importRootNote) {
|
|||||||
content = mdWriter.render(parsed);
|
content = mdWriter.render(parsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const noteTitle = getNoteTitle(filePath, noteMeta);
|
||||||
|
|
||||||
if (type === 'text') {
|
if (type === 'text') {
|
||||||
function isUrlAbsolute(url) {
|
function isUrlAbsolute(url) {
|
||||||
return /^(?:[a-z]+:)?\/\//i.test(url);
|
return /^(?:[a-z]+:)?\/\//i.test(url);
|
||||||
@ -301,6 +303,15 @@ async function importTar(importContext, fileBuffer, importRootNote) {
|
|||||||
|
|
||||||
return `href="#root/${targetNoteId}"`;
|
return `href="#root/${targetNoteId}"`;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
content = content.replace(/<h1>([^<]*)<\/h1>/g, (match, text) => {
|
||||||
|
if (noteTitle.trim() === text.trim()) {
|
||||||
|
return ""; // remove whole H1 tag
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'relation-map' && noteMeta) {
|
if (type === 'relation-map' && noteMeta) {
|
||||||
@ -320,8 +331,6 @@ async function importTar(importContext, fileBuffer, importRootNote) {
|
|||||||
await note.setContent(content);
|
await note.setContent(content);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const noteTitle = getNoteTitle(filePath, noteMeta);
|
|
||||||
|
|
||||||
({note} = await noteService.createNote(parentNoteId, noteTitle, content, {
|
({note} = await noteService.createNote(parentNoteId, noteTitle, content, {
|
||||||
noteId,
|
noteId,
|
||||||
type,
|
type,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user