示例#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')