fix: Title is duplicated on imported collections
This commit is contained in:
@@ -179,7 +179,6 @@ async function documentImporter({
|
||||
|
||||
let title = fileName.replace(/\.[^/.]+$/, "");
|
||||
let text = await fileInfo.getMarkdown(content);
|
||||
text = text.trim();
|
||||
|
||||
// find and extract emoji near the beginning of the document.
|
||||
const regex = emojiRegex();
|
||||
@@ -191,17 +190,18 @@ async function documentImporter({
|
||||
|
||||
// If the first line of the imported text looks like a markdown heading
|
||||
// then we can use this as the document title rather than the file name.
|
||||
if (text.startsWith("# ")) {
|
||||
if (text.trim().startsWith("# ")) {
|
||||
const result = parseTitle(text);
|
||||
title = result.title;
|
||||
text = text
|
||||
.trim()
|
||||
.replace(new RegExp(`#\\s+${escapeRegExp(title)}`), "")
|
||||
.trimStart();
|
||||
}
|
||||
|
||||
// Replace any <br> generated by the turndown plugin with escaped newlines
|
||||
// to match our hardbreak parser.
|
||||
text = text.replace(/<br>/gi, "\\n");
|
||||
text = text.trim().replace(/<br>/gi, "\\n");
|
||||
|
||||
text = await DocumentHelper.replaceImagesWithAttachments(
|
||||
text,
|
||||
|
||||
Reference in New Issue
Block a user