diff --git a/broker.ts b/broker.ts
index 2b63f2f..0a74069 100644
--- a/broker.ts
+++ b/broker.ts
@@ -77,12 +77,11 @@ function html(inputText: string): string {
return htmlOutput;
}
-//function parse(input: string): string {
function parse(input: string): Node {
console.log("Parse input text");
- const root: Node = { type: "Root"}; //, child: {}
+ const root: Node = { type: "Root"};
var currentNode: Node = root;
const lines = input.split("\n");
@@ -93,52 +92,40 @@ function parse(input: string): Node {
currentNode.child = hexagram;
currentNode = hexagram;
currentNode.value = "
" + line + "
"; //TODO: formattierung
- }
- if (line.startsWith("Judgement")) {
+ } else if (line.startsWith("Judgement")) {
const judgement: Node = { type: "Judgement"};
currentNode.child = judgement;
currentNode = judgement;
- currentNode.value = "" + line + "
"; //TODO: formattierung
- }
- if (line.startsWith("Images")) {
+ currentNode.value = "" + line + "
";
+ } else if (line.startsWith("Images")) {
const images: Node = { type: "Images"};
currentNode.child = images;
currentNode = images;
- currentNode.value = "" + line + "
"; //TODO: formattierung
- }
- //if (line.startsWith("changingLines") && currentNode.type != "ChangingLines") {
- if (line.startsWith("~") && currentNode.type != "ChangingLines") {
+ currentNode.value = "" + line + "
";
+ } else if (line.startsWith("~") && currentNode.type != "ChangingLines") {
const changingLines: Node = { type: "ChangingLines"};
currentNode.child = changingLines;
currentNode = changingLines;
currentNode.value = line + "
"; //TODO: formattierung
- }
- else {
- //currentNode.value?.concat(line + "
");
+ } else {
currentNode.value = currentNode.value + line + "
";
- console.log("currentNode.value: " + currentNode.value);
+ //console.log("currentNode.value: " + currentNode.value); //TODO: zu viel Info!!!
}
}
- // Bearbeite jede Zeile
- //const processedLines = lines.map(line => processLine(line));
- //processedLines.join("\n");
-
return root;
}
function render(node: Node): string {
- //if (typeof node.type == "undefined") {
- //if (node.type == undefined) {
if (node == undefined) {
console.log("...finished...")
return "";
}
- console.log("Render node 3 " + node.type);
+ console.log("Render node" + node.type);
var outputHTML: string = "";
@@ -149,12 +136,17 @@ function render(node: Node): string {
case "Root":
return render(node.child!);
//case "Hexagram":
- default:
- outputHTML = "" + node.value + "
";
- //outputHTML.concat(render(node.child!));
+ case "ChangingLines" :
+ outputHTML = "" + node.value + "
";
outputHTML = outputHTML + render(node.child!);
- console.log(" " + node.type + " - outputHTML: " + outputHTML);
+ return outputHTML;
+
+ default:
+ outputHTML = "" + node.value + "
";
+ outputHTML = outputHTML + render(node.child!);
+
+ //console.log(" " + node.type + " - outputHTML: " + outputHTML); //TODO: zu viel Info!!!
return outputHTML;