From c176d252872ff4f1605e5df008d07b21f372d3ea Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Thu, 15 Feb 2024 08:41:25 +0100 Subject: [PATCH] fix subnotes --- main.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/main.js b/main.js index 9012104..9753449 100644 --- a/main.js +++ b/main.js @@ -2780,9 +2780,12 @@ function togglepreview() function withsubs() { + var currentguid = getguid(title.value); + + // probe for infinite loop try { - descendants(currentnote); + descendants(currentguid); } catch (err) { @@ -2790,29 +2793,24 @@ function withsubs() return null; } - var tempnote = - { - title: currentnote.title + " (with subnotes)", - content: md.value - }; - - var kids = children(tempnote); + var content = md.value; + var kids = children(currentguid); while (kids.length) { - kids.forEach(kid => + kids.forEach(guid => { - var kidcontent = kid.content; + var kidcontent = localStorage.getItem(guid); if (kidcontent.startsWith("---\n")) { var pos = kidcontent.indexOf("---\n", 4); kidcontent = kidcontent.substring(pos + 4); } - tempnote.content = tempnote.content.replaceAll("[[" + kid.title + "]]", kidcontent); + content = content.replaceAll("[[" + metadata[guid].title + "]]", kidcontent); }); - kids = children(tempnote); + kids = children(currentguid); } - return tempnote; + return content; } function togglepreviewwithsubs()