Example #1
0
        public void PermitsNestedBlocks()
        {
            var source = @"::: zone target=""chromeless""
* foo
* bar
* baz
::: zone-end
";

            var expected = @"<div class=""zone has-target"" data-target=""chromeless"">
<ul>
<li>foo</li>
<li>bar</li>
<li>baz</li>
</ul>
</div>
";
            var listener = TestLoggerListener.CreateLoggerListenerWithPhaseEqualFilter(LoggerPhase);

            Logger.RegisterListener(listener);
            using (new LoggerPhaseScope(LoggerPhase))
            {
                TestUtility.AssertEqual(expected, source, TestUtility.MarkupWithoutSourceInfo);
            }
            Logger.UnregisterListener(listener);

            Assert.Empty(listener.Items);
        }
Example #2
0
        public void MissingEndTag()
        {
            //arange
            var source1 = @"::: zone target=""chromeless""";
            var source2 = @"::: zone target=""chromeless""
::: zone-end";

            // assert
            var expected = @"<div data-zone=""chromeless"">
</div>
";
            var listener = TestLoggerListener.CreateLoggerListenerWithPhaseEqualFilter(LoggerPhase);

            Logger.RegisterListener(listener);
            using (new LoggerPhaseScope(LoggerPhase))
            {
                TestUtility.AssertEqual(expected, source2, TestUtility.MarkupWithoutSourceInfo);

                Assert.Empty(listener.Items);

                TestUtility.AssertEqual(expected, source1, TestUtility.MarkupWithoutSourceInfo);
            }
            Logger.UnregisterListener(listener);

            Assert.Single(listener.Items);
            Assert.Equal("Invalid zone on line 0. No \"::: zone-end\" found. Blocks should be explicitly closed.", listener.Items[0].Message);
        }
Example #3
0
        public void NolocTest_Invalid()
        {
            // MultipleLines
            var source1   = @":::noloc text=""I am crossing\
a line"":::";
            var expected1 = @"<p>:::noloc text=&quot;I am crossing<br />
a line&quot;:::</p>
";

            TestUtility.AssertEqual(expected1, source1, TestUtility.MarkupWithoutSourceInfo);

            // Spaces not exactly match
            var source2   = @"::: noloc text=""test"" :::";
            var expected2 = @"<p>::: noloc text=&quot;test&quot; :::</p>
";

            TestUtility.AssertEqual(expected2, source2, TestUtility.MarkupWithoutSourceInfo);

            // Case sensitive
            var source3   = @":::Noloc text=""test"":::";
            var expected3 = @"<p>:::Noloc text=&quot;test&quot;:::</p>
";

            TestUtility.AssertEqual(expected3, source3, TestUtility.MarkupWithoutSourceInfo);
        }
Example #4
0
        public void MonikerRangeTestNotClosed()
        {
            //arange
            var source1 = @"::: moniker range=""start""";
            var source2 = @"::: moniker range=""start""
::: moniker-end";

            // assert
            var expected = @"<div range=""start"">
</div>
";
            var listener = TestLoggerListener.CreateLoggerListenerWithPhaseEqualFilter(LoggerPhase);

            Logger.RegisterListener(listener);
            using (new LoggerPhaseScope(LoggerPhase))
            {
                TestUtility.AssertEqual(expected, source2, TestUtility.MarkupWithoutSourceInfo);

                Assert.Empty(listener.Items);

                TestUtility.AssertEqual(expected, source1, TestUtility.MarkupWithoutSourceInfo);
            }
            Logger.UnregisterListener(listener);

            Assert.Single(listener.Items);
            Assert.Equal("No \"::: moniker-end\" found for \"start\", MonikerRange does not end explictly.", listener.Items[0].Message);
        }
