mirror of
https://github.com/zadam/trilium.git
synced 2025-11-17 18:50:41 +01:00
refactor(import/zip): extract method and test it
This commit is contained in:
@@ -385,15 +385,6 @@ async function importZip(taskContext: TaskContext, fileBuffer: Buffer, importRoo
|
||||
return content;
|
||||
}
|
||||
|
||||
function removeTriliumTags(content: string) {
|
||||
const tagsToRemove = ["<h1 data-trilium-h1>([^<]*)<\/h1>", "<title data-trilium-title>([^<]*)<\/title>"];
|
||||
for (const tag of tagsToRemove) {
|
||||
let re = new RegExp(tag, "gi");
|
||||
content = content.replace(re, "");
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
function processNoteContent(noteMeta: NoteMeta | undefined, type: string, mime: string, content: string | Buffer, noteTitle: string, filePath: string) {
|
||||
if ((noteMeta?.format === "markdown" || (!noteMeta && taskContext.data?.textImportedAsText && ["text/markdown", "text/x-markdown", "text/mdx"].includes(mime))) && typeof content === "string") {
|
||||
content = markdownService.renderToHtml(content, noteTitle);
|
||||
@@ -665,6 +656,17 @@ function resolveNoteType(type: string | undefined): NoteType {
|
||||
}
|
||||
}
|
||||
|
||||
export function removeTriliumTags(content: string) {
|
||||
const tagsToRemove = [
|
||||
"<h1 data-trilium-h1>([^<]*)<\/h1>",
|
||||
"<title data-trilium-title>([^<]*)<\/title>"];
|
||||
for (const tag of tagsToRemove) {
|
||||
let re = new RegExp(tag, "gi");
|
||||
content = content.replace(re, "");
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
export default {
|
||||
importZip
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user