Example #1
0
        private TokenMd HandleSquareBrackets(string text, int index, int finalIndex, out int newFinalIndex)
        {
            while (finalIndex < text.Length)
            {
                switch (text[finalIndex])
                {
                case '[':
                    symbolsCount++;
                    isFirst = false;
                    finalIndex++;
                    continue;

                case ']' when currentSymbol == "[":
                    linkText      = builder.ToString();
                    builder       = new StringBuilder();
                    currentSymbol = "]";
                    finalIndex++;
                    symbolsCount++;
                    continue;
                }

                if (currentSymbol == "[")
                {
                    builder = helper.AppendSymbol(builder, text, finalIndex, out finalIndex);
                    continue;
                }

                newFinalIndex = finalIndex;
                return(null);
            }
            newFinalIndex = finalIndex;
            return(ReturnFirstSymbolToken(index, out finalIndex));
        }
Example #2
0
        public TokenMd GetToken(string text, int index, out int finalIndex)
        {
            helper = new ParseHelper();
            mark   = new HeadMark();
            var builder = new StringBuilder();

            finalIndex = index;

            builder = helper.AppendMarkSymbols(builder, text, finalIndex, out finalIndex, mark.DefiningSymbol);

            while (!helper.IsSymbols(finalIndex, text, Environment.NewLine))
            {
                if (finalIndex >= text.Length || helper.IsSymbols(finalIndex, text, mark.AllSymbols.Last()))
                {
                    return(new TokenMd(builder.ToString(), mark));
                }
                builder = helper.AppendSymbol(builder, text, finalIndex, out finalIndex);
            }

            return(new TokenMd(builder.ToString(), mark));
        }