// Split the markdown into sections, one section for each // top level heading public static List <string> SplitSections(string markdown) { // Build blocks var md = new Markdown(); // Process blocks var blocks = md.ProcessBlocks(markdown); // Create sections var sections = new List <string>(); var sectionOffset = 0; foreach (var b in blocks) { if (!md.IsSectionHeader(b)) { continue; } // Get the offset of the section var iSectionOffset = b.LineStart; // Add section sections.Add(markdown.Substring(sectionOffset, iSectionOffset - sectionOffset)); sectionOffset = iSectionOffset; } // Add the last section if (markdown.Length > sectionOffset) { sections.Add(markdown.Substring(sectionOffset)); } return(sections); }
// Split the markdown into sections, one section for each // top level heading public static List <string> SplitSections(string markdown) { // Build blocks var md = new 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); }
// Split the markdown into sections, one section for each // top level heading public static List<string> SplitSections(string markdown) { // Build blocks var md = new 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; }