Exemplo n.º 1
0
 def test_internal_tag_link(self):
     """Asserts links like 'tag:test-tag' work"""
     instr = 'tag:test-tag foobar'
     exp = '<a href="/tag/test-tag">tag:test-tag</a> foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 2
0
 def test_internal_tag_linked_with_quotes_and_space(self):
     """Asserts links like 'tag:"test tag"' work"""
     instr = 'tag:"test tag" foobar'
     exp = '<a href="/tag/test%20tag">tag:"test tag"</a> foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 3
0
    def test_evil_markdown(self):
        instr = 'Evil <script src="http://evilserver.net/evil.js";>'
        exp = '''<p>Evil [HTML_REMOVED]
</p>'''
        format = MarkdownFormat()
        out = format.to_html(instr)
        assert out == exp, out
Exemplo n.º 4
0
 def test_malformed_link_3(self):
     instr = u'<a href="http://url.com"> url'
     exp = '<a href="http://url.com" target="_blank" rel="nofollow"> url'
     # NB when this is put into Genshi, it will close the tag for you.
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 5
0
 def test_tag_names_with_unicode_alphanumeric(self):
     """Asserts that unicode alphanumeric characters are captured"""
     instr = u'tag:"Japanese katakana \u30a1" blah'
     exp = u'<a href="/tag/Japanese%20katakana%20%E3%82%A1">tag:"Japanese katakana \u30a1"</a>'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, u'\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 6
0
 def test_tag_names_with_unicode_alphanumeric(self):
     """Asserts that unicode alphanumeric characters are captured"""
     instr = u'tag:"Japanese katakana \u30a1" blah'
     exp = u'<a href="/tag/Japanese%20katakana%20%E3%82%A1">tag:"Japanese katakana \u30a1"</a>'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, u'\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 7
0
 def test_tag_names_match_simple_punctuation(self):
     """Asserts punctuation and capital letters are matched in the tag name"""
     instr = 'tag:"Test- _." foobar'
     exp = '<a href="/tag/Test-%20_.">tag:"Test- _."</a> foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 8
0
 def test_tag_names_do_not_match_commas(self):
     """Asserts commas don't get matched as part of a tag name"""
     instr = 'tag:Test,tag foobar'
     exp = '<a href="/tag/Test">tag:Test</a>,tag foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 9
0
 def test_internal_tag_with_no_opening_quote_wont_match_the_closing_quote(self):
     """Asserts that 'tag:test" tag' is matched, but to 'tag:test'"""
     instr = 'tag:test" foobar' # should match 'tag:test'
     exp = '<a href="/tag/test">tag:test</a>" foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 10
0
 def test_malformed_link_3(self):
     instr = u'<a href="http://url.com"> url'
     exp = '<a href="http://url.com" target="_blank" rel="nofollow"> url'
     # NB when this is put into Genshi, it will close the tag for you.
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 11
0
 def test_internal_tag_with_no_opening_quote_only_matches_single_word(self):
     """Asserts that without an opening quote only one word is matched"""
     instr = 'tag:test tag" foobar' # should match 'tag:test'
     exp = '<a href="/tag/test">tag:test</a> tag" foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 12
0
 def test_internal_tag_linked_with_quotes_and_space(self):
     """Asserts links like 'tag:"test tag"' work"""
     instr = 'tag:"test tag" foobar'
     exp = '<a href="/tag/test%20tag">tag:"test tag"</a> foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 13
0
 def test_internal_tag_link(self):
     """Asserts links like 'tag:test-tag' work"""
     instr = 'tag:test-tag foobar'
     exp = '<a href="/tag/test-tag">tag:test-tag</a> foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 14
0
 def test_internal_tag_with_no_opening_quote_only_matches_single_word(self):
     """Asserts that without an opening quote only one word is matched"""
     instr = 'tag:test tag" foobar'  # should match 'tag:test'
     exp = '<a href="/tag/test">tag:test</a> tag" foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 15
0
 def test_tag_names_match_simple_punctuation(self):
     """Asserts punctuation and capital letters are matched in the tag name"""
     instr = 'tag:"Test- _." foobar'
     exp = '<a href="/tag/Test-%20_.">tag:"Test- _."</a> foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 16
0
 def test_tag_names_do_not_match_commas(self):
     """Asserts commas don't get matched as part of a tag name"""
     instr = 'tag:Test,tag foobar'
     exp = '<a href="/tag/Test">tag:Test</a>,tag foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 17
0
    def test_evil_markdown(self):
        instr = 'Evil <script src="http://evilserver.net/evil.js";>'
        exp = '''<p>Evil [HTML_REMOVED]
</p>'''
        format = MarkdownFormat()
        out = format.to_html(instr)
        assert out == exp, out
Exemplo n.º 18
0
 def test_internal_tag_with_no_opening_quote_wont_match_the_closing_quote(
         self):
     """Asserts that 'tag:test" tag' is matched, but to 'tag:test'"""
     instr = 'tag:test" foobar'  # should match 'tag:test'
     exp = '<a href="/tag/test">tag:test</a>" foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 19
0
 def test_tag_names_dont_match_non_space_whitespace(self):
     """Asserts that the only piece of whitespace matched in a tagname is a space"""
     whitespace_characters = '\t\n\r\f\v'
     for ch in whitespace_characters:
         instr = 'tag:Bad' + ch + 'space'
         exp = '<a href="/tag/Bad">tag:Bad</a>'
         format = MarkdownFormat()
         out = format.to_html(instr)
         assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 20
