Exemplo n.º 1
0
 def test_autolink(self):
     t = "https://hrabal.github.io/TemPy"
     r = T.from_markdown(t)
     self.assertEqual(
         r[0].render(),
         '<p><a href="https://hrabal.github.io/TemPy">https://hrabal.github.io/TemPy</a></p>'
     )
Exemplo n.º 2
0
 def test_img(self):
     t = '![alt text](foo.png "Title text")'
     r = T.from_markdown(t)
     self.assertEqual(
         Counter(r[0].render()),
         Counter(
             '<p><img src="foo.png" alt="alt text" title="Title text"/></p>'
         ))
Exemplo n.º 3
0
    def test_code_block(self):
        t = """```
some code here
```
        """
        r = T.from_markdown(t)
        self.assertEqual(''.join(t.render() for t in r),
                         '<pre><code>some code here</code></pre>')
Exemplo n.º 4
0
    def test_line_break(self):
        t = """Text in a paragraph that ends with two spaces  
other text"""
        r = T.from_markdown(t)
        self.assertEqual(
            r[0].render(),
            '<p>Text in a paragraph that ends with two spaces<br/>other text</p>'
        )
Exemplo n.º 5
0
    def test_code_block_lang(self):
        t = """```python
some code here
```
        """
        r = T.from_markdown(t)
        self.assertEqual(
            ''.join(t.render() for t in r),
            '<pre><code class="lang-python">some code here</code></pre>')
Exemplo n.º 6
0
    def test_list_numbered(self):
        t = """Important Numbered list:
 
   1. foo
   2. bar
   3. baz"""
        r = T.from_markdown(t)
        self.assertEqual(
            ''.join(t.render() for t in r),
            '<p>Important Numbered list:</p><ol><li>foo</li><li>bar</li><li>baz</li></ol>'
        )
Exemplo n.º 7
0
    def test_list(self):
        t = """Important list:
 
   * foo
   * bar
   * baz"""
        r = T.from_markdown(t)
        self.assertEqual(
            ''.join(t.render() for t in r),
            '<p>Important list:</p><ul><li>foo</li><li>bar</li><li>baz</li></ul>'
        )
Exemplo n.º 8
0
    def test_table_non_styled_non_pretty(self):
        t = """Test markdown table non pretty

Markdown | Less | Pretty
--- | --- | ---
*Still* | `renders` | **nicely**
1 | 2 | 3"""
        r = T.from_markdown(t)
        self.assertEqual(
            ''.join(t.render() for t in r),
            '<p>Test markdown table non pretty</p><table><thead><tr><th>Markdown</th><th>Less</th><th>Pretty</th></tr></thead><tbody><tr><td><em>Still</em></td><td><code>renders</code></td><td><strong>nicely</strong></td></tr><tr><td>1</td><td>2</td><td>3</td></tr></tbody></table>'
        )
Exemplo n.º 9
0
    def test_table_styled(self):
        t = """Test markdown table

| Tables        | Are           | Cool  |
| ------------- |:-------------:| -----:|
| col 3 is      | right-aligned | $1600 |
| col 2 is      | centered      |   $12 |
| zebra stripes | are neat      |    $1 |"""
        r = T.from_markdown(t)
        self.assertEqual(
            ''.join(t.render() for t in r),
            '<p>Test markdown table</p><table><thead><tr><th>Tables</th><th style="text-align: center;">Are</th><th style="text-align: right;">Cool</th></tr></thead><tbody><tr><td>col 3 is</td><td style="text-align: center;">right-aligned</td><td style="text-align: right;">$1600</td></tr><tr><td>col 2 is</td><td style="text-align: center;">centered</td><td style="text-align: right;">$12</td></tr><tr><td>zebra stripes</td><td style="text-align: center;">are neat</td><td style="text-align: right;">$1</td></tr></tbody></table>'
        )
Exemplo n.º 10
0
    def test_table_non_styled(self):
        t = """Test markdown table

| Tables        | Are           | Cool  |
| ------------- | ------------- | ----- |
| col 3 is      | foo           | $1600 |
| col 2 is      | bar.          |   $12 |
| zebra stripes | baz.          |    $1 |"""
        r = T.from_markdown(t)
        self.assertEqual(
            ''.join(t.render() for t in r),
            '<p>Test markdown table</p><table><thead><tr><th>Tables</th><th>Are</th><th>Cool</th></tr></thead><tbody><tr><td>col 3 is</td><td>foo</td><td>$1600</td></tr><tr><td>col 2 is</td><td>bar.</td><td>$12</td></tr><tr><td>zebra stripes</td><td>baz.</td><td>$1</td></tr></tbody></table>'
        )
Exemplo n.º 11
0
 def test_strikethrough(self):
     t = """~~strikethrough~~"""
     r = T.from_markdown(t)
     self.assertEqual(r[0].render(), '<p><del>strikethrough</del></p>')
Exemplo n.º 12
0
 def test_code_inline(self):
     t = """`monospace`"""
     r = T.from_markdown(t)
     self.assertEqual(r[0].render(), '<p><code>monospace</code></p>')
Exemplo n.º 13
0
 def test_bold(self):
     t = """**bold**"""
     r = T.from_markdown(t)
     self.assertEqual(r[0].render(), '<p><strong>bold</strong></p>')
Exemplo n.º 14
0
 def test_italic(self):
     t = """*italic*"""
     r = T.from_markdown(t)
     self.assertEqual(r[0].render(), '<p><em>italic</em></p>')
Exemplo n.º 15
0
 def test_h3_heading(self):
     t = """### H3 heading"""
     r = T.from_markdown(t)
     self.assertEqual(r[0].render(), '<h3>H3 heading</h3>')
Exemplo n.º 16
0
    def test_sub_heading(self):
        t = """Sub-heading
 -----------"""
        r = T.from_markdown(t)
        self.assertEqual(r[0].render(), '<h2>Sub-heading</h2>')
Exemplo n.º 17
0
 def test_hr(self):
     t = "---"
     r = T.from_markdown(t)
     self.assertEqual(r[0].render(), '<hr/>')
Exemplo n.º 18
0
 def test_link(self):
     t = """A [link](https://hrabal.github.io/TemPy/)."""
     r = T.from_markdown(t)
     self.assertEqual(
         r[0].render(),
         '<p>A <a href="https://hrabal.github.io/TemPy/">link</a>.</p>')
Exemplo n.º 19
0
 def test_email_link(self):
     t = "<*****@*****.**>"
     r = T.from_markdown(t)
     self.assertEqual(
         r[0].render(),
         '<p><a href="mailto:[email protected]">[email protected]</a></p>')
Exemplo n.º 20
0
 def test_markdown_return_P_wrap(self):
     t = 'Lorem ipsum'
     r = T.from_markdown(t)
     self.assertIsInstance(r[0], P)
Exemplo n.º 21
0
 def test_markdown_return_empty(self):
     t = ''
     r = T.from_markdown(t)
     self.assertEqual(r, [])
     self.assertIsInstance(r, list)
Exemplo n.º 22
0
 def test_quote(self):
     t = "> this is a quote"
     r = T.from_markdown(t)
     self.assertEqual(r[0].render(),
                      '<blockquote><p>this is a quote</p></blockquote>')
Exemplo n.º 23
0
 def test_markdown_escape(self):
     t = """&"""
     r = T.from_markdown(t)
     self.assertEqual(r[0].render(), '<p>&amp;</p>')
Exemplo n.º 24
0
 def test_heading(self):
     t = """Heading
         ======="""
     r = T.from_markdown(t)
     self.assertEqual(r[0].render(), '<h1>Heading</h1>')