当前位置: 首页>>代码示例>>C#>>正文


C# Markdown.OnPrepareLink方法代码示例

本文整理汇总了C#中MarkdownDeep.Markdown.OnPrepareLink方法的典型用法代码示例。如果您正苦于以下问题:C# Markdown.OnPrepareLink方法的具体用法?C# Markdown.OnPrepareLink怎么用?C# Markdown.OnPrepareLink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MarkdownDeep.Markdown的用法示例。


在下文中一共展示了Markdown.OnPrepareLink方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenderLink

		internal void RenderLink(Markdown m, StringBuilder b, string link_text)
		{
			if (url.StartsWith("mailto:"))
			{
				b.Append("<a href=\"");
				Utils.HtmlRandomize(b, url);
				b.Append('\"');
				if (!String.IsNullOrEmpty(title))
				{
					b.Append(" title=\"");
					Utils.SmartHtmlEncodeAmpsAndAngles(b, title);
					b.Append('\"');
				}
				b.Append('>');
				Utils.HtmlRandomize(b, link_text);
				b.Append("</a>");
			}
			else
			{
				HtmlTag tag = new HtmlTag("a");

				// encode url
				StringBuilder sb = m.GetStringBuilder();
				Utils.SmartHtmlEncodeAmpsAndAngles(sb, url);
				tag.attributes["href"] = sb.ToString();

				// encode title
				if (!String.IsNullOrEmpty(title ))
				{
					sb.Length = 0;
					Utils.SmartHtmlEncodeAmpsAndAngles(sb, title);
					tag.attributes["title"] = sb.ToString();
				}

				// Do user processing
				m.OnPrepareLink(tag);

				// Render the opening tag
				tag.RenderOpening(b);

				b.Append(link_text);	  // Link text already escaped by SpanFormatter
				b.Append("</a>");
			}
		}
开发者ID:CLupica,项目名称:ServiceStack,代码行数:44,代码来源:LinkDefinition.cs

示例2: Render


//.........这里部分代码省略.........
                            else
                            {
                                b.AppendFormat("<pre><code class=\"{0}\">", dataArgument);
                            }
                        }
                        else
                        {
                            b.Append("<pre><code>");
                        }
                        foreach(var line in children)
                        {
                            m.HtmlEncodeAndConvertTabsToSpaces(b, line.buf, line.contentStart, line.contentLen);
                            b.Append("\n");
                        }
                        b.Append(tagSuffix);
                    }
                    else
                    {
                        var sb = new StringBuilder();
                        foreach(var line in children)
                        {
                            m.HtmlEncodeAndConvertTabsToSpaces(sb, line.buf, line.contentStart, line.contentLen);
                            sb.Append("\n");
                        }
                        b.Append(m.FormatCodeBlock(m, sb.ToString()));
                    }
                    return;

                case BlockType.quote:
                    b.Append("<blockquote>\n");
                    RenderChildren(m, b);
                    b.Append("</blockquote>\n");
                    return;

                case BlockType.li:
                    b.Append("<li>\n");
                    RenderChildren(m, b);
                    b.Append("</li>\n");
                    return;

                case BlockType.ol:
                    b.Append("<ol>\n");
                    RenderChildren(m, b);
                    b.Append("</ol>\n");
                    return;

                case BlockType.ul:
                    b.Append("<ul>\n");
                    RenderChildren(m, b);
                    b.Append("</ul>\n");
                    return;

                case BlockType.HtmlTag:
                    var tag = (HtmlTag)data;

                    // Prepare special tags
                    var name=tag.name.ToLowerInvariant();
                    if (name == "a")
                    {
                        m.OnPrepareLink(tag);
                    }
                    else if (name == "img")
                    {
                        m.OnPrepareImage(tag, m.RenderingTitledImage);
                    }

                    tag.RenderOpening(b);
                    b.Append("\n");
                    RenderChildren(m, b);
                    tag.RenderClosing(b);
                    b.Append("\n");
                    return;

                case BlockType.Composite:
                case BlockType.footnote:
                    RenderChildren(m, b);
                    return;

                case BlockType.table_spec:
                    ((TableSpec)data).Render(m, b);
                    break;

                case BlockType.p_footnote:
                    b.Append("<p>");
                    if (contentLen > 0)
                    {
                        m.SpanFormatter.Format(b, buf, contentStart, contentLen);
                        b.Append("&nbsp;");
                    }
                    b.Append((string)data);
                    b.Append("</p>\n");
                    break;

                default:
                    b.Append("<" + blockType.ToString() + ">");
                    m.SpanFormatter.Format(b, buf, contentStart, contentLen);
                    b.Append("</" + blockType.ToString() + ">\n");
                    break;
            }
        }
开发者ID:FransBouma,项目名称:markdowndeep,代码行数:101,代码来源:Block.cs

示例3: Render


