diff --git a/src/services/export/zip.js b/src/services/export/zip.js index c58afca9f..1bc73f768 100644 --- a/src/services/export/zip.js +++ b/src/services/export/zip.js @@ -248,6 +248,7 @@ async function exportToZip(taskContext, branch, format, res, setHeaders = true) if (noteMeta.format === 'html') { if (!content.substr(0, 100).toLowerCase().includes(" element will make sure external links are openable - https://github.com/zadam/trilium/issues/1289#issuecomment-704066809 content = ` @@ -256,10 +257,11 @@ async function exportToZip(taskContext, branch, format, res, setHeaders = true) + ${htmlTitle}
-

${utils.escapeHtml(title)}

+

${htmlTitle}

${content}
@@ -415,7 +417,7 @@ ${markdownContent}`; const rootMeta = getNoteMeta(branch, { notePath: [] }, existingFileNames); const metaFile = { - formatVersion: 1, + formatVersion: 2, appVersion: packageInfo.version, files: [ rootMeta ] }; diff --git a/src/services/import/zip.js b/src/services/import/zip.js index abe3b58a9..74a942113 100644 --- a/src/services/import/zip.js +++ b/src/services/import/zip.js @@ -240,6 +240,8 @@ async function importZip(taskContext, fileBuffer, importRootNote) { return /^(?:[a-z]+:)?\/\//i.test(url); } + content = removeTrilumTags(content); + content = content.replace(/

([^<]*)<\/h1>/gi, (match, text) => { if (noteTitle.trim() === text.trim()) { return ""; // remove whole H1 tag @@ -325,6 +327,18 @@ async function importZip(taskContext, fileBuffer, importRootNote) { return content; } + function removeTrilumTags(content) { + const tagsToRemove = [ + '

([^<]*)<\/h1>', + '([^<]*)<\/title>' + ] + for (const tag of tagsToRemove) { + let re = new RegExp(tag, "gi"); + content = content.replace(re, ''); + } + return content; + } + function processNoteContent(noteMeta, type, mime, content, noteTitle, filePath) { if (noteMeta?.format === 'markdown' || (!noteMeta && taskContext.data.textImportedAsText && ['text/markdown', 'text/x-markdown'].includes(mime))) {