Пример #1
0
 def test_block_quotes_preceded_by_spaces(self):
     markdown = self.r(
         'A wise man once said:\n\n' \
         ' > Isn\'t it wonderful just to be alive.\n')
     ok(markdown).diff(
         '<p>A wise man once said:</p>\n\n' \
         '<blockquote>\n<p>Isn&#39;t it wonderful just to be alive.</p>\n</blockquote>\n')
Пример #2
0
 def test_block_quotes_preceded_by_spaces(self):
     markdown = self.r(
         'A wise man once said:\n\n' \
         ' > Isn\'t it wonderful just to be alive.\n')
     ok(markdown).diff(
         '<p>A wise man once said:</p>\n\n' \
         '<blockquote>\n<p>Isn&#39;t it wonderful just to be alive.</p>\n</blockquote>\n')
Пример #3
0
    def test_tables(self):
        text = ' aaa | bbbb\n' \
            '-----|------\n' \
            'hello|sailor\n'

        ok(self.render_with(text)).not_contains('<table')
        ok(self.render_with(text, extensions=EXT_TABLES)).contains('<table')
Пример #4
0
    def test_tables(self):
        text = ' aaa | bbbb\n' \
            '-----|------\n' \
            'hello|sailor\n'

        ok(self.render_with(text)).not_contains('<table')
        ok(self.render_with(text, extensions=EXT_TABLES)).contains('<table')
Пример #5
0
 def test_html_block_end_tag_on_same_line(self):
     markdown = self.r(
         'Para 1\n\n<div><pre>HTML block\n</pre></div>\n\nPara 2 [Link](#anchor)'
     )
     ok(markdown).diff(
         '<p>Para 1</p>\n\n<div><pre>HTML block\n</pre></div>\n\n<p>Para 2 <a href=\"#anchor\">Link</a></p>\n'
     )
Пример #6
0
 def test_autolinking_with_ent_chars(self):
     markdown = self.render_with(
         'This a stupid link: https://github.com/rtomayko/tilt/issues?milestone=1&state=open',
         extensions=EXT_AUTOLINK)
     ok(markdown).diff(
         '<p>This a stupid link: <a href=\"https://github.com/rtomayko/tilt/issues?milestone=1&amp;state=open\">https://github.com/rtomayko/tilt/issues?milestone=1&amp;state=open</a></p>\n'
     )
Пример #7
0
 def test_whitespace_after_urls(self):
     markdown = self.render_with(
         'Japan: http://www.abc.net.au/news/events/japan-quake-2011/beforeafter.htm (yes, japan)',
         extensions=EXT_AUTOLINK)
     ok(markdown).diff(
         '<p>Japan: <a href="http://www.abc.net.au/news/events/japan-quake-2011/beforeafter.htm">http://www.abc.net.au/news/events/japan-quake-2011/beforeafter.htm</a> (yes, japan)</p>\n'
     )
Пример #8
0
 def test_headings_with_trailing_space(self):
     markdown = self.render_with(
         'The Ant-Sugar Tales \n' \
         '=================== \n\n' \
         'By Candice Yellowflower   \n',
         extensions=EXT_LAX_HTML_BLOCKS)
     ok(markdown).diff('<h1>The Ant-Sugar Tales </h1>\n\n<p>By Candice Yellowflower   </p>\n')
Пример #9
0
 def test_block_quotes(self):
     text = self.br.render(
         'A wise man once said:\n\n'
         ' > Isn\'t it wonderful just to be alive.\n')
     ok(text).diff('<p>A wise man once said:</p>\n'
                   '<blockquote cite="my">\n'
                   '<p>Isn&#39;t it wonderful just to be alive.</p>\n</blockquote>')
Пример #10
0
    def test_intra_emphasis(self):
        markdown = self.r('foo_bar_baz')
        ok(markdown).diff('<p>foo<em>bar</em>baz</p>\n')

        markdown = self.render_with('foo_bar_baz',
                                    extensions=EXT_NO_INTRA_EMPHASIS)
        ok(markdown).diff('<p>foo_bar_baz</p>\n')