0
 def test_tag_names_dont_match_non_space_whitespace(self):
     """Asserts that the only piece of whitespace matched in a tagname is a space"""
     whitespace_characters = '\t\n\r\f\v'
     for ch in whitespace_characters:
         instr = 'tag:Bad' + ch + 'space'
         exp = '<a href="/tag/Bad">tag:Bad</a>'
         format = MarkdownFormat()
         out = format.to_html(instr)
         assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 21
0
    def test_multiline_links(self):
        instr = u'''I get 10 times more traffic from [Google][] than from
[Yahoo][] or [MSN][].

  [google]: http://google.com/        "Google"
  [yahoo]:  http://search.yahoo.com/  "Yahoo Search"
  [msn]:    http://search.msn.com/    "MSN Search"'''
        exp = '''I get 10 times more traffic from <a href="http://google.com/" title="Google">Google</a> than from
   <a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.'''
        # NB when this is put into Genshi, it will close the tag for you.
        format = MarkdownFormat()
        out = format.to_html(instr)
        assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 22
0
    def test_multiline_links(self):
        instr = u'''I get 10 times more traffic from [Google][] than from
[Yahoo][] or [MSN][].

  [google]: http://google.com/        "Google"
  [yahoo]:  http://search.yahoo.com/  "Yahoo Search"
  [msn]:    http://search.msn.com/    "MSN Search"'''
        exp = '''I get 10 times more traffic from <a href="http://google.com/" title="Google">Google</a> than from
   <a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.'''
        # NB when this is put into Genshi, it will close the tag for you.
        format = MarkdownFormat()
        out = format.to_html(instr)
        assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 23
0
    def test_markdown(self):
        instr = '''# Hello World

**Some bolded text.**

*Some italicized text.*
'''
        exp = '''<h1>Hello World</h1>
<p><strong>Some bolded text.</strong>
</p>
<p><em>Some italicized text.</em>
</p>'''
        format = MarkdownFormat()
        out = format.to_html(instr)
        assert out == exp
Exemplo n.º 24
0
    def test_markdown(self):
        instr = '''# Hello World

**Some bolded text.**

*Some italicized text.*
'''
        exp = '''<h1>Hello World</h1>
<p><strong>Some bolded text.</strong>
</p>
<p><em>Some italicized text.</em>
</p>'''
        format = MarkdownFormat()
        out = format.to_html(instr)
        assert out == exp
Exemplo n.º 25
0
 def test_malformed_link_2(self):
     instr = u'<a href="http://url.com> url >'
     exp = '<a href="TAG MALFORMED" target="_blank" rel="nofollow"> url &gt;'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 26
0
 def test_malformed_link_1(self):
     instr = u'<a href=\u201dsomelink\u201d>somelink</a>'
     exp = '<a href="TAG MALFORMED" target="_blank" rel="nofollow">somelink</a>'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 27
0
 def test_auto_link_after_whitespace(self):
     instr = 'go to http://somelink.com'
     exp = 'go to <a href="http://somelink.com" target="_blank" rel="nofollow">http://somelink.com</a>'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 28
0
 def test_normal_link(self):
     instr = '<http://somelink/>'
     exp = '<a href="http://somelink/" target="_blank" rel="nofollow">http://somelink/</a>'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 29
0
 def test_internal_link(self):
     instr = 'package:test-_pkg'
     exp = '<a href="/package/test-_pkg">package:test-_pkg</a>'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 30
0
 def test_auto_link_after_whitespace(self):
     instr = 'go to http://somelink.com'
     exp = 'go to <a href="http://somelink.com" target="_blank" rel="nofollow">http://somelink.com</a>'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 31
0
 def test_markdown_blank(self):
     instr = None
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert out == ''
Exemplo n.º 32
0
 def test_internal_tag_with_no_closing_quote_does_not_match(self):
     """Asserts that without an opening quote only one word is matched"""
     instr = 'tag:"test tag foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert "<a href" not in out
Exemplo n.º 33
0
 def test_malformed_link_2(self):
     instr = u'<a href="http://url.com> url >'
     exp = '<a href="TAG MALFORMED" target="_blank" rel="nofollow"> url &gt;'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 34
0
 def test_malformed_link_1(self):
     instr = u'<a href=\u201dsomelink\u201d>somelink</a>'
     exp = '<a href="TAG MALFORMED" target="_blank" rel="nofollow">somelink</a>'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 35
0
 def test_normal_link(self):
     instr = '<http://somelink/>'
     exp = '<a href="http://somelink/" target="_blank" rel="nofollow">http://somelink/</a>'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 36
0
 def test_internal_link(self):
     instr = 'package:test-_pkg'
     exp = '<a href="/package/test-_pkg">package:test-_pkg</a>'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, '\nGot: %s\nWanted: %s' % (out, exp)
Exemplo n.º 37
0
 def test_internal_tag_with_no_closing_quote_does_not_match(self):
     """Asserts that without an opening quote only one word is matched"""
     instr = 'tag:"test tag foobar'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert "<a href" not in out
Exemplo n.º 38
0
 def test_markdown_blank(self):
     instr = None
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert out == ''
Exemplo n.º 39
0
 def test_normal_link(self):
     instr = "<http:/somelink/>"
     exp = '<a href="http:/somelink/">http:/somelink/</a>'
     format = MarkdownFormat()
     out = format.to_html(instr)
     assert exp in out, "\nGot: %s\nWanted: %s" % (out, exp)