Example #5
0
        public void TestTabGroup()
        {
            string actual   = @"# [title-a](#tab/a)
content-a
# <a id=""x""></a>[title-b](#tab/b/c)
content-b
- - -";
            var    groupId  = "CeZOj-G++Q";
            var    expected = $@"<div class=""tabGroup"" id=""tabgroup_{groupId}"" sourceFile=""test.md"" sourceStartLineNumber=""1"" sourceEndLineNumber=""5"">
<ul role=""tablist"">
<li role=""presentation"">
<a href=""#tabpanel_{groupId}_a"" role=""tab"" aria-controls=""tabpanel_{groupId}_a"" data-tab=""a"" tabindex=""0"" aria-selected=""true"" sourceFile=""test.md"" sourceStartLineNumber=""1"" sourceEndLineNumber=""1"">title-a</a>
</li>
<li role=""presentation"" aria-hidden=""true"" hidden=""hidden"">
<a href=""#tabpanel_{groupId}_b_c"" role=""tab"" aria-controls=""tabpanel_{groupId}_b_c"" data-tab=""b"" data-condition=""c"" tabindex=""-1"" sourceFile=""test.md"" sourceStartLineNumber=""3"" sourceEndLineNumber=""3"">title-b</a>
</li>
</ul>
<section id=""tabpanel_{groupId}_a"" role=""tabpanel"" data-tab=""a"">
<p sourceFile=""test.md"" sourceStartLineNumber=""2"" sourceEndLineNumber=""2"">content-a</p>
</section>
<section id=""tabpanel_{groupId}_b_c"" role=""tabpanel"" data-tab=""b"" data-condition=""c"" aria-hidden=""true"" hidden=""hidden"">
<p sourceFile=""test.md"" sourceStartLineNumber=""4"" sourceEndLineNumber=""4"">content-b</p>
</section>
</div>
";

            TestUtility.AssertEqual(expected, actual, content => TestUtility.Markup(content, "test.md"));
        }
Example #6
0
        public void ComplexImageTestBlockGeneral()
        {
            var source = @"
:::image type=""icon"" source=""example.svg"":::

:::image type=""complex"" source=""example.jpg"" alt-text=""example""::: 
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
:::image-end:::

:::image source=""example.jpg"" alt-text=""example"":::
";

            var expected = @"<img role=""presentation"" src=""example.svg"">
<img alt=""example"" aria-describedby=""a00f6"" src=""example.jpg"">
<div id=""a00f6"" class=""visually-hidden"">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>
<img alt=""example"" src=""example.jpg"">
".Replace("\r\n", "\n");

            var listener = TestLoggerListener.CreateLoggerListenerWithPhaseEqualFilter(LoggerPhase);

            Logger.RegisterListener(listener);
            using (new LoggerPhaseScope(LoggerPhase))
            {
                TestUtility.AssertEqual(expected, source, TestUtility.MarkupWithoutSourceInfo);
            }
            Logger.UnregisterListener(listener);
        }
Example #7
0
        public void TripleColonTestSelfClosing()
        {
            var source = @"::: zone target=""chromeless""
::: form action=""create-resource"" submitText=""Create"" :::
::: zone-end
";

            var expected = @"<div class=""zone has-target"" data-target=""chromeless"">
<form class=""chromeless-form"" data-action=""create-resource"">
<div></div>
<button class=""button is-primary"" disabled=""disabled"" type=""submit"">Create</button>
</form>
</div>
".Replace("\r\n", "\n");

            var listener = TestLoggerListener.CreateLoggerListenerWithPhaseEqualFilter(LoggerPhase);

            Logger.RegisterListener(listener);
            using (new LoggerPhaseScope(LoggerPhase))
            {
                TestUtility.AssertEqual(expected, source, TestUtility.MarkupWithoutSourceInfo);
            }
            Logger.UnregisterListener(listener);

            // Listener should have no error or warning message.
            Assert.Empty(listener.Items);
        }
Example #8
0
        public void TestDfmLink_LinkWithSpecialCharactorsInTitle()
        {
            var source   = @"[text's string](https://www.google.com.sg/?gfe_rd=cr&ei=Xk ""Google's homepage"")";
            var expected = @"<p><a href=""https://www.google.com.sg/?gfe_rd=cr&amp;ei=Xk"" title=""Google's homepage"">text's string</a></p>
";

            TestUtility.AssertEqual(expected, source, TestUtility.MarkupWithoutSourceInfo);
        }
Example #9
0
        public void TestPathUtility_AbsoluteLinkWithBracketAndBrackt()
        {
            var source   = @"[User-Defined Date/Time Formats (Format Function)](http://msdn2.microsoft.com/library/73ctwf33\(VS.90\).aspx)";
            var expected = @"<p><a href=""http://msdn2.microsoft.com/library/73ctwf33(VS.90).aspx"">User-Defined Date/Time Formats (Format Function)</a></p>
";

            TestUtility.AssertEqual(expected, source, TestUtility.MarkupWithoutSourceInfo);
        }
