protected override BlockParseResult <WorkerCostBlock> ParseInternal(LineBlock markdown, int startLine, bool lineStartsNewParagraph, MarkdownDocument document) { var line = markdown[startLine].Trim(); if (line.Length == 0 || line[0] != '>') { return(null); } line = line.Slice(1).TrimStart(); var list = new List <uint>(); uint currentCost = 0; while (line.Length != 0) { var end = line.IndexOfNexWhiteSpace(); if (end == -1) { end = line.Length; } var current = line.Slice(0, end).Trim(); var splitter = current.IndexOf(':'); if (splitter == -1) { return(null); } var first = current.Slice(0, splitter); var scccond = current.Slice(splitter + 1); if (!uint.TryParse(first, out var count)) { return(null); } if (!uint.TryParse(scccond, out var cost)) { return(null); } for (var i = 0; i < count; i++) { currentCost += cost; list.Add(currentCost); } line = line.Slice(end).Trim(); } if (list.Count == 0) { return(null); } var result = new WorkerCostBlock() { WorkerCosts = list.AsReadOnly() }; return(BlockParseResult.Create(result, startLine, 1)); }
protected override BlockParseResult <WorkerTextBlock> ParseInternal(LineBlock markdown, int startLine, bool lineStartsNewParagraph, MarkdownDocument document) { var line = markdown[startLine].Trim(); if (line.Length == 0 || line[0] != '>') { return(null); } line = line.Slice(2).TrimStart(); var list = new List <IEnumerable <MarkdownInline> >(); while (line.Length != 0) { var current = line; var splitter = current.IndexOf(":<"); if (splitter == -1) { return(null); } var currentEnd = current.Slice(splitter + 1).FindClosingBrace() + splitter + 1; if (currentEnd < splitter + 1) { return(null); } current = current.Slice(0, currentEnd + 1); var first = current.Slice(0, splitter); var scccond = current.Slice(splitter + 1); // remove the <> scccond = scccond.Slice(1, scccond.Length - 2); if (!uint.TryParse(first, out var count)) { return(null); } for (var i = 0; i < count; i++) { list.Add(document.ParseInlineChildren(scccond, true, true)); } line = line.Slice(current.Length).Trim(); } if (list.Count == 0) { return(null); } var result = new WorkerTextBlock() { WorkerText = list.AsReadOnly() }; return(BlockParseResult.Create(result, startLine, 1)); }