July 2019
Intermediate to advanced
416 pages
10h 6m
English
The last class that we are going to write is used to take the text that the user is typing in and split it into individual lines, and create our ParseElement, chain-of-responsibility handlers, and MarkdownDocument instance. Each line is then forwarded to Header1ChainHandler to start the processing of the line. Finally, we get the text from the document and return it so that we can display it in the label:
class Markdown { public ToHtml(text : string) : string { let document : IMarkdownDocument = new MarkdownDocument(); let header1 : Header1ChainHandler = new ChainOfResponsibilityFactory().Build(document); let lines : string[] = text.split(`\n`); for (let index = 0; index < lines.length; index++) { let parseElement ...Read now
Unlock full access