Example #10
0
        public void Test_Mathematics_Support_1()
        {
            var source   = "$ math^0 **inline** $";
            var expected = @"<p><span class=""math"">math^0 **inline**</span></p>
";

            TestUtility.AssertEqual(expected, source, TestUtility.MarkupWithoutSourceInfo);
        }
Example #11
0
        public void TestDfm_HeadingId()
        {
            var source   = @" ### 1. Deploying the network";
            var expected = @"<h3 id=""1-deploying-the-network"">1. Deploying the network</h3>
";

            TestUtility.AssertEqual(expected, source, TestUtility.MarkupWithoutSourceInfo);
        }
Example #12
0
        public void TestDfmLink_WithSpecialCharactorsInTitle()
        {
            var source = @"[This is link text with quotation ' and double quotation ""hello"" world](girl.png ""title is \""hello\"" world."")";

            var expected = @"<p><a href=""girl.png"" title=""title is &quot;hello&quot; world."">This is link text with quotation ' and double quotation &quot;hello&quot; world</a></p>
";

            TestUtility.AssertEqual(expected, source, TestUtility.MarkupWithoutSourceInfo);
        }
Example #13
0
        public void TestDfmImageLink_WithSpecialCharactorsInAltText()
        {
            var source = @"![This is image alt text with quotation ' and double quotation ""hello"" world](girl.png)";

            var expected = @"<p><img src=""girl.png"" alt=""This is image alt text with quotation ' and double quotation &quot;hello&quot; world"" /></p>
";

            TestUtility.AssertEqual(expected, source, TestUtility.MarkupWithoutSourceInfo);
        }
Example #14
0
        public void MonikerRangeTestInvalid()
        {
            //arange
            var source = @"::: moniker range=""azure-rest-1.0";

            // assert
            var expected = @"<p>::: moniker range=&quot;azure-rest-1.0</p>
";

            TestUtility.AssertEqual(expected, source, TestUtility.MarkupWithoutSourceInfo);
        }
Example #15
0
        public void ChromelessFormsAttributeValueSingleQuote()
        {
            var content  = @"::: form submitText=""<script> >.< </script>"" action=""create-Resource"" :::";
            var expected = @"<form class=""chromeless-form"" data-action=""create-Resource"">
<div></div>
<button disabled=""disabled"" type=""submit"">&lt;script&gt; &gt;.&lt; &lt;/script&gt;</button>
</form>
".Replace("\r\n", "\n");

            TestUtility.AssertEqual(expected, content, TestUtility.MarkupWithoutSourceInfo);
        }
Example #16
0
        public void ChromelessFormsTestWithModel()
        {
            var content  = @"::: form model=""./devsandbox/ChromelessFormsTest.md"" action=""create-resource"" submitText=""Do it"" :::";
            var expected = @"<form class=""chromeless-form"" data-model=""./devsandbox/ChromelessFormsTest.md"" data-action=""create-resource"">
<div></div>
<button disabled=""disabled"" type=""submit"">Do it</button>
</form>
".Replace("\r\n", "\n");

            TestUtility.AssertEqual(expected, content, TestUtility.MarkupWithoutSourceInfo);
        }
Example #17
0
        public void ChromelessFormsTestWithoutModel()
        {
            var content  = @"::: form action=""create-resource"" submitText=""Create"" :::";
            var expected = @"<form class=""chromeless-form"" data-action=""create-resource"">
<div></div>
<button class=""button is-primary"" disabled=""disabled"" type=""submit"">Create</button>
</form>
".Replace("\r\n", "\n");

            TestUtility.AssertEqual(expected, content, TestUtility.MarkupWithoutSourceInfo);
        }