Пример #11
0
    def test_inline_markdown_start_end(self):
        markdown = self.render_with('_start _ foo_bar bar_baz _ end_ *italic* **bold** <a>_blah_</a>',
            extensions=EXT_NO_INTRA_EMPHASIS)
        ok(markdown).diff('<p><em>start _ foo_bar bar_baz _ end</em> <em>italic</em> <strong>bold</strong> <a><em>blah</em></a></p>\n')

        markdown = self.r('Run \'rake radiant:extensions:rbac_base:migrate\'')
        ok(markdown).diff('<p>Run &#39;rake radiant:extensions:rbac_base:migrate&#39;</p>\n')
Пример #12
0
 def test_whitespace_after_urls(self):
     markdown = self.render_with('Japan: http://www.abc.net.au/news/events/'
                                 'japan-quake-2011/beforeafter.htm (yes, japan)',
                                 extensions=EXT_AUTOLINK)
     ok(markdown).diff('<p>Japan: <a href="http://www.abc.net.au/news/events/'
                       'japan-quake-2011/beforeafter.htm">http://www.abc.net.'
                       'au/news/events/japan-quake-2011/beforeafter.htm</a> (yes, japan)</p>\n')
Пример #13
0
 def test_infinite_loop_in_header(self):
     markdown = self.render_with(
         '######\n' \
         '#Body#\n' \
         '######\n',
         extensions=EXT_LAX_HTML_BLOCKS)
     ok(markdown).diff('<h1>Body</h1>\n')
Пример #14
0
 def test_html_block_not_wrapped_in_p(self):
     markdown = self.render_with(
         'Things to watch out for\n\n' \
         '<ul>\n<li>Blah</li>\n</ul>\n',
         extensions=EXT_LAX_SPACING)
     ok(markdown).diff(
         '<p>Things to watch out for</p>\n\n' \
         '<ul>\n<li>Blah</li>\n</ul>\n')
Пример #15
0
    def test_hard_wrap(self):
        markdown = self.render_with(HTML_HARD_WRAP, '''
Hello world,
this is just a simple test

With hard wraps
and other *things*.''')
        ok(markdown).contains('<br>')
Пример #16
0
 def test_autolinking_with_ent_chars(self):
     markdown = self.render_with('This a stupid link: https://github.com/'
                                 'rtomayko/tilt/issues?milestone=1&state=open',
                                 extensions=EXT_AUTOLINK)
     ok(markdown).diff('<p>This a stupid link: <a href=\"https://github.com/'
                       'rtomayko/tilt/issues?milestone=1&amp;state=open\">'
                       'https://github.com/rtomayko/tilt/issues?milestone=1'
                       '&amp;state=open</a></p>\n')
Пример #17
0
 def test_html_block_not_wrapped_in_p(self):
     markdown = self.render_with(
         'Things to watch out for\n' \
         '<ul>\n<li>Blah</li>\n</ul>\n',
         extensions=EXT_LAX_HTML_BLOCKS)
     ok(markdown).diff(
         '<p>Things to watch out for</p>\n\n' \
         '<ul>\n<li>Blah</li>\n</ul>\n')
Пример #18
0
 def test_headings_with_trailing_space(self):
     markdown = self.render_with(
         'The Ant-Sugar Tales \n' \
         '=================== \n\n' \
         'By Candice Yellowflower   \n')
     ok(markdown).diff(
         '<h1>The Ant-Sugar Tales </h1>\n\n<p>By Candice Yellowflower   </p>\n'
     )
Пример #19
0
    def test_hard_wrap(self):
        markdown = self.render_with(
            HTML_HARD_WRAP, '''
Hello world,
this is just a simple test

With hard wraps
and other *things*.''')
        ok(markdown).contains('<br>')
Пример #20
0
    def test_unicode(self):
        tests_dir = path.dirname(__file__)

        with codecs.open(path.join(tests_dir, 'unicode.txt'), 'r', encoding='utf-8') as fd:
            text = fd.read()
        with codecs.open(path.join(tests_dir, 'unicode.html'), 'r', encoding='utf-8') as fd:
            html = fd.read()

        markdown = self.r(text)
        ok(markdown).diff(html)
