コード例 #1
0
        public WikiTextToken(TokenType tokenType, string text, WikiTextTokenScopes scopes)
        {
            Contract.Requires(!string.IsNullOrEmpty(text));

            this.tokenType = tokenType;
            this.text      = text;
            this.scopes    = scopes;
        }
コード例 #2
0
        public WikiTextTokenDef(
            string tokenString,
            bool isRegexToken,
            WikiTextToken.TokenType tokenType,
            WikiTextTokenScopes availableInScopes,
            Func <WikiTextTokenScopes, WikiTextTokenScopes> scopeModifierFunc = null)
        {
            Contract.Requires(!String.IsNullOrEmpty(tokenString));

            if (isRegexToken)
            {
                tokenRegex = new Regex(tokenString, RegexOptions.CultureInvariant | RegexOptions.IgnoreCase | RegexOptions.Compiled);
            }
            else
            {
                this.tokenString = tokenString;
            }
            this.tokenType         = tokenType;
            this.availableInScopes = availableInScopes;
            this.scopeModifierFunc = scopeModifierFunc;
        }
コード例 #3
0
ファイル: WikiTextTokenizer.cs プロジェクト: breki/freude
        private static void AddTextTokenIfAny(
            string wikiText, ICollection <WikiTextToken> tokens, ref int?textTokenStart, int index, WikiTextTokenScopes scope)
        {
            Contract.Requires(wikiText != null);
            Contract.Requires(tokens != null);
            Contract.Requires(textTokenStart == null ||
                              (textTokenStart != null &&
                               index > textTokenStart.Value &&
                               textTokenStart.Value < wikiText.Length &&
                               index <= wikiText.Length));
            Contract.Ensures(textTokenStart == null);

            if (!textTokenStart.HasValue)
            {
                return;
            }

            WikiTextToken prevToken = new WikiTextToken(
                WikiTextToken.TokenType.Text,
                wikiText.Substring(textTokenStart.Value, index - textTokenStart.Value),
                scope);

            tokens.Add(prevToken);
            textTokenStart = null;
        }
コード例 #4
0
ファイル: WikiTextTokenizer.cs プロジェクト: breki/freude
 private static WikiTextTokenScopes ModifyScopeForAnywhereTokens(WikiTextTokenScopes scope)
 {
     return(scope == WikiTextTokenScopes.LineStart ? WikiTextTokenScopes.InnerText : scope);
 }