Example #18
0
        public void TestDfm_EncodeInStrongEM()
        {
            var source = @"tag started with non-alphabet should be encoded <1-100>, <_hello>, <?world>, <1_2 href=""good"">, <1 att='bcd'>.
tag started with alphabet should not be encode: <abc> <a-hello> <a?world> <a_b href=""good""> <AC att='bcd'>";

            var expected = @"<p>tag started with non-alphabet should be encoded &lt;1-100&gt;, &lt;_hello&gt;, &lt;?world&gt;, &lt;1_2 href=&quot;good&quot;&gt;, &lt;1 att='bcd'&gt;.
tag started with alphabet should not be encode: <abc> <a-hello> &lt;a?world&gt; &lt;a_b href=&quot;good&quot;&gt; <AC att='bcd'></p>
";

            TestUtility.AssertEqual(expected, source, TestUtility.MarkupWithoutSourceInfo);
        }
Example #19
0
        public void TestDfm_TaskList()
        {
            // Confirm that the [ ] and { } in the middle of list should not be parsed.
            var source   = @"* Not contain a special character: &#92; ! # $ % & * + / = ? ^ &#96; { } | ~ < > ( ) ' ; : , [ ] "" @ _";
            var expected = @"<ul>
<li>Not contain a special character: \ ! # $ % &amp; * + / = ? ^ ` { } | ~ &lt; &gt; ( ) ' ; : , [ ] &quot; @ _</li>
</ul>
";

            TestUtility.AssertEqual(expected, source, TestUtility.MarkupWithoutSourceInfo);
        }
Example #20
0
        public void TestDfm_LinkDefinition()
        {
            var source   = @"![scenario image][scenario]
## Scenario
[scenario]: ./scenario.png";
            var expected = @"<p><img src=""./scenario.png"" alt=""scenario image"" /></p>
<h2 id=""scenario"">Scenario</h2>
";

            TestUtility.AssertEqual(expected, source, TestUtility.MarkupWithoutSourceInfo);
        }
Example #21
0
        public void MonikerRangeWithCodeIndent()
        {
            var source   = @"::: moniker range=""start""
    console.log(""hehe"")
::: moniker-end";
            var expected = @"<div range=""start"">
<pre><code>console.log(&quot;hehe&quot;)
</code></pre>
</div>
";

            TestUtility.AssertEqual(expected, source, TestUtility.MarkupWithoutSourceInfo);
        }
Example #22
0
        public void TripleColonTestGeneral()
        {
            var source   = @"::: zone pivot=""windows""
    hello
::: zone-end
";
            var expected = @"<div class=""zone has-pivot"" data-pivot=""windows"">
<pre><code>hello
</code></pre>
</div>
".Replace("\r\n", "\n");

            TestUtility.AssertEqual(expected, source, TestUtility.MarkupWithoutSourceInfo);
        }
Example #23
0
        public void TestYaml_InvalidYamlInsideContent()
        {
            var source   = @"# Title
---
Not yaml syntax
---
hello world";
            var expected = @"<h1 id=""title"">Title</h1>
<hr />
<h2 id=""not-yaml-syntax"">Not yaml syntax</h2>
<p>hello world</p>
";

            TestUtility.AssertEqual(expected, source, TestUtility.MarkupWithoutSourceInfo);
        }
Example #24
0
        public void ImageWithIconTypeTestBlockGeneral()
        {
            var source = @":::image type=""icon"" source=""example.svg"":::";

            var expected = @"<img role=""presentation"" src=""example.svg"">
".Replace("\r\n", "\n");

            var listener = TestLoggerListener.CreateLoggerListenerWithPhaseEqualFilter(LoggerPhase);

            Logger.RegisterListener(listener);
            using (new LoggerPhaseScope(LoggerPhase))
            {
                TestUtility.AssertEqual(expected, source, TestUtility.MarkupWithoutSourceInfo);
            }
            Logger.UnregisterListener(listener);
        }
Example #25
0
        public void PivotCommaDelimited()
        {
            //arange
            var source = @"::: zone pivot = ""a,b""
::: zone-end";

            // assert
            var expected = "<div data-pivot=\"a b\">\n</div>\n";
            var listener = TestLoggerListener.CreateLoggerListenerWithPhaseEqualFilter(LoggerPhase);

            Logger.RegisterListener(listener);
            using (new LoggerPhaseScope(LoggerPhase))
            {
                TestUtility.AssertEqual(expected, source, TestUtility.MarkupWithoutSourceInfo);
            }
            Logger.UnregisterListener(listener);

            Assert.Empty(listener.Items);
        }
