""" cross compare creole unittest ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Compare all similarities between: * creole2html * html2creole Note: This only works fine if there is no problematic whitespace handling. In this case, we must test in test_creole2html.py or test_html2creole.py :copyleft: 2008-2011 by python-creole team, see AUTHORS for more details. :license: GNU GPL v3 or above, see LICENSE for more details. """ import unittest from creole.shared import example_macros from creole.shared.unknown_tags import use_html_macro from creole.tests.utils.base_unittest import BaseCreoleTest class CrossCompareCreoleTests(BaseCreoleTest): def test_typeface(self): self.cross_compare_creole( creole_string=r""" basics: **//bold italics//** //**bold italics**// //This is **also** good.// Creole 1.0 optional: This is ##monospace## text. This is ^^superscripted^^ text. This is ,,subscripted,, text. This is __underlined__ text. own additions: This is --small-- and this ~~strikeout~~ ;) """, html_string="""

basics:
bold italics
bold italics
This is also good.

Creole 1.0 optional:
This is monospace text.
This is superscripted text.
This is subscripted text.
This is underlined text.

own additions:
This is small and this strikeout ;)

""" ) def test_cross_lines_html2creole(self): """ bold/italics cross lines see: http://code.google.com/p/python-creole/issues/detail?id=13 TODO: The way back creole2html doesn't work, see below """ self.assert_html2creole(r""" Bold and italics should //be able// to **cross lines.** """, """

Bold and italics should be
able
to cross
lines.

""") def test_small(self): """ http://code.google.com/p/python-creole/issues/detail?id=12#c0 """ self.cross_compare_creole( creole_string=r""" no -- small no // italics no ** bold no ## monospace no ^^ superscripted no ,, subscripted no __ underline """, html_string="""

no -- small
no // italics
no ** bold
no ## monospace
no ^^ superscripted
no ,, subscripted
no __ underline

""", debug=False ) def test_link(self): self.cross_compare_creole( creole_string=r""" this is [[/a internal]] link. 1 [[internal links|link A]] test. """, html_string="""

this is /a internal link.
1 link A test.

""" ) def test_bolditalic_links(self): self.cross_compare_creole(r""" //[[a internal]]// **[[Shortcut2|a page2]]** //**[[Shortcut3|a page3]]**// """, """

a internal
a page2
a page3

""") def test_pre_contains_braces(self): """ braces, > and %lt in a pre area. """ self.cross_compare_creole( creole_string=r""" === Closing braces in nowiki: {{{ if (x != NULL) { for (i = 0; i < size; i++) { if (x[i] > 0) { x[i]--; }}} }}} """, html_string="""

Closing braces in nowiki:

                if (x != NULL) {
                  for (i = 0; i < size; i++) {
                    if (x[i] > 0) {
                      x[i]--;
                  }}}
                
""") def test_pre2(self): self.cross_compare_creole(r""" 111 {{{ //This// does **not** get [[formatted]] }}} 222 one {{{ foo bar }}} two """, """

111

            //This// does **not** get [[formatted]]
            

222

one

            foo

            bar
            

two

""") def test_pre(self): self.cross_compare_creole(r""" start {{{ * no list }}} end """, """

start

            * no list
            <html escaped>
            

end

""") def test_tt(self): self.cross_compare_creole(r""" this is ##**strong** Teletyper## ;) """, """

this is strong Teletyper ;)

""") def test_no_inline_headline(self): self.cross_compare_creole( creole_string=r""" = Headline === **not** //parsed// No == headline == or? """, html_string="""

Headline

**not** //parsed//

No == headline == or?

""" ) def test_horizontal_rule(self): self.cross_compare_creole(r""" one ---- two """, """

one


two

""") def test_bullet_list(self): self.cross_compare_creole(r""" * Item 1 ** Item 1.1 ** a **bold** Item 1.2 * Item 2 ** Item 2.1 *** [[a link Item 3.1]] *** Force\\linebreak 3.2 *** item 3.3 *** item 3.4 up to five levels * 1 ** 2 *** 3 **** 4 ***** 5 """, """

up to five levels

""") def test_number_list(self): self.cross_compare_creole(r""" # Item 1 ## Item 1.1 ## a **bold** Item 1.2 # Item 2 ## Item 2.1 ### [[a link Item 3.1]] ### Force\\linebreak 3.2 ### item 3.3 ### item 3.4 up to five levels # 1 ## 2 ### 3 #### 4 ##### 5 """, """
  1. Item 1
    1. Item 1.1
    2. a bold Item 1.2
  2. Item 2
    1. Item 2.1
      1. a link Item 3.1
      2. Force
        linebreak 3.2
      3. item 3.3
      4. item 3.4

up to five levels

  1. 1
    1. 2
      1. 3
        1. 4
          1. 5
""", # debug = True ) def test_big_table(self): self.cross_compare_creole(r""" A Table... |= Headline |= a other\\headline |= the **big end** | | a cell | a **big** cell | **//bold italics//** | | next\\line | No == headline == or? | | | link test: | a [[/url/|link]] in | a cell. | | | | empty cells | ...end """, """

A Table...

Headline a other
headline
the big end
a cell a big cell bold italics
next
line
No == headline == or?
link test: a link in a cell.
empty cells

...end

""", # debug = True ) def test_html_macro_unknown_nodes(self): """ use the <> macro to mask unknown tags. Note: All cross compare tests use html2creole.HTML_MACRO_UNKNOWN_NODES """ self.cross_compare_creole(""" 111 <><>foo<><> 222 333<><>foobar<><>444 555<><>666 """, """

111 foo 222
333foobar444

555666

""", # use macro in creole2html emitter: macros=example_macros, # escape unknown tags with <> in html2creole emitter: unknown_emit=use_html_macro, ) def test_entities(self): self.cross_compare_creole(""" less-than sign: < greater-than sign: > """, """

less-than sign: <
greater-than sign: >

""") # def test_macro_html1(self): # self.cross_compare_creole(r""" # <> # # <> # some code # <> # # a macro: # <> # <> # the sourcecode # <> # """, r""" #

[Error: Macro 'a_not_existing_macro' doesn't exist]

#
# unknown type #
some code
#
#

a macro:

#
# unknown type #
<<code>>
#            the sourcecode
#
# """) # def test_macro_pygments_code(self): # self.cross_compare_creole(r""" # a macro: # <> # /* Stylesheet */ # form * { # vertical-align:middle; # } # <> # the end # """, """ #

a macro:

#
# CSS
1
#            2
#            3
#            4
/* Stylesheet */
#            form * {
#              vertical-align:middle;
#            }
#            
#
#

the end

# """) if __name__ == '__main__': unittest.main()