本文整理汇总了C#中MarkdownDeep.Markdown.GetLinkDefinition方法的典型用法代码示例。如果您正苦于以下问题:C# Markdown.GetLinkDefinition方法的具体用法?C# Markdown.GetLinkDefinition怎么用?C# Markdown.GetLinkDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MarkdownDeep.Markdown
的用法示例。
在下文中一共展示了Markdown.GetLinkDefinition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FormatCodePrettyPrint
public static string FormatCodePrettyPrint(Markdown m, string code)
{
var match = rxExtractLanguage.Match(code);
string language = null;
if (match.Success)
{
// Save the language
var g=(Group)match.Groups[2];
language = g.ToString();
// Remove the first line
code = code.Substring(match.Groups[1].Length);
}
if (language == null)
{
var d = m.GetLinkDefinition("default_syntax");
if (d!=null)
language = d.title;
}
if (language == "C#")
language = "csharp";
if (language == "C++")
language = "cpp";
if (string.IsNullOrEmpty(language))
return string.Format("<pre><code>{0}</code></pre>\n", code);
else
return string.Format("<pre class=\"prettyprint lang-{0}\"><code>{1}</code></pre>\n", language.ToLowerInvariant(), code);
}
示例2: FormatCodeBlock
private static string FormatCodeBlock(Markdown markdown, string code)
{
// Try to extract the language from the first line
var match = rxExtractLanguage.Match(code);
string language = null;
if (match.Success)
{
// Save the language
var g = match.Groups[2];
language = g.ToString();
// Remove the first line
code = code.Substring(match.Groups[1].Length);
}
// If not specified, look for a link definition called "default_syntax" and
// grab the language from its title
if (language == null)
{
var d = markdown.GetLinkDefinition("default_syntax");
if (d != null)
{
language = d.title;
}
}
// Common replacements
if (language == "C#")
{
language = "csharp";
}
if (language == "C++")
{
language = "cpp";
}
if (string.IsNullOrWhiteSpace(language))
{
language = "csharp";
}
// Wrap code in pre/code tags and add PrettyPrint attributes if necessary
return string.Format("<pre class=\"brush: {0};toolbar: false;\">{1}</pre>\n", language, code);
}