public WikiTextToken(TokenType tokenType, string text, WikiTextTokenScopes scopes) { Contract.Requires(!string.IsNullOrEmpty(text)); this.tokenType = tokenType; this.text = text; this.scopes = scopes; }
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; }
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; }
private static WikiTextTokenScopes ModifyScopeForAnywhereTokens(WikiTextTokenScopes scope) { return(scope == WikiTextTokenScopes.LineStart ? WikiTextTokenScopes.InnerText : scope); }