Esempio n. 1
0
 public void HeadingTest()
 {
     using (var markdownify = new Markdownify())
     {
         var transform = markdownify.Transform("# The Heading");
         Approvals.Verify(transform);
     }
 }
Esempio n. 2
0
 public void HeadingTest()
 {
     using (var markdownify = new Markdownify())
     {
         var transform = markdownify.Transform("# The Heading");
         Approvals.Verify(transform);
     }
 }
Esempio n. 3
0
 public void InlineCodeTest()
 {
     var input = @"`the code`";
     using (var markdownify = new Markdownify())
     {
         var transform = markdownify.Transform(input);
         Assert.AreEqual("<p><code>the code</code></p>\n", transform);
     }
 }
Esempio n. 4
0
    public void InlineCodeTest()
    {
        var input = @"`the code`";

        using (var markdownify = new Markdownify())
        {
            var transform = markdownify.Transform(input);
            Assert.AreEqual("<p><code>the code</code></p>\n", transform);
        }
    }
Esempio n. 5
0
 public void MultiLineCodeTest()
 {
     var input = @"
     ```
     the code
     ```";
     using (var markdownify = new Markdownify())
     {
         var transform = markdownify.Transform(input);
         Assert.AreEqual("<pre><code>the code\n</code></pre>", transform);
     }
 }
Esempio n. 6
0
    public void MultiLineCodeTest()
    {
        var input = @"
```
the code
```";

        using (var markdownify = new Markdownify())
        {
            var transform = markdownify.Transform(input);
            Assert.AreEqual("<pre><code>the code\n</code></pre>", transform);
        }
    }
Esempio n. 7
0
    public void Sample()
    {
        var input = @"
| Tables        | Are           | Cool  |
| ------------- |:-------------:| -----:|
| col 3 is      | right-aligned | $1600 |
| col 2 is      | centered      |   $12 |
";

        using (var markdownify = new Markdownify())
        {
            Debug.WriteLine(markdownify.Transform(input));
        }
    }
Esempio n. 8
0
        private static string TransformDoc(string input)
        {
            var renderMethods = new Strike.RenderMethods
            {
                Link =
                    @"function(href, title, text){
                       //Determine if relative url
                       if(!/^(https?:)\w+/.test(href)) {
                         //Filter out links to in-page anchors
                         if(href.charAt(0) !== '#') {
                           //Ensure relative urls to folders end with /readme.htm
                           if(href.slice(href.lastIndexOf('/')).lastIndexOf('.') < 0) {
                             //Ensure path ends with /
                             if(!/\/$/.test(href)) {
                               href += '/';
                             }
                             href += 'readme.htm';
                           // Otherwise, for relative URLs ending with .md, replace .md with .htm
                           } else if (href.toLowerCase().lastIndexOf('.md') == href.length - 3) {
                             href = href.replace('.md','.htm');
                           }
                         }
                       }

                     var out = marked.Renderer.prototype.link.apply(this, arguments);
                     return out; 
                   }",
                Image =
                    @"function(href, title, text){
                     var out = marked.Renderer.prototype.image.apply(this, arguments);
                     out = out.replace('<img ', '<img class=""img-responsive""');
                     return out; 
                   }",
                Heading =
                    @"function(text, level){
                     var out = marked.Renderer.prototype.heading.apply(this, arguments);
                     if(level === 1) {
                       out = out.replace('<h1', '<div class=""jumbotron""><h1');
                       out = out.replace('</h1>', '</h1></div>');
                     }
                     return out; 
                   }"
            };

            using (var markdownify = new Markdownify(new Strike.Options(), renderMethods))
            {
                return(markdownify.Transform(input));
            }
        }
Esempio n. 9
0
    public void TableTest()
    {
        var input = @"
| Tables        | Are           | Cool  |
| ------------- |:-------------:| -----:|
| col 3 is      | right-aligned | $1600 |
| col 2 is      | centered      |   $12 |
| zebra stripes | are neat      |    $1 |
";

        using (var markdownify = new Markdownify())
        {
            Approvals.Verify(markdownify.Transform(input).FixNewLines());
        }
    }