Пример #21
0
    def test_inline_markdown_start_end(self):
        markdown = self.render_with(
            '_start _ foo_bar bar_baz _ end_ *italic* **bold** <a>_blah_</a>',
            extensions=EXT_NO_INTRA_EMPHASIS)
        ok(markdown).diff(
            '<p><em>start _ foo_bar bar_baz _ end</em> <em>italic</em> <strong>bold</strong> <a><em>blah</em></a></p>\n'
        )

        markdown = self.r('Run \'rake radiant:extensions:rbac_base:migrate\'')
        ok(markdown).diff(
            '<p>Run &#39;rake radiant:extensions:rbac_base:migrate&#39;</p>\n')
Пример #22
0
        def test():
            with codecs.open(text_path, 'r', encoding='utf-8') as fd:
                text = fd.read()
            with codecs.open(html_path, 'r', encoding='utf-8') as fd:
                expected_html = fd.read()

            actual_html = self.r(text)
            expected_result = clean_html(expected_html)
            actual_result = clean_html(actual_html)

            ok(actual_result).diff(expected_result)
Пример #23
0
        def test():
            with codecs.open(text_path, 'r', encoding='utf-8') as fd:
                text = fd.read()
            with codecs.open(html_path, 'r', encoding='utf-8') as fd:
                expected_html = fd.read()

            actual_html = self.r(text)
            expected_result = clean_html(expected_html)
            actual_result = clean_html(actual_html)

            ok(actual_result).diff(expected_result)
Пример #24
0
    def test_fenced_code_blocks(self):
        text = '''
This is a simple test

~~~~~
This is some awesome code
    with tabs and shit
~~~
'''

        ok(self.render_with(text)).not_contains('<code')
        ok(self.render_with(text, extensions=EXT_FENCED_CODE)).contains('<code')
Пример #25
0
    def test_fenced_code_blocks(self):
        text = '''
This is a simple test

~~~~~
This is some awesome code
    with tabs and shit
~~~
'''

        ok(self.render_with(text)).not_contains('<code')
        ok(self.render_with(text,
                            extensions=EXT_FENCED_CODE)).contains('<code')
Пример #26
0
    def test_unicode(self):
        tests_dir = path.dirname(__file__)

        with codecs.open(path.join(tests_dir, 'unicode.txt'),
                         'r',
                         encoding='utf-8') as fd:
            text = fd.read()
        with codecs.open(path.join(tests_dir, 'unicode.html'),
                         'r',
                         encoding='utf-8') as fd:
            html = fd.read()

        markdown = self.r(text)
        ok(markdown).diff(html)
Пример #27
0
    def test_escape_html(self):
        source = '''
Through <em>NO</em> <script>DOUBLE NO</script>

<script>BAD</script>

<img src="/favicon.ico" />
'''

        expected = clean_html('''
<p>Through &lt;em&gt;NO&lt;/em&gt; &lt;script&gt;DOUBLE NO&lt;/script&gt;</p>

<p>&lt;script&gt;BAD&lt;/script&gt;</p>

<p>&lt;img src=&quot;/favicon.ico&quot; /&gt;</p>
''')

        markdown = clean_html(self.render_with(HTML_ESCAPE, source))
        ok(markdown).diff(expected)
Пример #28
0
    def test_escape_html(self):
        source = '''
Through <em>NO</em> <script>DOUBLE NO</script>

<script>BAD</script>

<img src="/favicon.ico" />
'''

        expected = clean_html('''
<p>Through &lt;em&gt;NO&lt;/em&gt; &lt;script&gt;DOUBLE NO&lt;/script&gt;</p>

<p>&lt;script&gt;BAD&lt;/script&gt;</p>

<p>&lt;img src=&quot;/favicon.ico&quot; /&gt;</p>
''')

        markdown = clean_html(self.render_with(HTML_ESCAPE, source))
        ok(markdown).diff(expected)
Пример #29
0
    def test_get_and_set(self):
        self.db.get('test_get_and_set', callback=self.stop)
        ok(self.wait()) == None

        self.db.set('test_get_and_set', 'value', callback=self.stop)
        ok(self.wait()) == 'OK'

        self.db.get('test_get_and_set', callback=self.stop)
        ok(self.wait()) == 'value'