//.........这里部分代码省略.........
                    }
                    else
                    {
                        b.Append("<dt>\n");
                        RenderChildren(m, b);
                        b.Append("</dt>\n");
                    }
                    break;
                }

                case BlockType.dl:
                    b.Append("<dl>\n");
                    RenderChildren(m, b);
                    b.Append("</dl>\n");
                    return;

                case BlockType.html:
                    b.Append(buf, contentStart, contentLen);
                    return;

                case BlockType.unsafe_html:
                    m.HtmlEncode(b, buf, contentStart, contentLen);
                    return;

                case BlockType.codeblock:
                    RenderCodeBlock(m, b);
                    return;

                case BlockType.quote:
                    b.Append("<blockquote>\n");
                    RenderChildren(m, b);
                    b.Append("</blockquote>\n");
                    return;

                case BlockType.li:
                    b.Append("<li>\n");
                    RenderChildren(m, b);
                    b.Append("</li>\n");
                    return;

                case BlockType.ol:
                    b.Append("<ol>\n");
                    RenderChildren(m, b);
                    b.Append("</ol>\n");
                    return;

                case BlockType.ul:
                    b.Append("<ul>\n");
                    RenderChildren(m, b);
                    b.Append("</ul>\n");
                    return;

                case BlockType.HtmlTag:
                    var tag = (HtmlTag)data;

                    // Prepare special tags
                    var name=tag.name.ToLowerInvariant();
                    if (name == "a")
                    {
                        m.OnPrepareLink(tag);
                    }
                    else if (name == "img")
                    {
                        m.OnPrepareImage(tag, m.RenderingTitledImage);
                    }

                    tag.RenderOpening(b);
                    b.Append("\n");
                    RenderChildren(m, b);
                    tag.RenderClosing(b);
                    b.Append("\n");
                    return;

                case BlockType.Composite:
                case BlockType.footnote:
                    RenderChildren(m, b);
                    return;

                case BlockType.table_spec:
                    ((TableSpec)data).Render(m, b);
                    break;

                case BlockType.p_footnote:
                    b.Append("<p>");
                    if (contentLen > 0)
                    {
                        m.SpanFormatter.Format(b, buf, contentStart, contentLen);
                        b.Append("&nbsp;");
                    }
                    b.Append((string)data);
                    b.Append("</p>\n");
                    break;

                default:
                    b.Append("<" + blockType.ToString() + ">");
                    m.SpanFormatter.Format(b, buf, contentStart, contentLen);
                    b.Append("</" + blockType.ToString() + ">\n");
                    break;
            }
        }
开发者ID:carbonrobot,项目名称:markdowndeep,代码行数:101,代码来源:Block.cs

示例4: Render


//.........这里部分代码省略.........
                            m.HtmlEncodeAndConvertTabsToSpaces(sb, line.Buf, line.ContentStart, line.ContentLen);
                            sb.Append("\n");
                        }
                        b.Append(m.FormatCodeBlockFunc(m, sb.ToString()));
                    }
                    return;

                case BlockType.quote:
                    b.Append("<blockquote>\n");
                    RenderChildren(m, b);
                    b.Append("</blockquote>\n");
                    return;

                case BlockType.li:
                    b.Append("<li>\n");
                    RenderChildren(m, b);
                    b.Append("</li>\n");
                    return;

                case BlockType.ol:
                    b.Append("<ol>\n");
                    RenderChildren(m, b);
                    b.Append("</ol>\n");
                    return;

                case BlockType.ul:
                    b.Append("<ul>\n");
                    RenderChildren(m, b);
                    b.Append("</ul>\n");
                    return;

                case BlockType.HtmlTag:
                    var tag = (HtmlTag)Data;

                    // Prepare special tags
                    var name=tag.name.ToLowerInvariant();
                    if (name == "a")
                    {
                        m.OnPrepareLink(tag);
                    }
                    else if (name == "img")
                    {
                        m.OnPrepareImage(tag, m.RenderingTitledImage);
                    }

                    tag.RenderOpening(b);
                    b.Append("\n");
                    RenderChildren(m, b);
                    tag.RenderClosing(b);
                    b.Append("\n");
                    return;

                case BlockType.Composite:
                case BlockType.footnote:
                    RenderChildren(m, b);
                    return;

                case BlockType.table_spec:
                    ((TableSpec)Data).Render(m, b);
                    break;

                case BlockType.p_footnote:
                    b.Append("<p>");
                    if (ContentLen > 0)
                    {
                        m.SpanFormatter.Format(b, Buf, ContentStart, ContentLen);
                        b.Append("&nbsp;");
                    }
                    b.Append((string)Data);
                    b.Append("</p>\n");
                    break;
            // DocNet Extensions
                case BlockType.font_awesome:
                    if(m.DocNetMode)
                    {
                        b.Append("<i class=\"fa fa-");
                        b.Append(this.Data as string ?? string.Empty);
                        b.Append("\"></i>");
                    }
                    break;
                case BlockType.alert:
                    if(m.DocNetMode)
                    {
                        RenderAlert(m, b);
                    }
                    break;
                case BlockType.tabs:
                    if(m.DocNetMode)
                    {
                        RenderTabs(m, b);
                    }
                    break;
            // End DocNet Extensions
                default:
                    b.Append("<" + BlockType.ToString() + ">");
                    m.SpanFormatter.Format(b, Buf, ContentStart, ContentLen);
                    b.Append("</" + BlockType.ToString() + ">\n");
                    break;
            }
        }
开发者ID:FransBouma,项目名称:DocNet,代码行数:101,代码来源:Block.cs


注:本文中的MarkdownDeep.Markdown.OnPrepareLink方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。