TOC html

From Redazione
Jump to navigation Jump to search
Line 1: Line 1:
 
 
  
 
<html>
 
<html>
Line 61: Line 59:
  
  
function walk_through_TOC(children,depth) {
+
function walk_through_TOC(children,parent,depth) {
 
depth++
 
depth++
  
Line 71: Line 69:
  
 
if(value.path) {
 
if(value.path) {
wiki_list.push('#'.repeat(depth) + '[[' + value.path + '|' + value.text + ']]')
+
var repeat = depth
 +
if(parent && !parent.path && parent.text == value.path) {
 +
repeat--;
 +
}
 +
wiki_list.push('#'.repeat(repeat) + '[[' + value.path + '|' + value.text + ']]')
 
}
 
}
  
 
 
 
if(value.children) {
 
if(value.children) {
walk_through_TOC(value.children,depth);
+
walk_through_TOC(value.children,value,depth);
 
}
 
}
 
 
Line 129: Line 131:
 
console.log(index_obj_saved)
 
console.log(index_obj_saved)
  
walk_through_TOC(index_obj_saved,0)
+
walk_through_TOC(index_obj_saved,null,0)
  
 
console.log(wiki_list)
 
console.log(wiki_list)

Revision as of 17:32, 16 July 2020

tree placeholder