From a36282caf04434966145d03a03cdd289ede44d9b Mon Sep 17 00:00:00 2001 From: azivner Date: Sun, 17 Sep 2017 21:58:03 -0400 Subject: [PATCH] parsing links in html to keep references between notes in links table --- static/js/html2notecase.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/static/js/html2notecase.js b/static/js/html2notecase.js index 54ec2b2dd..0b4ee7375 100644 --- a/static/js/html2notecase.js +++ b/static/js/html2notecase.js @@ -8,6 +8,20 @@ function html2notecase(contents, note) { if (globalHtmlEnabled) { note.detail.note_text = contents; + if (!note.detail.encryption) { + const linkRegexp = /]+?href="[^"]*kapp#([A-Za-z0-9]{22})"[^>]*?>[^<]+?<\/a>/g; + let match; + + while (match = linkRegexp.exec(contents)) { + console.log("adding link for " + match[1]); + + note.links.push({ + note_id: note.detail.note_id, + target_note_id: match[1] + }); + } + } + return; }