示例#1
0
        public void TestTokenValidator()
        {
            const string content         = "# Hello World";
            const string expected        = "<h1>Hello World</h1>\n";
            const string expectedMessage = "a space is expected after '#'";
            string       message         = null;

            var rewriter = MarkdownObjectRewriterFactory.FromValidator(
                MarkdownObjectValidatorFactory.FromLambda <HeadingBlock>(
                    block =>
            {
                if (!block.Lines.ToString().StartsWith("# "))
                {
                    message = expectedMessage;
                }
            })
                );

            var html = Markup(content, rewriter, null);

            Assert.Equal(expected.Replace("\r\n", "\n"), html);
            Assert.Equal(expectedMessage, message);
        }
示例#2
0
        public void TestGetSchemaName()
        {
            const string expectedSchemaName = "YamlMime:ModuleUnit";
            const string yamlFilename       = "moduleunit.yml";
            const string yamlContent        = @"### YamlMime:ModuleUnit
uid: learn.azure.introduction";

            File.WriteAllText(yamlFilename, yamlContent);
            InclusionContext.PushFile(yamlFilename);
            InclusionContext.PushInclusion("introduction-included.md");

            string schemaName = string.Empty;

            var rewriter = MarkdownObjectRewriterFactory.FromValidator(
                MarkdownObjectValidatorFactory.FromLambda <MarkdownDocument>(
                    root =>
            {
                schemaName = root.GetData("SchemaName")?.ToString();
            })
                );
            var html = Markup("# Hello World", rewriter, null);

            Assert.Equal(expectedSchemaName, schemaName);
        }
示例#3
0
 ImmutableArray <IMarkdownObjectValidator> IMarkdownObjectValidatorProvider.GetValidators()
 {
     return(ImmutableArray.Create(
                MarkdownObjectValidatorFactory.FromLambda <HtmlBlock>(
                    block => Logger.LogWarning(WarningMessage))));
 }