Exemple #1
0
        private StringBuffer RenderLinkNormalLink(IMarkdownRenderer render, MarkdownLinkInlineToken token, MarkdownInlineContext context)
        {
            StringBuffer content = StringBuffer.Empty;

            content += "[";
            foreach (var t in token.Content)
            {
                content += render.Render(t);
            }
            content += "](";
            content += StringHelper.EscapeMarkdownHref(token.Href);
            if (!string.IsNullOrEmpty(token.Title))
            {
                content += " \"";
                if (render.Options.LegacyMode)
                {
                    content += StringHelper.LegacyEscapeMarkdown(token.Title);
                }
                else
                {
                    content += StringHelper.EscapeMarkdown(token.Title);
                }
                content += "\"";
            }
            content += ")";
            return(content);
        }
Exemple #2
0
        private StringBuffer RenderRefLink(IMarkdownRenderer render, IMarkdownToken token, MarkdownInlineContext context)
        {
            StringBuffer content = StringBuffer.Empty;

            if (token is MarkdownImageInlineToken)
            {
                var realToken = token as MarkdownImageInlineToken;
                content += "![";
                if (render.Options.LegacyMode)
                {
                    content += StringHelper.LegacyEscapeMarkdown(realToken.Text);
                }
                else
                {
                    content += StringHelper.EscapeMarkdown(realToken.Text);
                }
                content += "][";
                content += realToken.RefId;
                content += "]";
            }
            else if (token is MarkdownLinkInlineToken)
            {
                var realToken = token as MarkdownLinkInlineToken;
                content += "[";
                foreach (var t in realToken.Content)
                {
                    content += render.Render(t);
                }
                content += "][";
                content += realToken.RefId;
                content += "]";
            }
            else
            {
                throw new NotSupportedException("Reference link token should be either link token or image token");
            }

            return(content);
        }