public virtual StringBuffer Render(IMarkdownRenderer engine, MarkdownTagInlineToken token, MarkdownInlineContext context) { if (engine.Options.Sanitize) { if (engine.Options.Sanitizer != null) { return(engine.Options.Sanitizer(token.RawMarkdown)); } return(StringHelper.Escape(token.RawMarkdown)); } return(token.RawMarkdown); }
public virtual StringBuffer Render(IMarkdownRenderer renderer, MarkdownTagInlineToken token, MarkdownInlineContext context) { if (renderer.Options.Sanitize) { if (renderer.Options.Sanitizer != null) { return(renderer.Options.Sanitizer(token.SourceInfo.Markdown)); } return(StringHelper.Escape(token.SourceInfo.Markdown)); } return(token.SourceInfo.Markdown); }
public IMarkdownToken Validate(MarkdownEngine engine, MarkdownTagInlineToken token) { var m = OpeningTag.Match(token.Content); bool isOpeningTag = true; if (m.Length == 0) { m = ClosingTag.Match(token.Content); if (m.Length == 0) { return null; } isOpeningTag = false; } return ValidateCore(token, m, isOpeningTag); }
private IMarkdownToken ValidateCore(MarkdownTagInlineToken token, Match m, bool isOpeningTag) { foreach (var validator in Validators) { if (isOpeningTag || !validator.OpeningTagOnly) { foreach (var tagName in validator.TagNames) { if (string.Equals(tagName, m.Groups[1].Value, System.StringComparison.OrdinalIgnoreCase)) { return ValidateOne(token, m, validator); } } } } return null; }
private IMarkdownToken ValidateOne(MarkdownTagInlineToken token, Match m, MarkdownTagValidationRule validator) { if (!string.IsNullOrEmpty(validator.CustomValidatorContractName)) { if (CompositionHost == null) { Logger.LogWarning($"Unable to validate tag by contract({validator.CustomValidatorContractName}): CompositionHost is null."); return null; } var customValidators = GetCustomMarkdownTagValidators(validator); if (customValidators.Count == 0) { Logger.LogWarning($"Cannot find custom markdown tag validator by contract name: {validator.CustomValidatorContractName}."); return null; } if (customValidators.TrueForAll(av => av.Validate(token.Content))) { return null; } } return ValidateOneCore(token, m, validator); }
private IMarkdownToken ValidateOneCore(MarkdownTagInlineToken token, Match m, MarkdownTagValidationRule validator) { switch (validator.Behavior) { case TagRewriteBehavior.Warning: Logger.LogWarning(string.Format(validator.MessageFormatter, m.Groups[1].Value, token.Content)); return null; case TagRewriteBehavior.Error: Logger.LogError(string.Format(validator.MessageFormatter, m.Groups[1].Value, token.Content)); return null; case TagRewriteBehavior.ErrorAndRemove: Logger.LogError(string.Format(validator.MessageFormatter, m.Groups[1].Value, token.Content)); return new MarkdownIgnoreToken(token.Rule); case TagRewriteBehavior.None: default: return null; } }
public virtual StringBuffer Render(IMarkdownRenderer engine, MarkdownTagInlineToken token, MarkdownInlineContext context) { if (engine.Options.Sanitize) { if (engine.Options.Sanitizer != null) { return engine.Options.Sanitizer(token.RawMarkdown); } return StringHelper.Escape(token.RawMarkdown); } return token.RawMarkdown; }
public virtual StringBuffer Render(IMarkdownRenderer renderer, MarkdownTagInlineToken token, MarkdownInlineContext context) { return(Insert(token, ExposeTokenName(token))); }
public void Validate(MarkdownTagInlineToken token) { var m = OpeningTag.Match(token.RawMarkdown); bool isOpeningTag = true; if (m.Length == 0) { m = ClosingTag.Match(token.RawMarkdown); if (m.Length == 0) { return; } isOpeningTag = false; } ValidateCore(token, m, isOpeningTag); }
private void ValidateOneCore(MarkdownTagInlineToken token, Match m, MarkdownTagValidationRule validator) { switch (validator.Behavior) { case TagValidationBehavior.Warning: Logger.LogWarning(string.Format(validator.MessageFormatter, m.Groups[1].Value, token.RawMarkdown)); return; case TagValidationBehavior.Error: Logger.LogError(string.Format(validator.MessageFormatter, m.Groups[1].Value, token.RawMarkdown)); return; case TagValidationBehavior.None: default: return; } }
public virtual StringBuffer Render(IMarkdownRenderer renderer, MarkdownTagInlineToken token, MarkdownInlineContext context) { return(this.Insert("Tag", this.GetSize(), Type.Leaf)); }