コード例 #1
0
    def test_figure_with_title_and_caption(self):
        result = markdown_to_html('![Alt text](/path/to/img.jpg "Optional title" (\'Optional figcaption\'))') 
        print result
        self.assertEqual(result, u"""<figure>
    <img alt="Alt text" src="/path/to/img.jpg" title="Optional title" />
    <figcaption>Optional figcaption</figcaption>
</figure>""")
コード例 #2
0
    def test_code_block(self):
        result = markdown_to_html("""``` shell
$ docker build -t knowru/plumber_example https://github.com/Knowru/plumber_example.git
```
``` shell
$ docker run -p 8000:8000 -d knowru/plumber_example
```""")
        self.assertEqual(result, u"""<pre class="brush: shell">
$ docker build -t knowru/plumber_example https://github.com/Knowru/plumber_example.git
</pre>

<pre class="brush: shell">
$ docker run -p 8000:8000 -d knowru/plumber_example
</pre>""")
コード例 #3
0
 def test_header(self):
     result = markdown_to_html('# this is a header')
     self.assertEqual(result, '<h1>this is a header</h1>')
コード例 #4
0
 def test_anchor_has_target_blank_and_is_not_alone(self):
     result = markdown_to_html('In [our last post (How to create a RESTful API for a machine learning credit model in R)](https://www.knowru.com/blog/how-create-restful-api-for-machine-learning-credit-model-in-r/ "How to create a RESTful API for a machine learning credit model in R")')
     self.assertEqual(result, '<p>In <a href="https://www.knowru.com/blog/how-create-restful-api-for-machine-learning-credit-model-in-r/" title="How to create a RESTful API for a machine learning credit model in R" target="_blank">our last post (How to create a RESTful API for a machine learning credit model in R)</a></p>')
コード例 #5
0
 def test_anchor_has_target_blank_and_is_alone(self):
     result = markdown_to_html('[content](http://url "title")')
     self.assertEqual(result, '<p><a href="http://url" title="title" target="_blank">content</a></p>')
コード例 #6
0
 def test_paragraph(self):
     result = markdown_to_html('this is a paragraph.')
     self.assertEqual(result, '<p>this is a paragraph.</p>')
コード例 #7
0
    def test_blockquote_with_footer_and_cite_content_and_title(self):
        result = markdown_to_html('> some content("some footer" ["cite content" "cite title"])')
        self.assertEqual(result, u"""<blockquote>
    <p>some content</p>
    <footer>some footer in <cite title="cite title">cite content</cite></footer>
</blockquote>""")
コード例 #8
0
    def test_figure_with_title_but_without_caption(self):
        result = markdown_to_html('![Alt text](/path/to/img.jpg "Optional title")') 
        self.assertEqual(result, u"""<figure>
    <img alt="Alt text" src="/path/to/img.jpg" title="Optional title" />
    <figcaption></figcaption>
</figure>""")