Beispiel #1
0
        public static string GetText(RdParseContext context)
        {
            var text = string.Empty;

            if (RdParseUtility.GetKeywordArgumentBounds(context.Tokens, out var startTokenIndex, out var endTokenIndex))
            {
                text = RdText.FromTokens(context, startTokenIndex, endTokenIndex);
                context.Tokens.Position = endTokenIndex;
            }

            text = text.Trim();
            var index = text.IndexOf(@"\href", StringComparison.Ordinal);

            if (index >= 0)
            {
                var openCurlyIndex  = text.IndexOf('{', index);
                var closeCurlyIndex = text.LastIndexOf('}', openCurlyIndex);
                openCurlyIndex  = text.IndexOf('{', closeCurlyIndex);
                closeCurlyIndex = text.LastIndexOf('}', openCurlyIndex);
                if (openCurlyIndex >= 0 && closeCurlyIndex >= 0 && openCurlyIndex < closeCurlyIndex)
                {
                    var name = text.Substring(openCurlyIndex + 1, closeCurlyIndex - openCurlyIndex - 1);
                    text = text.Substring(0, index) + name + text.Substring(closeCurlyIndex + 1);
                }
            }
            return(text);
        }
Beispiel #2
0
        public static string GetText(RdParseContext context)
        {
            string text = string.Empty;

            int startTokenIndex, endTokenIndex;

            if (RdParseUtility.GetKeywordArgumentBounds(context.Tokens, out startTokenIndex, out endTokenIndex))
            {
                text = RdText.FromTokens(context, startTokenIndex, endTokenIndex);
                context.Tokens.Position = endTokenIndex;
            }

            return(text.Trim());
        }