Exemple #1
0
        /// <summary>
        /// Completes the escaping of a multi-line token and stores it in the TokenState
        /// </summary>
        /// <param name="tokenState"></param>
        /// <param name="myValue"></param>
        /// <param name="chunked"></param>
        /// <returns></returns>
        public static string CaptureAndEscapeThePartialToken(this TokenState tokenState, string myValue, List <string> chunked)
        {
            if (tokenState is null || myValue is null || chunked is null)
            {
                return(string.Empty);
            }
            var first = chunked.First();

            chunked.Remove(first);

            tokenState.PartialToken += first;
            myValue += tokenState.CaptureAndEscapeToken(myValue, tokenState.PartialToken);
            tokenState.PartialToken = string.Empty;

            return(myValue);
        }
Exemple #2
0
        /// <summary>
        /// Escapes tokens between `` delimiters and stores them in the TokenState object
        /// </summary>
        /// <param name="tokenState"></param>
        /// <param name="myValue"></param>
        /// <param name="chunked"></param>
        /// <returns></returns>
        public static string CaptureAndEscapeOddIndexedChunks(this TokenState tokenState, string myValue, List <string> chunked)
        {
            if (tokenState is null || myValue is null || chunked is null)
            {
                return(string.Empty);
            }
            var chunkIndex = 0;

            foreach (var chunk in chunked)
            {
                if (chunkIndex % 2 == 0)
                {
                    myValue += chunk;
                }
                else
                {
                    myValue = tokenState.CaptureAndEscapeToken(myValue, chunk);
                }
                chunkIndex++;
            }
            return(myValue);
        }