Example #26
0
        public void PdfPivotInvalid()
        {
            //arange
            var source = @"::: zone target = ""pdf""  pivot = ""foo""  ";

            // assert
            var expected = @"<p>::: zone target = &quot;pdf&quot;  pivot = &quot;foo&quot;</p>
";
            var listener = TestLoggerListener.CreateLoggerListenerWithPhaseEqualFilter(LoggerPhase);

            Logger.RegisterListener(listener);
            using (new LoggerPhaseScope(LoggerPhase))
            {
                TestUtility.AssertEqual(expected, source, TestUtility.MarkupWithoutSourceInfo);
            }
            Logger.UnregisterListener(listener);

            Assert.Single(listener.Items);
            Assert.Equal("Invalid zone on line 0. \"::: zone target = \"pdf\"  pivot = \"foo\"  \" is invalid. Pivot not permitted on pdf target.", listener.Items[0].Message);
        }
Example #27
0
        public void DuplicateAttribute()
        {
            //arange
            var source = @"::: zone target=""pdf"" target=""docs""";

            // assert
            var expected = @"<p>::: zone target=&quot;pdf&quot; target=&quot;docs&quot;</p>
";
            var listener = TestLoggerListener.CreateLoggerListenerWithPhaseEqualFilter(LoggerPhase);

            Logger.RegisterListener(listener);
            using (new LoggerPhaseScope(LoggerPhase))
            {
                TestUtility.AssertEqual(expected, source, TestUtility.MarkupWithoutSourceInfo);
            }
            Logger.UnregisterListener(listener);

            Assert.Single(listener.Items);
            Assert.Equal("Invalid zone on line 0. \"::: zone target=\"pdf\" target=\"docs\"\" is invalid. Attribute \"target\" specified multiple times.", listener.Items[0].Message);
        }
Example #28
0
        public void InvalidAttribute()
        {
            //arange
            var source = @"::: zone *=""pdf""";

            // assert
            var expected = @"<p>::: zone *=&quot;pdf&quot;</p>
";
            var listener = TestLoggerListener.CreateLoggerListenerWithPhaseEqualFilter(LoggerPhase);

            Logger.RegisterListener(listener);
            using (new LoggerPhaseScope(LoggerPhase))
            {
                TestUtility.AssertEqual(expected, source, TestUtility.MarkupWithoutSourceInfo);
            }
            Logger.UnregisterListener(listener);

            Assert.Single(listener.Items);
            Assert.Equal("Invalid zone on line 0. \"::: zone *=\"pdf\"\" is invalid. Invalid attribute.", listener.Items[0].Message);
        }
Example #29
0
        public void AttributeMissingClosingQuote()
        {
            //arange
            var source = @"::: zone target=""chromeless";

            // assert
            var expected = @"<p>::: zone target=&quot;chromeless</p>
";
            var listener = TestLoggerListener.CreateLoggerListenerWithPhaseEqualFilter(LoggerPhase);

            Logger.RegisterListener(listener);
            using (new LoggerPhaseScope(LoggerPhase))
            {
                TestUtility.AssertEqual(expected, source, TestUtility.MarkupWithoutSourceInfo);
            }
            Logger.UnregisterListener(listener);

            Assert.Single(listener.Items);
            Assert.Equal("Invalid zone on line 0. \"::: zone target=\"chromeless\" is invalid. Invalid attribute \"target\". Values must be terminated with a double quote.", listener.Items[0].Message);
        }
Example #30
0
        public void MonikerRangeTestInvalid()
        {
            //arange
            var source = @"::: moniker range=""azure-rest-1.0";

            // assert
            var expected = @"<p>::: moniker range=&quot;azure-rest-1.0</p>
";
            var listener = TestLoggerListener.CreateLoggerListenerWithPhaseEqualFilter(LoggerPhase);

            Logger.RegisterListener(listener);
            using (new LoggerPhaseScope(LoggerPhase))
            {
                TestUtility.AssertEqual(expected, source, TestUtility.MarkupWithoutSourceInfo);
            }
            Logger.UnregisterListener(listener);

            Assert.Single(listener.Items);
            Assert.Equal("MonikerRange does not have ending charactor (\").", listener.Items[0].Message);
        }