diff --git a/broker.ts b/broker.ts index 0a74069..88acc9d 100644 --- a/broker.ts +++ b/broker.ts @@ -16,12 +16,9 @@ exec('iching divine', (error, stdout, stderr) => { return; } - //console.log(`Ergebnis:\n${stdout}`); - console.log(`Send E-Mail`); sendEmail(stdout); - sleep(); }); @@ -40,9 +37,7 @@ async function sendEmail(content: string) { to: "Christopher.Hase@telekom.com;test@mailhog.local", subject: "Your Horoscope Is Ready", text: content, - //html: "
${content}
" html: html(content) - //html: content }); console.log("E-Mail sent: ", info.messageId); @@ -61,22 +56,22 @@ async function sleep() { }, 3600000); } -//node structure for the Parse Tree +//node structure for the Parse Tree (it's a degenerated tree with one or zero children per node) interface Node { type: "Root" | "Hexagram" | "Judgement" | "Images" | "ChangingLines" ; child?: Node; value?: string; - //level?: number; // Für Header } +//generate 1) Parse Tree and 2) HTML function html(inputText: string): string { - // Parse Tree erstellen & HTML generieren const parseTree = parse(inputText); const htmlOutput = render(parseTree); return htmlOutput; } +//generate the Parse Tree function parse(input: string): Node { console.log("Parse input text"); @@ -91,7 +86,7 @@ function parse(input: string): Node { const hexagram: Node = { type: "Hexagram"}; currentNode.child = hexagram; currentNode = hexagram; - currentNode.value = "" + node.value + "
"; + outputHTML = outputHTML + render(node.child!); + + return outputHTML; + case "ChangingLines" : outputHTML = "" + node.value + "
"; outputHTML = outputHTML + render(node.child!);