public MdCodeElement(string[] lines, ref int index) { if (CodeBlockRegex.IsMatch(lines[index])) { var matches = CodeBlockRegex.Match(lines[index]).Groups; if (matches[2].Value.Length > 0) { codeType = matches[2].Value; } index++; for (; index < lines.Length; index++) { string line = lines[index]; if (!CodeBlockRegex.IsMatch(line)) { this.lines.Add(line); } else { break; } } } else { for (; index < lines.Length; index++) { string line = lines[index]; if (CodeBlockIndentRegex.IsMatch(line)) { if (line.Length > 4) { this.lines.Add(line.Substring(4)); } else { this.lines.Add(string.Empty); } } else { index--; break; } } } }
public MdListElement(string[] lines, ref int index) { for (; index < lines.Length; index++) { string line = lines[index]; if (!string.IsNullOrWhiteSpace(line) && !HeadRegex.IsMatch(line) && !CodeBlockRegex.IsMatch(line)) { if (ListItemRegex.IsMatch(line)) { this.lines.Add(line); } else { this.lines[this.lines.Count - 1] += ' ' + line; } } else { index--; break; } } }