Пример #30
0
    def test_exists(self):
        self.db.set('test_exists', 'value', callback=self.stop)
        ok(self.wait()) == 'OK'

        self.db.exists('test_exists', callback=self.stop)
        ok(self.wait()) == 1

        self.db.exists('test_not_exists', callback=self.stop)
        ok(self.wait()) == 0
Пример #31
0
    def test_exists(self):
        self.db.set('test_exists', 'value', callback=self.stop)
        ok(self.wait()) == 'OK'

        self.db.exists('test_exists', callback=self.stop)
        ok(self.wait()) == 1

        self.db.exists('test_not_exists', callback=self.stop)
        ok(self.wait()) == 0
Пример #32
0
    def test_get_and_set(self):
        self.db.get('test_get_and_set', callback=self.stop)
        ok(self.wait()) == None

        self.db.set('test_get_and_set', 'value', callback=self.stop)
        ok(self.wait()) == 'OK'

        self.db.get('test_get_and_set', callback=self.stop)
        ok(self.wait()) == 'value'
Пример #33
0
    def test_fenced_code_blocks_without_space(self):
        text = 'foo\nbar\n```\nsome\ncode\n```\nbaz'

        ok(self.render_with(text)).not_contains('<pre><code>')
        ok(self.render_with(text, extensions=EXT_FENCED_CODE
                            | EXT_LAX_SPACING)).contains('<pre><code>')
Пример #34
0
 def test_single_quotes_d(self):
     html = self.r('<p>what\'d you say?</p>\n')
     ok(html).diff('<p>what&rsquo;d you say?</p>\n')
Пример #35
0
 def test_single_quotes_ve(self):
     html = self.r('<p>I\'ve been meaning to tell you ..</p>\n')
     ok(html).diff('<p>I&rsquo;ve been meaning to tell you ..</p>\n')
Пример #36
0
 def test_single_quotes_ll(self):
     html = self.r('<p>Well that\'ll be the day</p>\n')
     ok(html).diff('<p>Well that&rsquo;ll be the day</p>\n')
Пример #37
0
 def test_single_quotes_ve(self):
     html = self.r('<p>I\'ve been meaning to tell you ..</p>\n')
     ok(html).diff('<p>I&rsquo;ve been meaning to tell you ..</p>\n')
Пример #38
0
 def test_spaced_headers(self):
     text = '#123 a header yes\n'
     ok(self.render_with(text,
                         extensions=EXT_SPACE_HEADERS)).not_contains('<h1>')
Пример #39
0
 def test_html_block_end_tag_on_same_line(self):
     markdown = self.r('Para 1\n\n<div><pre>HTML block\n</pre></div>\n\nPara 2 [Link](#anchor)')
     ok(markdown).diff('<p>Para 1</p>\n\n<div><pre>HTML block\n</pre></div>\n\n<p>Para 2 <a href=\"#anchor\">Link</a></p>\n')
Пример #40
0
 def test_autolink(self):
     markdown = self.render_with('http://axr.vg/', extensions=EXT_AUTOLINK)
     ok(markdown).diff(
         '<p><a href=\"http://axr.vg/\">http://axr.vg/</a></p>\n')
Пример #41
0
 def test_tags_with_dashes_and_underscored(self):
     markdown = self.r(
         'foo <asdf-qwerty>bar</asdf-qwerty> and <a_b>baz</a_b>')
     ok(markdown).diff(
         '<p>foo <asdf-qwerty>bar</asdf-qwerty> and <a_b>baz</a_b></p>\n')
Пример #42
0
 def test_spaced_headers(self):
     text = '#123 a header yes\n'
     ok(self.render_with(text, extensions=EXT_SPACE_HEADERS)).not_contains('<h1>')
Пример #43
0
 def test_linkable_headers(self):
     markdown = self.r('### Hello [GitHub](http://github.com)')
     ok(markdown).diff('<h3>Hello <a href=\"http://github.com\">GitHub</a></h3>\n')
