fix subnotes
This commit is contained in:
parent
e7567e4d67
commit
c176d25287
24
main.js
24
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()
|
||||
|
|
Loading…
Reference in New Issue