Inheritance: Block
        public override Block Build(int start, StringRange content, out int end)
        {
            int startOfLine = start;
            var items = new List<Item>();
            Item lastItem = null;
            bool foundItem = false;

            do
            {
                int startOfItem = content.IndexOf(' ', startOfLine) + 1;
                int endOfItem = FindEndOfItem(content, startOfItem);

                IEnumerable<Span> spans = _inlineParser.Parse(new StringRange(content, startOfItem, endOfItem));
                lastItem = new Item(
                    content,
                    startOfItem,
                    endOfItem,
                    spans);

                items.Add(lastItem);

                startOfLine = content.StartOfNextLine(endOfItem);

                if (startOfLine == -1)
                    break;

                foundItem = _expression.IsMatch(content.Document, startOfLine);
            } while (foundItem);

            // special case when content ends
            end = content.EndOfLine(lastItem.End);

            return new List(content, start, end, true, items);
        }
        public Block Build(int start, StringRange content, out int end)
        {
            int startOfLine = start;
            var items = new List<LinkDefinition>();

            do
            {
                var key = new StringRange(
                    content,
                    content.IndexOf('[', startOfLine) + 1,
                    content.IndexOf(']', startOfLine) - 1);

                var urlStart = content.IndexOf(':', key.End) + 1;

                if (content[urlStart] == ' ')
                    urlStart++;

                var url = new StringRange(
                    content,
                    urlStart,
                    content.EndOfLine(startOfLine));

                var item = new LinkDefinition(
                    content,
                    startOfLine,
                    content.EndOfLine(startOfLine),
                    key,
                    url);

                items.Add(item);
                startOfLine = content.StartOfNextLine(startOfLine);

                if (startOfLine == -1)
                    break;

            } while (_expression.IsMatch(content.Document, content.IndexOf('[', startOfLine)));

            // special case when content ends
            end = startOfLine != -1 ? content.EndOfLine(startOfLine, false) : content.End;

            return new LinkDefinitionList(content, start, end, items);
        }
Beispiel #3
0
 public Paragraph(StringRange parent, int start, int end, IEnumerable<Span> spans) : base(parent, start, end)
 {
     _spans = new List<Span>(spans);
 }