diff --git a/src/ts/textsynt.ts b/src/ts/textsynt.ts new file mode 100644 index 00000000..9010403e --- /dev/null +++ b/src/ts/textsynt.ts @@ -0,0 +1,33 @@ + +interface TextSyntSyntaxTree { + name: string; + children: TextSyntSyntaxTree[]; +} + +function parseMarkdownLikeYaml(text:string){ + + const lines = text.split('\n'); + const root: TextSyntSyntaxTree = {name: 'root', children: []}; + let rootHashIndentation = -1; + let currentIndentation = 0; + + for(let i = 0; i < lines.length; i++){ + const line = lines[i]; + + if(line.startsWith('#')){ + let indentations = 0; + while(line[indentations] === '#'){ + indentations++; + } + + if(currentIndentation === 0 && rootHashIndentation === -1){ + rootHashIndentation = indentations; + indentations = 1; + } + else{ + indentations -= (rootHashIndentation - 1) + } + } + + } +} \ No newline at end of file