Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: use regex to extract text from html

thecodrra83fab17c5bc
diff --git a/packages/core/__tests__/notes.test.js b/packages/core/__tests__/notes.test.js
index 8ff43f2bf..ddabe5c4d 100644
--- a/packages/core/__tests__/notes.test.js
+++ b/packages/core/__tests__/notes.test.js
@@ -63,7 +63,7 @@ test("get all notes", () =>
test("note without a title should get title from content", () =>
noteTest().then(async ({ db, id }) => {
let note = db.notes.note(id);
- expect(note.title).toBe("HelloThis is colorful");
+ expect(note.title).toBe("Hello This is colorful");
}));
test("note should get headline from content", () =>
diff --git a/packages/core/content-types/tiny.js b/packages/core/content-types/tiny.js
index 0bf5cd364..b6646c05e 100644
--- a/packages/core/content-types/tiny.js
+++ b/packages/core/content-types/tiny.js
@@ -19,8 +19,10 @@ class Tiny {
}
toTXT() {
- const document = parseHTML(this.data);
- return document.textContent || document.body.textContent;
+ return decode(
+ this.data.replace(/<br[^>]*>/gi, "\n").replace(/<[^>]+>/g, ""),
+ { level: EntityLevel.HTML, mode: DecodingMode.Strict }
+ ).trim();
}
toMD() {
@@ -57,7 +59,6 @@ class Tiny {
async insertMedia(getData) {
let document = parseHTML(this.data);
const attachmentElements = document.querySelectorAll("img");
-
for (var i = 0; i < attachmentElements.length; ++i) {
const attachment = attachmentElements[i];
switch (attachment.tagName) {