Пример #44
0
 def test_single_quotes_re(self):
     html = self.r('<p>They\'re not for sale.</p>\n')
     ok(html).diff('<p>They&rsquo;re not for sale.</p>\n')
Пример #45
0
 def test_single_quotes_ll(self):
     html = self.r('<p>Well that\'ll be the day</p>\n')
     ok(html).diff('<p>Well that&rsquo;ll be the day</p>\n')
Пример #46
0
 def test_double_quotes_to_curly_quotes(self):
     html = self.r('<p>"Quoted text"</p>\n')
     ok(html).diff('<p>&ldquo;Quoted text&rdquo;</p>\n')
Пример #47
0
 def test_linkable_headers(self):
     markdown = self.r('### Hello [GitHub](http://github.com)')
     ok(markdown).diff(
         '<h3>Hello <a href=\"http://github.com\">GitHub</a></h3>\n')
Пример #48
0
 def test_no_link_in_code_blocks(self):
     markdown = self.r(
         '    This is a code block\n    This is a link [[1]] inside\n')
     ok(markdown).diff(
         '<pre><code>This is a code block\nThis is a link [[1]] inside\n</code></pre>\n'
     )
Пример #49
0
 def test_autolink(self):
     markdown = self.render_with('http://axr.vg/', extensions=EXT_AUTOLINK)
     ok(markdown).diff('<p><a href=\"http://axr.vg/\">http://axr.vg/</a></p>\n')
Пример #50
0
    def test_strikethrough(self):
        text = 'this is ~some~ striked ~~text~~'

        ok(self.render_with(text)).not_contains('<del')
        ok(self.render_with(text, extensions=EXT_STRIKETHROUGH)).contains('<del')
Пример #51
0
    def test_intra_emphasis(self):
        markdown = self.r('foo_bar_baz')
        ok(markdown).diff('<p>foo<em>bar</em>baz</p>\n')

        markdown = self.render_with('foo_bar_baz', extensions=EXT_NO_INTRA_EMPHASIS)
        ok(markdown).diff('<p>foo_bar_baz</p>\n')
Пример #52
0
 def test_infinite_loop_in_header(self):
     markdown = self.render_with(
         '######\n' \
         '#Body#\n' \
         '######\n')
     ok(markdown).diff('<h1>Body</h1>\n')
Пример #53
0
 def test_single_quotes_re(self):
     html = self.r('<p>They\'re not for sale.</p>\n')
     ok(html).diff('<p>They&rsquo;re not for sale.</p>\n')
Пример #54
0
 def test_no_link_in_code_blocks(self):
     markdown = self.r('    This is a code block\n    This is a link [[1]] inside\n')
     ok(markdown).diff('<pre><code>This is a code block\nThis is a link [[1]] inside\n</code></pre>\n')
Пример #55
0
 def test_double_quotes_to_curly_quotes(self):
     html = self.r('<p>"Quoted text"</p>\n')
     ok(html).diff('<p>&ldquo;Quoted text&rdquo;</p>\n')
Пример #56
0
    def test_strikethrough(self):
        text = 'this is ~some~ striked ~~text~~'

        ok(self.render_with(text)).not_contains('<del')
        ok(self.render_with(text,
                            extensions=EXT_STRIKETHROUGH)).contains('<del')
Пример #57
0
 def test_single_quotes_m(self):
     html = self.r('<p>I\'m not kidding</p>\n')
     ok(html).diff('<p>I&rsquo;m not kidding</p>\n')
Пример #58
0
 def test_tags_with_dashes_and_underscored(self):
     markdown = self.r('foo <asdf-qwerty>bar</asdf-qwerty> and <a_b>baz</a_b>')
     ok(markdown).diff('<p>foo <asdf-qwerty>bar</asdf-qwerty> and <a_b>baz</a_b></p>\n')
Пример #59
0
 def test_single_quotes_d(self):
     html = self.r('<p>what\'d you say?</p>\n')
     ok(html).diff('<p>what&rsquo;d you say?</p>\n')
Пример #60
0
 def test_single_quotes_m(self):
     html = self.r('<p>I\'m not kidding</p>\n')
     ok(html).diff('<p>I&rsquo;m not kidding</p>\n')