Esempio n. 10
0
    public void MultiLineCodeWithhighlightTest()
    {
        var input   = @"
```
the code
```";
        var options = new Options
        {
            Highlight = "function (code) {return 'before' + code + 'after';}"
        };

        using (var markdownify = new Markdownify(options, new RenderMethods()))
        {
            var transform = markdownify.Transform(input);
            Assert.AreEqual("<pre><code>beforethe codeafter\n</code></pre>", transform);
        }
    }
Esempio n. 11
0
    public void InvokeRootMarkedJsMember()
    {
        var input = "![text](href.png \"text\")";

        var rendereMethods = new RenderMethods
        {
            Image = @"
function (href, title, text) {
    text = 'replaced text';
    return marked.Renderer.prototype.image.apply(this, arguments);
}"
        };

        using (var markdownify = new Markdownify(new Options(), rendereMethods))
        {
            var transform = markdownify.Transform(input);
            Assert.AreEqual("<p><img src=\"href.png\" alt=\"replaced text\" title=\"text\"></p>\n", transform);
        }
    }
Esempio n. 12
0
    public void RendererTest()
    {
        var input = @"
```
the code
```
---";

        var rendereMethods = new RenderMethods
        {
            Code = @"function(code,language) {
  return '<mycode>' + code + '</mycode>';
};",
            Hr   = "function(){ return '<myhr>';}"
        };

        using (var markdownify = new Markdownify(new Options(), rendereMethods))
        {
            var transform = markdownify.Transform(input);
            Assert.AreEqual("<mycode>the code</mycode><myhr>", transform);
        }
    }
Esempio n. 13
0
    public void InlineHtmlTest()
    {
        var input = @"
        <table>
        <thead>
        <tr>
        <th>Tables</th>
        <th >Are</th>
        <th >Cool</th>
        </tr>
        </thead>
        <tbody>
        <tr>
        <td>col 3 is</td>
        <td >right-aligned</td>
        <td >$1600</td>
        </tbody>
        </table>";

        using (var markdownify = new Markdownify())
        {
            Approvals.Verify(markdownify.Transform(input).FixNewLines());
        }
    }
Esempio n. 14
0
    public void InlineHtmlTest()
    {
        var input = @"
<table>
<thead>
<tr>
<th>Tables</th>
<th >Are</th>
<th >Cool</th>
</tr>
</thead>
<tbody>
<tr>
<td>col 3 is</td>
<td >right-aligned</td>
<td >$1600</td>
</tbody>
</table>";

        using (var markdownify = new Markdownify())
        {
            Approvals.Verify(markdownify.Transform(input).FixNewLines());
        }
    }
Esempio n. 15
0
    public void TableTest()
    {
        var input = @"
        | Tables        | Are           | Cool  |
        | ------------- |:-------------:| -----:|
        | col 3 is      | right-aligned | $1600 |
        | col 2 is      | centered      |   $12 |
        | zebra stripes | are neat      |    $1 |
        ";

        using (var markdownify = new Markdownify())
        {
            Approvals.Verify(markdownify.Transform(input).FixNewLines());
        }
    }
Esempio n. 16
0
 public void MultiLineCodeWithhighlightTest()
 {
     var input = @"
     ```
     the code
     ```";
     var options = new Options
     {
         Highlight = "function (code) {return 'before' + code + 'after';}"
     };
     using (var markdownify = new Markdownify(options, new RenderMethods()))
     {
         var transform = markdownify.Transform(input);
         Assert.AreEqual("<pre><code>beforethe codeafter\n</code></pre>", transform);
     }
 }
Esempio n. 17
0
    public void Sample()
    {
        var input = @"
        | Tables        | Are           | Cool  |
        | ------------- |:-------------:| -----:|
        | col 3 is      | right-aligned | $1600 |
        | col 2 is      | centered      |   $12 |
        ";

        using (var markdownify = new Markdownify())
        {
            Debug.WriteLine(markdownify.Transform(input));
        }
    }