Example #1
0
def test_bug5():
    text = """
PROMPT='%{^[[1;32m%}[%{^[[36m%}%n@%m%{^[[1;32m%}]%{^[[00m%}%# '
RPROMPT='%{^[[1;32m%}(%{^[[36m%}%~%{^[[1;32m%})%{^[[00m%}%'
    """
    parser = AmiFormat()
    parser.htmlFormat(text)
Example #2
0
def test_http_links():
    text = """http://amix.dk/

This is a link: http://amix.dk/?dkd

[link=http://amix.dk/]"""
    parser = AmiFormat()
    r_text = removeWS(parser.htmlFormat(text))
    assert r_text == '<p><a href="http://amix.dk/">http://amix.dk/</a></p><p>This is a link: <a href="http://amix.dk/?dkd">http://amix.dk/?dkd</a></p><p>[link=http://amix.dk/]</p>'
Example #3
0
def test_bug11():
    text = """[[image=Fluffy]]"""
    parser = AmiFormat()

    def handler(args):
        return False, ''

    parser.registerSLPlugin('image', handler)
    r_text = removeWS(parser.htmlFormat(text))
    assert r_text == '<p>[]</p>'
Example #4
0
def test_bug8():
    text = """Here are some [random_colors=random colors]!"""

    def handler(args):
        return False, 'random colors'

    parser = AmiFormat()
    parser.registerSLPlugin('random_colors', handler)
    r_text = removeWS(parser.htmlFormat(text))
    assert r_text == '<p>Here are some random colors!</p>'
Example #5
0
def test_bug10():
    text = """* Test
[image]"""
    parser = AmiFormat()

    def handler(args):
        return False, None

    parser.registerSLPlugin('image', handler)
    r_text = removeWS(parser.htmlFormat(text))
    assert r_text == '<ul><li>Test<br />[image]</li></ul>'
Example #6
0
def test_bug9():
    text = """%(hl) Hej%
%(hl) [image=folder, global] my_sk_page%"""
    parser = AmiFormat()

    def handler(args):
        return False, None

    parser.registerSLPlugin('image', handler)
    r_text = removeWS(parser.htmlFormat(text))
    assert r_text == '<p><span class="hl">Hej</span><br /><span class="hl">[image=folder, global] my_sk_page</span></p>'
Example #7
0
def test_escapes():
    text1 = """
[escapestyle]
%(b) Test%
  Test
[/escapestyle]

[escapestyle]%(b) Test%[/escapestyle]

[dummy]"""
    parser = AmiFormat()
    r_text1 = removeWS(parser.htmlFormat(text1))
    assert r_text1 == '<p>%(b) Test%  Test</p><p>%(b) Test%</p><p>[dummy]</p>'
Example #8
0
def test_bug6():
    text = """
[lolly]
pop
[/lolly]

[lolly] pop [/lolly]

[comment]Hello[/comment]"""

    def handler(args):
        return True, '<div>%s</div>' % args['data']

    parser = AmiFormat()
    parser.registerMLPlugin('comment', handler)
    r_text1 = removeWS(parser.htmlFormat(text))
    assert r_text1 == '<p>[lolly]<br />pop<br />[/lolly]</p><p>[lolly] pop [/lolly]</p><div>Hello</div>'
Example #9
0
def test_bug7():
    text = """
h2. Example of use

This code:
[hlcode, language=python]
return True, '<div style="color: [escapestyle]%(color)s">%(data)s</div>' %[/escapestyle] args
parser = amiformat.AmiFormat()
parser.registerMLPlugin('comment', commentHandler)
text = "
h2 . Just a test

Here is a red comment:
[!comment, color=red]
I am red
[!/comment]"
print parser.htmlFormat(text)
[/hlcode]
    """
    parser = AmiFormat()

    def handler(args):
        return True, '<div>%s</div>' % args['data']

    parser.registerMLPlugin('comment', handler)
    parser.registerMLPlugin('hlcode', handler)
    r_text1 = removeWS(parser.htmlFormat(text))
Example #10
0
def test_sl_plugin():
    check = {}

    def handler(args):
        if args.has_key('data'):
            check['data'] = args['data']
            return True, None
        elif args.has_key('color'):
            check['color'] = args['color']
            return False, None

    parser = AmiFormat()
    parser.registerSLPlugin('ltx', handler)
    parser.registerMLPlugin('latex', handler)
    text = """
h2. My LaTeX
[ltx=2+2, color=red]
[latex] 2+2 [/latex]
[latex]
Test1
Test2
[/latex]
[dummy]"""
    result = removeWS(parser.htmlFormat(text))
    assert check['data'] == 'Test1\nTest2'
    assert check['color'] == 'red'
    assert result == """<h2>My LaTeX</h2><p>[ltx=2+2, color=red]</p><p>[latex] 2+2 [/latex]</p><p>[latex]<br />Test1<br />Test2<br />[/latex]</p><p>[dummy]</p>"""
Example #11
0
def test_infinite_loop():
    text = """
CONTENT=[html]
Todoist is now moved to the new data center.

<p>
We have also added some improvements, some of these are:
</p>

<ul>
    <li>Faster hardware, should be able to handle much more users</li>
    <li>Support for <b>q: free text search</b></li>
    <li>Support for back and forward browser buttons</li>

    <li>Improved and upgraded the libraries behind Todoist</li>
</ul>

<p>
If you spot any bugs with the move, please report them on <a href="http://getsatisfaction.com/todoist" target="_blank">http://getsatisfaction.com/todoist</a>
</p>
[/html]

[escape]
Todoist is now moved to the new data center.

<p>
We have also added some improvements, some of these are:
</p>

<ul>
    <li>Faster hardware, should be able to handle much more users</li>
    <li>Support for <b>q: free text search</b></li>
    <li>Support for back and forward browser buttons</li>

    <li>Improved and upgraded the libraries behind Todoist</li>
</ul>

<p>
If you spot any bugs with the move, please report them on <a href="http://getsatisfaction.com/todoist" target="_blank">http://getsatisfaction.com/todoist</a>
</p>
[/html]
"""
    parser = AmiFormat()
    assert parser.htmlFormat(text) != None
Example #12
0
def test_plugins_combined():
    def file_handler(args):
        print args
        return False, None

    def image_handler(args):
        print args
        return False, None

    parser = AmiFormat()
    parser.registerSLPlugin('file', file_handler)
    parser.registerSLPlugin('image', image_handler)

    text = """
[image=Test, show_as=[file=Hellow]]
"""
    parser.htmlFormat(text)
Example #13
0
def test_header_plugin():
    def handler(args):
        return True, ''

    parser = AmiFormat()
    parser.registerMLPlugin('header_data', handler)
    text = """
h2. Test juhu.
[header_data]
<style>
  .feats {
    line-height: 13px;
  }
</style>
[/header_data]

[dummy]

Dette er en test.
Yes sir!
"""
    result = removeWS(parser.htmlFormat(text))
    print result
    assert result == '<h2>Test juhu.</h2><p>[dummy]</p><p>Dette er en test.<br />Yes sir!</p>'
Example #14
0
def test_http_link_bug():
    parser = AmiFormat()
    text = 'This is a :D buu'
    r_text = removeWS(parser.htmlFormat(text))
    assert r_text == '<p>This is a :D buu</p>'
Example #15
0
def runFormat(text):
    parser = AmiFormat()
    r1 = parser.htmlFormat(text)
    r1 = removeWS(r1)
    return r1