public override bool? AcceptsLetter(ParseContext context, char letter) { if (letter == '\r' || letter == '\n') return false; // don't allow multiline html if (context.MatchedString.Length == 1 && context.MatchedString[0] != '<') return false; if (context.MatchedString.Length == 2 && context.MatchedString[1] == ' ') return false; if (context.MatchedString.Length > 2 && letter == '>') { var tag = Regex.Match(context.MatchedString, "</?([a-z0-9]+)[ />]",RegexOptions.IgnoreCase).Groups[1].Value; // invalid opening tag if (!validTags.ContainsKey(tag)) return false; if (context.MatchedString.StartsWith("</")) return true; // for closing elements, end here var csr = context.MatchedString; if (!csr.EndsWith("/>")) csr = $"{csr}</{tag}>"; // close tag for xelement parsing try { XElement.Parse(csr); return true; } catch { return false; } } return null; }
public override bool? AcceptsLetter(ParseContext context, char letter) { if (letter == '\n' || letter == '\r') { if (sb.ToString().Contains("\n")) return false; // allow only one \n in the same tag return true; } return false; }
public override bool? AcceptsLetter(ParseContext context, char letter) { if (letter == '_') { if (context.PreviousTag?.Value is SpaceTag || context.PreviousTag?.Value is NewLineTag || context.NextChar == ' ' || context.NextChar == '\r' || context.NextChar == '\n') { var lastLit = (context.PreviousTag?.Value as LiteralTag); if (lastLit?.Text.IsValidLink() == true) return false; } else return false; } return base.AcceptsLetter(context, letter); }
public override bool? AcceptsLetter(ParseContext context, char letter) { if (context.MatchedString.Length > Match.Length) { if (letter == MatchTerminator) { if (ValidateArgs(context, ExtractArgs(context.MatchedString))) return true; return false; } if (letter == '\n') return false; } else if (Match[context.MatchedString.Length-1] != context.CurrentCharLowerCase) return false; return null; }
public override bool? AcceptsLetter(ParseContext context, char letter) { if (letter == '=') { if (context.MatchedString.Length > 6) return false; // max is h6 if (context.NextChar != '=') { if (context.PreviousTag == null || context.PreviousTag.Value is SpaceTag || context.PreviousTag.Value is NewLineTag || context.NextChar == null || context.NextChar == ' ' || context.NextChar == '\r' || context.NextChar == '\n') return true; return false; } return null; } else return false; }
public override bool? AcceptsLetter(ParseContext context, char letter) { if (letter == ' ' || letter == '\t' || letter == '\r' || letter == '\n') return false; return true; }
/// <summary> /// Parses terminal symbols - like string constants /// </summary> static void ParseTerminals(ParseContext context) { for (var i = context.NonterminalStartPos; i <= context.Pos; i++) { var scanChar = context.Input[i]; var lastTerm = context.PreviousTag?.Value as TerminalTag; if (lastTerm == null || lastTerm.AcceptsLetter(context, scanChar) == false) { foreach (var tt in terminalTags) { if (tt.AcceptsLetter(context, scanChar) != false) { context.AddTag(((TerminalTag)tt.Create()).AppendChar(scanChar)); break; } } } else lastTerm.AppendChar(scanChar); } }
public abstract bool? AcceptsLetter(ParseContext context, char letter);
public override bool? AcceptsLetter(ParseContext context, char letter) { if (Match[context.MatchedString.Length-1] != context.CurrentCharLowerCase) return false; if (context.MatchedString.Length == Match.Length) return true; return null; }
protected override bool ValidateArgs(ParseContext context, string args) => true;
public override bool? AcceptsLetter(ParseContext context, char letter) { if (letter == '\r' || letter == '\n') return false; return base.AcceptsLetter(context, letter); }
public override bool? AcceptsLetter(ParseContext context, char letter) { var ret =base.AcceptsLetter(context, letter); if (ret == true && !(context.NextChar ==null|| context.NextChar =='\r' || context.NextChar=='\n')) return false; return ret; }
protected abstract bool ValidateArgs(ParseContext context, string args);
protected override bool ValidateArgs(ParseContext context, string args) { var parts = args.Split(' '); if (string.IsNullOrEmpty(parts[0])) return false; return parts[0].IsValidLink() || context.IsWikiKey(parts[0]); }
protected override bool ValidateArgs(ParseContext context, string args) { return(args.Length > 0 && !args.Contains("'") && !args.Contains("\"")); }