Exemple #1
0
        public override BlockState TryContinue(BlockProcessor processor, Block block)
        {
            if (processor.IsCodeIndent)
            {
                return(BlockState.None);
            }

            var quote = (QuoteBlock)block;

            // 5.1 Block quotes
            // A block quote marker consists of 0-3 spaces of initial indent, plus (a) the character > together with a following space, or (b) a single character > not followed by a space.
            var c = processor.CurrentChar;

            if (c != quote.QuoteChar)
            {
                return(processor.IsBlankLine ? BlockState.BreakDiscard : BlockState.None);
            }

            c = processor.NextChar(); // Skip opening char
            if (c.IsSpace())
            {
                processor.NextChar(); // Skip following space
            }

            block.UpdateSpanEnd(processor.Line.End);
            return(BlockState.Continue);
        }
Exemple #2
0
        public override BlockState TryOpen(BlockProcessor processor)
        {
            if (processor.IsCodeIndent)
            {
                return(BlockState.None);
            }

            var column         = processor.Column;
            var sourcePosition = processor.Start;

            // 5.1 Block quotes
            // A block quote marker consists of 0-3 spaces of initial indent, plus (a) the character > together with a following space, or (b) a single character > not followed by a space.
            var quoteChar = processor.CurrentChar;
            var c         = processor.NextChar();

            if (c.IsSpaceOrTab())
            {
                processor.NextColumn();
            }
            processor.NewBlocks.Push(new QuoteBlock(this)
            {
                QuoteChar = quoteChar,
                Column    = column,
                Span      = new SourceSpan(sourcePosition, processor.Line.End),
            });
            return(BlockState.Continue);
        }
Exemple #3
0
        public override BlockState TryContinue(BlockProcessor processor, Block block)
        {
            var result = base.TryContinue(processor, block);

            if (result == BlockState.Continue)
            {
                var fence = (FencedCodeBlock)block;
                // Remove any indent spaces
                var c           = processor.CurrentChar;
                var indentCount = fence.IndentCount;
                while (indentCount > 0 && c.IsSpace())
                {
                    indentCount--;
                    c = processor.NextChar();
                }
            }

            return(result);
        }
Exemple #4
0
        public override bool TryParse(BlockProcessor state, char pendingBulletType, out ListInfo result)
        {
            result = new ListInfo();
            var c = state.CurrentChar;

            int countDigit = 0;
            int startChar  = -1;
            int endChar    = 0;

            while (c.IsDigit())
            {
                endChar = state.Start;
                // Trim left 0
                if (startChar < 0 && c != '0')
                {
                    startChar = endChar;
                }
                c = state.NextChar();
                countDigit++;
            }
            if (startChar < 0)
            {
                startChar = endChar;
            }

            // Note that ordered list start numbers must be nine digits or less:
            char orderedDelimiter;

            if (countDigit > 9 || !TryParseDelimiter(state, out orderedDelimiter))
            {
                return(false);
            }

            result.OrderedStart        = state.Line.Text.Substring(startChar, endChar - startChar + 1);
            result.OrderedDelimiter    = orderedDelimiter;
            result.BulletType          = '1';
            result.DefaultOrderedStart = "1";
            return(true);
        }