import * as CF from '@efforting.tech/data/field-configuration-factories'; import { inspect } from 'node:util'; import { Indention_Mode, Text_Settings, string_has_contents, indented_line_iterator } from '@efforting.tech/data/string-utilities'; import { Text_Node } from '@efforting.tech/text/basic-tree'; const ts = Text_Settings.load({ indention_mode: 'TABULATORS', }); const example_string = `branch1 leaf1 leaf2 branch2 sub-branch1 leaf3 leaf4 sub-branch2 leaf5 branch3 dual-indented `; const root = Text_Node.from_string(ts, example_string); function debug_dump(node, level=0) { console.log(`${" ".repeat(level)}[${node.line_no ?? '-'}] ${inspect(node.line)}`); for (const child of node.children) { debug_dump(child, level+1); } } debug_dump(root); /* [-] undefined [1] 'branch1' [2] 'leaf1' [3] 'leaf2' [4] '' [5] 'branch2' [6] 'sub-branch1' [7] 'leaf3' [8] 'leaf4' [9] '' [10] '' [11] 'sub-branch2' [12] 'leaf5' [13] '' [14] 'branch3' [-] undefined [15] 'dual-indented' [16] '' [17] '' */