Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 4
0
 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);
         }
     }
 }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
 public MarkdownContextBuilder WithMvb(MarkdownValidatorBuilder mvb)
 {
     _mvb = mvb;
     return(this);
 }