private static void LoadValidatorConfig(string baseDir, string templateDir, MarkdownValidatorBuilder builder) { if (string.IsNullOrEmpty(baseDir)) { return; } if (templateDir != null) { var configFolder = Path.Combine(templateDir, MarkdownSytleDefinition.MarkdownStyleDefinitionFolderName); if (Directory.Exists(configFolder)) { LoadValidatorDefinition(configFolder, builder); } } var configFile = Path.Combine(baseDir, MarkdownSytleConfig.MarkdownStyleFileName); if (EnvironmentContext.FileAbstractLayer.Exists(configFile)) { var config = JsonUtility.Deserialize <MarkdownSytleConfig>(configFile); builder.AddValidators(config.Rules); builder.AddTagValidators(config.TagRules); builder.AddSettings(config.Settings); } builder.EnsureDefaultValidator(); }
public MarkdownContextBuilder WithContext(MarkdownContext context) { _filePath = context.FilePath; _basePath = context.BasePath; _mvb = context.Mvb; _content = context.Content; _isInline = context.IsInline; _inclusionSet = context.InclusionSet; return(this); }
private static void LoadValidatorDefinition(string mdStyleDefPath, MarkdownValidatorBuilder builder) { if (Directory.Exists(mdStyleDefPath)) { foreach (var configFile in Directory.GetFiles(mdStyleDefPath, "*" + MarkdownSytleDefinition.MarkdownStyleDefinitionFilePostfix)) { var fileName = Path.GetFileName(configFile); var category = fileName.Remove(fileName.Length - MarkdownSytleDefinition.MarkdownStyleDefinitionFilePostfix.Length); var config = JsonUtility.Deserialize <MarkdownSytleDefinition>(configFile); builder.AddTagValidators(category, config.TagRules); builder.AddValidators(category, config.Rules); } } }
public MarkdownContext(string filePath, string basePath, MarkdownValidatorBuilder mvb, string content, bool isInline, ImmutableHashSet <string> inclusionSet) { Content = content; FilePath = filePath; BasePath = basePath; Mvb = mvb; IsInline = isInline; InclusionSet = inclusionSet; }
public static MarkdownValidatorBuilder Create( MarkdownServiceParameters parameters, ICompositionContainer container) { var builder = new MarkdownValidatorBuilder(container); if (parameters != null) { LoadValidatorConfig(parameters.BasePath, parameters.TemplateDir, builder); } if (container != null) { builder.LoadEnabledRulesProvider(); } return(builder); }
public ValidationExtension(MarkdownValidatorBuilder validationBuilder, MarkdownContext context) { _mvb = validationBuilder; _context = context; }
public MarkdownContextBuilder WithMvb(MarkdownValidatorBuilder mvb) { _mvb = mvb; return(this); }