예제 #1
0
        private bool HandleKeyword()
        {
            var start = _cs.Position;

            if (MoveToKeywordEnd())
            {
                AddToken(RdTokenType.Keyword, start, _cs.Position - start);
                SkipWhitespace();

                if (_cs.CurrentChar == '{' || _cs.CurrentChar == '[')
                {
                    var keyword     = _cs.Text.GetText(TextRange.FromBounds(start, _cs.Position)).Trim();
                    var contentType = RdBlockContentType.GetBlockContentType(keyword);

                    if (_currentContentType != contentType)
                    {
                        _currentContentType = contentType;

                        Debug.Assert(_tokens[_tokens.Count - 1].TokenType == RdTokenType.Keyword);
                        _tokens[_tokens.Count - 1].ContentTypeChange = true;
                    }

                    // Handle argument sequence like \latex[0]{foo} or \item{}{}
                    while (_cs.CurrentChar == '{' || _cs.CurrentChar == '[')
                    {
                        HandleKeywordArguments(contentType);
                    }
                }

                return(true);
            }

            return(false);
        }
예제 #2
0
        private void HandleKeywordArguments(BlockContentType contentType)
        {
            // Content type table can be found in
            // https://developer.r-project.org/parseRd.pdf

            switch (contentType)
            {
            case BlockContentType.R:
                HandleRContent();
                break;

            case BlockContentType.Verbatim:
                HandleVerbatimContent();
                break;

            default:
                HandleLatexContent(block: true);
                break;
            }
        }
예제 #3
0
 public override IReadOnlyTextRangeCollection <RdToken> Tokenize(ITextProvider textProvider, int start, int length, bool excludePartialTokens)
 {
     _currentContentType = BlockContentType.Latex;
     return(base.Tokenize(textProvider, start, length, excludePartialTokens));
 }