本文整理汇总了C#中MarkdownDeep.Markdown.ProcessBlocks方法的典型用法代码示例。如果您正苦于以下问题:C# MarkdownDeep.Markdown.ProcessBlocks方法的具体用法?C# MarkdownDeep.Markdown.ProcessBlocks怎么用?C# MarkdownDeep.Markdown.ProcessBlocks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MarkdownDeep.Markdown
的用法示例。
在下文中一共展示了MarkdownDeep.Markdown.ProcessBlocks方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SplitUserSections
// Split the markdown into sections, one section for each
// top level heading
public static List<string> SplitUserSections(string markdown)
{
// Build blocks
var md = new MarkdownDeep.Markdown();
md.UserBreaks = true;
// Process blocks
var blocks = md.ProcessBlocks(markdown);
// Create sections
var Sections = new List<string>();
int iPrevSectionOffset = 0;
for (int i = 0; i < blocks.Count; i++)
{
var b = blocks[i];
if (b.blockType==BlockType.user_break)
{
// Get the offset of the section
int iSectionOffset = b.lineStart;
// Add section
Sections.Add(markdown.Substring(iPrevSectionOffset, iSectionOffset - iPrevSectionOffset).Trim());
// Next section starts on next line
if (i + 1 < blocks.Count)
{
iPrevSectionOffset = blocks[i + 1].lineStart;
if (iPrevSectionOffset==0)
iPrevSectionOffset = blocks[i + 1].contentStart;
}
else
iPrevSectionOffset = markdown.Length;
}
}
// Add the last section
if (markdown.Length > iPrevSectionOffset)
{
Sections.Add(markdown.Substring(iPrevSectionOffset).Trim());
}
return Sections;
}
示例2: SplitSections
// Split the markdown into sections, one section for each
// top level heading
public static List<string> SplitSections(string markdown)
{
// Build blocks
var md = new MarkdownDeep.Markdown();
// Process blocks
var blocks = md.ProcessBlocks(markdown);
// Create sections
var Sections = new List<string>();
int iPrevSectionOffset = 0;
for (int i = 0; i < blocks.Count; i++)
{
var b = blocks[i];
if (md.IsSectionHeader(b))
{
// Get the offset of the section
int iSectionOffset = b.lineStart;
// Add section
Sections.Add(markdown.Substring(iPrevSectionOffset, iSectionOffset - iPrevSectionOffset));
iPrevSectionOffset = iSectionOffset;
}
}
// Add the last section
if (markdown.Length > iPrevSectionOffset)
{
Sections.Add(markdown.Substring(iPrevSectionOffset));
}
return Sections;
}