public bool HandleLine(MarkdownNode context, string line) { line = line.Trim(); bool isBullet; int skip; if (line.StartsWith("-")) { isBullet = true; skip = 1; } else if (line.StartsWith("#.")) { isBullet = false; skip = 2; } else { return(false); } var bulletNode = new MarkdownNode() { Type = isBullet ? MarkdownType.Bulleted : MarkdownType.Numbered, }; context.AddChild(bulletNode); AppendParsedTextTo(bulletNode, line.Substring(skip).Trim()); return(true); }
public bool HandleLine(MarkdownNode context, string line) { line = line.Trim(); var headingTag = GetHeadingTag(line); if (headingTag == null) { return(false); } MarkdownType type; switch (headingTag) { case "#": type = MarkdownType.Heading1; break; case "##": type = MarkdownType.Heading2; break; case "###": type = MarkdownType.Heading3; break; default: return(false); } string headingText = line.Substring(headingTag.Length).Trim(); var node = new MarkdownNode() { Type = type, Text = headingText }; context.AddChild(node); return(true); }
public bool HandleLine(MarkdownNode context, string line) { line = line.Trim(); var para = new MarkdownNode() { Type = MarkdownType.Paragraph }; context.AddChild(para); AppendParsedTextTo(para, line); return(true); }