Example #1
0
        public static void AssertNormalize(string input, string expected = null, bool trim = true, NormalizeOptions options = null, MarkdownPipeline pipeline = null)
        {
            expected = expected ?? input;
            input    = NormText(input, trim);
            expected = NormText(expected, trim);

            pipeline = pipeline ?? new MarkdownPipelineBuilder()
                       .UseAutoLinks()
                       .UseJiraLinks(new Extensions.JiraLinks.JiraLinkOptions("https://jira.example.com"))
                       .UseTaskLists()
                       .Build();

            var result = Markdown.Normalize(input, options, pipeline: pipeline);

            result = NormText(result, trim);

            TestParser.PrintAssertExpected(input, result, expected);
        }
Example #2
0
        public void TestThematicInsideCodeBlockInsideList()
        {
            var input = @"1. In the :

   ```
   Id                                   DisplayName         Description
   --                                   -----------         -----------
   62375ab9-6b52-47ed-826b-58e47e0e304b Group.Unified       ...
   ```";

            TestParser.TestSpec(input, @"<ol>
<li><p>In the :</p>
<pre><code>Id                                   DisplayName         Description
--                                   -----------         -----------
62375ab9-6b52-47ed-826b-58e47e0e304b Group.Unified       ...
</code></pre></li>
</ol>");
        }
Example #3
0
        public void TestBugPipeTables()
        {
            // https://github.com/lunet-io/markdig/issues/73
            TestParser.TestSpec(@"| abc | def |
| --- | --- |
| 1 | ~3 |
", @"<table>
<thead>
<tr>
<th>abc</th>
<th>def</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>~3</td>
</tr>
</tbody>
</table>", "advanced");
        }
Example #4
0
        public void TestListBug()
        {
            // TODO: Add this test back to the CommonMark specs
            var text = @"- item1
  - item2
    - item3
      - item4";

            TestParser.TestSpec(text, @"<ul>
<li>item1
<ul>
<li>item2
<ul>
<li>item3
<ul>
<li>item4</li>
</ul></li>
</ul></li>
</ul></li>
</ul>
");
        }
Example #5
0
        public void LinkTextMayContainBalancedBrackets(string linkText)
        {
            string markdown = $"[{linkText}](/uri)";
            string expected = $@"<p><a href=""/uri"">{linkText}</a></p>";

            TestParser.TestSpec(markdown, expected);

            // Make the link text unbalanced
            foreach (var bracketIndex in linkText
                     .Select((c, i) => new Tuple <char, int>(c, i))
                     .Where(t => t.Item1 == '[' || t.Item1 == ']')
                     .Select(t => t.Item2))
            {
                string brokenLinkText = linkText.Remove(bracketIndex, 1);

                markdown = $"[{brokenLinkText}](/uri)";
                expected = $@"<p><a href=""/uri"">{brokenLinkText}</a></p>";

                string actual = Markdown.ToHtml(markdown);
                Assert.AreNotEqual(expected, actual);
            }
        }
Example #6
0
 public void NormalStrongNormal()
 {
     TestParser.TestSpec("normal ***Strong emphasis*** normal", "<p>normal <em><strong>Strong emphasis</strong></em> normal</p>", "");
 }
Example #7
0
 public static void TestSpec(string markdownText, string expected, string extensions)
 {
     TestParser.TestSpec(markdownText, expected, extensions, plainText: true);
 }
Example #8
0
 public void TestBugEmphAttribute()
 {
     // https://github.com/lunet-io/markdig/issues/108
     TestParser.TestSpec(@"*test*{name=value}", "<p><em name=\"value\">test</em></p>", "advanced");
 }
Example #9
0
 public void TestStandardUriEscape()
 {
     TestParser.TestSpec(@"![你好](你好.png)", "<p><img src=\"你好.png\" alt=\"你好\" /></p>", "nonascii-noescape");
 }
Example #10
0
 public void TestHtmlh4Bug()
 {
     TestParser.TestSpec(@"<h4>foobar</h4>", @"<h4>foobar</h4>");
 }
Example #11
0
        public void TestInvalidHtmlEntity()
        {
            var input = "9&ddr;&*&ddr;&de��__";

            TestParser.TestSpec(input, "<p>9&amp;ddr;&amp;*&amp;ddr;&amp;de��__</p>");
        }
Example #12
0
 public void TestAltTextIsCorrectlyEscaped()
 {
     TestParser.TestSpec(
         @"![This is image alt text with quotation ' and double quotation ""hello"" world](girl.png)",
         @"<p><img src=""girl.png"" alt=""This is image alt text with quotation ' and double quotation &quot;hello&quot; world"" /></p>");
 }
Example #13
0
 public void TestUnicodeInDomainNameOfLinkReferenceDefinition()
 {
     TestParser.TestSpec("[Foo]\n\n[Foo]: http://ünicode.com", "<p><a href=\"http://xn--nicode-2ya.com\">Foo</a></p>");
 }
Example #14
0
        public void TestEmphasisAndHtmlEntity()
        {
            var markdownText = "*Unlimited-Fun&#174;*&#174;";

            TestParser.TestSpec(markdownText, "<p><em>Unlimited-Fun®</em>®</p>");
        }
 public void OnlyStrikethrough_Single()
 {
     TestParser.TestSpec("~foo~", "<p>~foo~</p>", new MarkdownPipelineBuilder().UseEmphasisExtras(EmphasisExtraOptions.Strikethrough).Build());
 }
 public void SubscriptAndStrikethrough_Double()
 {
     TestParser.TestSpec("~~foo~~", "<p><del>foo</del></p>", new MarkdownPipelineBuilder().UseEmphasisExtras(EmphasisExtraOptions.Strikethrough | EmphasisExtraOptions.Subscript).Build());
 }
 public void OnlySubscript_Double()
 {
     TestParser.TestSpec("~~foo~~", "<p><sub><sub>foo</sub></sub></p>", new MarkdownPipelineBuilder().UseEmphasisExtras(EmphasisExtraOptions.Subscript).Build());
 }