/// <summary>
        /// Renders markdown of the current document text into raw HTML
        /// </summary>
        /// <param name="markdown">markdown to render</param>
        /// <param name="renderLinksExternal">Determines whether links have a target='top' attribute</param>
        /// <param name="usePragmaLines">renders line numbers into html output as ID tags for editor positioning</param>
        /// <returns></returns>
        public string RenderHtml(string markdown = null, bool renderLinksExternal = false, bool usePragmaLines = false)
        {
            if (string.IsNullOrEmpty(markdown))
            {
                markdown = CurrentText;
            }

            var parser = MarkdownParserFactory.GetParser(usePragmaLines: usePragmaLines,
                                                         forceLoad: true,
                                                         parserAddinId: mmApp.Configuration.MarkdownOptions.MarkdownParserName);
            var html = parser.Parse(markdown);


            if (!string.IsNullOrEmpty(html) && !UnlockKey.IsRegistered() && mmApp.Configuration.ApplicationUpdates.AccessCount > 20)
            {
                html += @"
<div style=""margin-top: 30px;margin-bottom: 10px;font-size: 0.8em;border-top: 1px solid #eee;padding-top: 8px;opacity: 0.75;""
     title=""This message doesn't display in the registered version of Markdown Monster."">
    <img src=""https://markdownmonster.west-wind.com/favicon.png""
         style=""height: 20px;float: left; margin-right: 10px;opacity: 0.75;""/>
    created with the free version of
    <a href=""https://markdownmonster.west-wind.com"" 
       target=""top"">Markdown Monster</a> 
</div>
";
            }

            return(html);
        }
        /// <summary>
        /// Renders markdown of the current document text into raw HTML
        /// </summary>
        /// <param name="markdown">markdown to render</param>
        /// <param name="renderLinksExternal">Determines whether links have a target='top' attribute</param>
        /// <param name="usePragmaLines">renders line numbers into html output as ID tags for editor positioning</param>
        /// <returns></returns>
        public string RenderHtml(string markdown = null, bool renderLinksExternal = false, bool usePragmaLines = false)
        {
            if (string.IsNullOrEmpty(markdown))
            {
                markdown = CurrentText;
            }

            var parser = MarkdownParserFactory.GetParser(renderLinksAsExternal: renderLinksExternal, usePragmaLines: usePragmaLines, forceLoad: true);

            return(parser.Parse(markdown));
        }
Example #3
0
        /// <summary>
        /// Renders markdown of the current document text into raw HTML
        /// </summary>
        /// <param name="markdown">markdown to render</param>
        /// <param name="renderLinksExternal">Determines whether links have a target='top' attribute</param>
        /// <param name="usePragmaLines">renders line numbers into html output as ID tags for editor positioning</param>
        /// <returns></returns>
        public string RenderHtml(string markdown = null, bool renderLinksExternal = false, bool usePragmaLines = false)
        {
            if (string.IsNullOrEmpty(markdown))
            {
                markdown = CurrentText;
            }

            var parser = MarkdownParserFactory.GetParser(usePragmaLines: usePragmaLines,
                                                         forceLoad: true,
                                                         addinId: mmApp.Configuration.MarkdownOptions.MarkdownParserName);

            return(parser.Parse(markdown));
        }
Example #4
0
        /// <summary>
        /// Renders markdown of the current document text into raw HTML
        /// </summary>
        /// <param name="markdown">markdown to render</param>
        /// <param name="renderLinksExternal">Determines whether links have a target='top' attribute</param>
        /// <param name="usePragmaLines">renders line numbers into html output as ID tags for editor positioning</param>
        /// <returns></returns>
        public string RenderHtml(string markdown          = null,
                                 bool renderLinksExternal = false,
                                 bool usePragmaLines      = false)
        {
            if (string.IsNullOrEmpty(markdown))
            {
                markdown = CurrentText;
            }

            if (string.IsNullOrEmpty(markdown))
            {
                return(markdown);
            }

            OnBeforeDocumentRendered(ref markdown);

            var parser = MarkdownParserFactory.GetParser(usePragmaLines: usePragmaLines,
                                                         forceLoad: true,
                                                         parserAddinId: mmApp.Configuration.MarkdownOptions.MarkdownParserName);


            if (!string.IsNullOrEmpty(PreviewWebRootPath))
            {
                var path = FileUtils.AddTrailingSlash(PreviewWebRootPath).Replace("\\", "/");
                markdown = markdown.Replace("](~/", "](" + path);
                markdown = markdown.Replace("](/", "](" + path);
            }

            // allow override of RenderScriptTags if set
            var oldAllowScripts = mmApp.Configuration.MarkdownOptions.AllowRenderScriptTags;

            if (ProcessScripts)
            {
                mmApp.Configuration.MarkdownOptions.AllowRenderScriptTags = false;
            }

            var html = parser.Parse(markdown);

            mmApp.Configuration.MarkdownOptions.AllowRenderScriptTags = oldAllowScripts;


            OnDocumentRendered(ref html, ref markdown);


            if (!string.IsNullOrEmpty(html) && !UnlockKey.IsRegistered() && mmApp.Configuration.ApplicationUpdates.AccessCount > 20)
            {
                html += @"
<div style=""margin-top: 30px;margin-bottom: 10px;font-size: 0.8em;border-top: 1px solid #eee;padding-top: 8px;cursor: pointer;""
     title=""This message doesn't display in the registered version of Markdown Monster."" onclick=""window.open('https://markdownmonster.west-wind.com')"">
    <img src=""https://markdownmonster.west-wind.com/favicon.png""
         style=""height: 20px;float: left; margin-right: 10px;""/>
    created with the free version of
    <a href=""https://markdownmonster.west-wind.com""
       target=""top"">Markdown Monster</a>
</div>
";
            }



            return(html);
        }