fix subnotes

This commit is contained in:
quenousimporte 2024-02-15 08:41:25 +01:00
parent e7567e4d67
commit c176d25287
1 changed files with 11 additions and 13 deletions

24
main.js
View File

@ -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()