/// <summary>
        /// Called externally to render markdown to a text block.
        /// </summary>
        /// <param name="markdownTree"></param>
        public void Render(Markdown markdownTree)
        {
            // Clear anything that currently exists
            m_richTextBlock.Blocks.Clear();

            // For the root, loop through the block types and render them
            foreach (MarkdownBlock element in markdownTree.Children)
            {
                RendnerBlock(element, m_richTextBlock.Blocks);
            }
        }
        /// <summary>
        /// Parses the given markdown into an AST.
        /// </summary>
        /// <param name="markdown"></param>
        /// <returns></returns>
        protected string RenderMarkdown(string markdown)
        {
            var parser = new Markdown();
            parser.Parse(markdown);

            var richTextBlock = new RichTextBlock();
            var renderer = new RenderToRichTextBlock(richTextBlock, new DummyLinkRegister());
            renderer.Render(parser);

            var result = new StringBuilder();
            foreach (var block in richTextBlock.Blocks)
            {
                SerializeElement(result, block, indentLevel: 0);
            }
            return result.ToString();
        }
        /// <summary>
        /// Fired when the markdown is changed. 
        /// </summary>
        /// <param name="newMarkdown"></param>
        private void OnMarkdownChanged(string newMarkdown)
        {
            OnMarkdownReadyArgs args = new OnMarkdownReadyArgs();

            // Clear the current content
            CleanUpTextBlock();

            // Make sure we have something to parse.
            if (!String.IsNullOrWhiteSpace(newMarkdown))
            {
                try
                {
                    // Try to parse the markdown.
                    Markdown markdown = new Markdown();
                    markdown.Parse(newMarkdown);

                    // Now try to display it
                    RenderToRichTextBlock rendner = new RenderToRichTextBlock(ui_richTextBox, this);
                    rendner.Render(markdown);
                }
                catch (Exception e)
                {
                    DebuggingReporter.ReportCriticalError("Error while parsing and rendering: " + e.Message);
                    args.WasError = true;
                    args.Exception = e;
                }
            }

            // #todo indicate if ready
            m_onMarkdownReady.Raise(this, args);            
        }