Show
Ignore:
Timestamp:
09/12/08 15:05:57 (18 months ago)
Author:
JensDiemer
Message:

* creole markup:

  • better list output
  • code cleanup
  • more tests
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pylucid_project/tests/markup_creole.py

    r1763 r1764  
    99    django template syntax. 
    1010 
     11    Some Links 
     12    ~~~~~~~~~~ 
     13    http://code.google.com/p/creoleparser/source/browse/trunk/creoleparser/tests.py 
     14    http://hg.moinmo.in/moin/1.7/file/tip/MoinMoin/parser/ 
     15    http://sheep.art.pl/devel/creole/file/tip 
     16    http://djikiki.googlecode.com/svn/trunk/djikiki/creole/ 
     17 
     18    Differences to Creole 1.0 
     19    ~~~~~~~~~~~~~~~~~~~~~~~~~ 
     20     * italics -> <i> and not <em> 
     21 
    1122    Last commit info: 
    1223    ~~~~~~~~~~~~~~~~~ 
     
    4758        #print ">>>%r<<<" % out_string 
    4859        return out_string 
    49      
     60 
    5061    def _processCreole(self, source_string, should_string): 
    5162        """ 
     
    5667        out_string = self._parse(source) 
    5768        return out_string, should 
    58      
     69 
    5970    def assertCreole(self, source_string, should_string): 
    6071        """ 
     
    6778        out_string = out_string.rstrip("\n") 
    6879        self.assertEqual(out_string, should) 
    69          
     80 
    7081    #-------------------------------------------------------------------------- 
    71      
     82 
    7283    def test_creole_basic1(self): 
    7384        out_string = self._parse("a text line.") 
    74         self.assertEqual(out_string, "<p>a text line. </p>\n\n") 
    75          
     85        self.assertEqual(out_string, "<p>a text line.</p>\n\n") 
     86 
    7687    def test_creole_basic2(self): 
    7788        self.assertCreole(r""" 
     
    7990        """, """ 
    8091            <p>Force<br /> 
    81             linebreak </p> 
    82         """) 
    83          
     92            linebreak</p> 
     93        """) 
     94 
    8495    def test_creole_basic3(self): 
    8596        self.assertCreole(r""" 
     
    8798            or **//both//** or //**both**// 
    8899        """, """ 
    89             <p>Basics: <b>bold</b> or <i>italic</i> <br /> 
    90             or <b><i>both</i></b> or <i><b>both</b></i> </p> 
    91         """) 
    92          
     100            <p>Basics: <b>bold</b> or <i>italic</i><br /> 
     101            or <b><i>both</i></b> or <i><b>both</b></i></p> 
     102        """) 
     103 
    93104    def test_creole_basic4(self): 
    94105        self.assertCreole(r""" 
     
    97108            A [[internal links|different]] link name. 
    98109        """, """ 
    99             <p>Here is <a href="a internal">a internal</a> link. <br /> 
    100             This is <a href="http://domain.tld">external links</a>. <br /> 
    101             A <a href="internal links">different</a> link name. </p> 
    102         """) 
    103          
     110            <p>Here is <a href="a internal">a internal</a> link.<br /> 
     111            This is <a href="http://domain.tld">external links</a>.<br /> 
     112            A <a href="internal links">different</a> link name.</p> 
     113        """) 
     114 
    104115    def test_django1(self): 
    105116        """ 
    106117        Test if django template tags are not changed by Creole. 
    107118        The Creole image tag use "{{" and "}}", too. 
     119        We test also the passthrough for all django template blocktags 
    108120        """ 
    109121        self.assertCreole(r""" 
    110122            The current page name: >{{ PAGE.name }}< great? 
    111123            A {% lucidTag page_update_list count=10 %} PyLucid plugin 
    112              
     124 
     125            {% sourcecode py %} 
     126            import sys 
     127 
     128            sys.stdout("Hello World!") 
     129            {% endsourcecode %} 
     130 
    113131            A [[www.domain.tld|link]]. 
    114132            a {{/image.jpg|My Image}} image 
    115              
     133 
    116134            no image: {{ foo|bar }}! 
    117135            picture [[www.domain.tld | {{ foo.JPG | Foo }} ]] as a link 
    118136        """, """ 
    119             <p>The current page name: &gt;{{ PAGE.name }}&lt; great? <br /> 
    120             A {% lucidTag page_update_list count=10 %} PyLucid plugin </p> 
    121              
    122             <p>A <a href="www.domain.tld">link</a>. <br /> 
    123             a <img src="/image.jpg" alt="My Image"> image </p> 
    124              
    125             <p>no image: {{ foo|bar }}! <br /> 
    126             picture <a href="www.domain.tld"><img src="foo.JPG" alt="Foo"></a> as a link </p> 
    127         """) 
    128          
     137            <p>The current page name: &gt;{{ PAGE.name }}&lt; great?<br /> 
     138            A {% lucidTag page_update_list count=10 %} PyLucid plugin</p> 
     139 
     140            {% sourcecode py %} 
     141            import sys 
     142 
     143            sys.stdout("Hello World!") 
     144            {% endsourcecode %} 
     145 
     146            <p>A <a href="www.domain.tld">link</a>.<br /> 
     147            a <img src="/image.jpg" alt="My Image"> image</p> 
     148 
     149            <p>no image: {{ foo|bar }}!<br /> 
     150            picture <a href="www.domain.tld"><img src="foo.JPG" alt="Foo"></a> as a link</p> 
     151        """) 
     152 
    129153    def test_nowiki1(self): 
    130         """ 
    131         Test preformatted text 
    132         """ 
    133154        self.assertCreole(r""" 
    134155            {{{ 
     
    140161            </pre> 
    141162        """) 
    142          
     163 
    143164    def test_nowiki2(self): 
    144         """ 
    145         Test preformatted text 
    146         """ 
    147165        self.assertCreole(r""" 
    148166            111 
    149167            222 
    150              
     168 
    151169            {{{ 
    152170            333 
    153171            }}} 
    154              
     172 
    155173            444 
    156174        """, """ 
    157             <p>111 <br /> 
    158             222 </p> 
    159              
     175            <p>111<br /> 
     176            222</p> 
     177 
    160178            <pre> 
    161179            333 
    162180            </pre> 
    163             <p>444 </p> 
    164         """) 
    165      
    166     def test_preformatted(self): 
    167         """ 
    168         Test preformatted text 
    169         """ 
    170         self.assertCreole(r""" 
    171             This should be also interpreded as preformated: 
    172              
    173             {% sourcecode py %} 
    174             import sys 
    175              
    176             sys.stdout("Hello World!") 
    177             {% endsourcecode %} 
    178              
    179             END 
    180         """, """ 
    181             <p>This should be also interpreded as preformated: </p> 
    182              
    183             {% sourcecode py %} 
    184             import sys 
    185              
    186             sys.stdout("Hello World!") 
    187             {% endsourcecode %} 
    188              
    189             <p>END </p> 
    190         """) 
     181            <p>444</p> 
     182        """) 
     183 
     184    def test_bold_italics(self): 
     185        self.assertCreole(r""" 
     186            **//bold italics//** 
     187            //**bold italics**// 
     188            //This is **also** good.// 
     189        """, """ 
     190            <p><b><i>bold italics</i></b><br /> 
     191            <i><b>bold italics</b></i><br /> 
     192            <i>This is <b>also</b> good.</i></p> 
     193        """) 
     194 
     195    def test_cross_paragraphs(self): 
     196        self.assertCreole(""" 
     197            Bold and italics should //be 
     198            able// to cross lines. 
     199 
     200            But, should //not be... 
     201 
     202            ...able// to cross paragraphs. 
     203        """, """ 
     204            <p>Bold and italics should <i>be<br /> 
     205            able</i> to cross lines.</p> 
     206 
     207            <p>But, should <i>not be...</i></p> 
     208 
     209            <p>...able<i> to cross paragraphs.</i></p> 
     210        """) 
     211 
     212    def test_headlines(self): 
     213        self.assertCreole(""" 
     214            = Level 1 (largest) = 
     215            == Level 2 == 
     216            === Level 3 === 
     217            ==== Level 4 ==== 
     218            ===== Level 5 ===== 
     219            ====== Level 6 ====== 
     220            === Also level 3 
     221            === Also level 3 = 
     222            === Also level 3 == 
     223            === **not** //parsed// === 
     224            No == headline == or? 
     225        """, """ 
     226            <h1>Level 1 (largest)</h1> 
     227            <h2>Level 2</h2> 
     228            <h3>Level 3</h3> 
     229            <h4>Level 4</h4> 
     230            <h5>Level 5</h5> 
     231            <h6>Level 6</h6> 
     232            <h3>Also level 3</h3> 
     233            <h3>Also level 3</h3> 
     234            <h3>Also level 3</h3> 
     235            <h3>**not** //parsed//</h3> 
     236            <p>No == headline == or?</p> 
     237        """) 
     238 
     239    def test_bullet_list(self): 
     240        self.assertCreole(""" 
     241            * Item 1 
     242            ** Item 1.1 
     243            ** Item 1.2 
     244            * Item 2 
     245            ** Item 2.1 
     246            *** Item 3.1 
     247            *** Item 3.2 
     248        """, """ 
     249            <ul> 
     250            <li>Item 1 
     251              <ul> 
     252              <li>Item 1.1 
     253              </li> 
     254              <li>Item 1.2 
     255              </li> 
     256              </ul> 
     257            </li> 
     258            <li>Item 2 
     259              <ul> 
     260              <li>Item 2.1 
     261                <ul> 
     262                <li>Item 3.1 
     263                </li> 
     264                <li>Item 3.2 
     265                </li> 
     266                </ul> 
     267              </li> 
     268              </ul> 
     269            </li> 
     270            </ul> 
     271        """) 
     272 
     273    def test_number_list(self): 
     274        self.assertCreole(""" 
     275            # Item 1 
     276            ## Item 1.1 
     277            # Item 2 
     278        """, """ 
     279            <ol> 
     280            <li>Item 1 
     281              <ol> 
     282              <li>Item 1.1 
     283              </li> 
     284              </ol> 
     285            </li> 
     286            <li>Item 2 
     287            </li> 
     288            </ol> 
     289        """) 
     290 
     291    def test_horizontal_rule(self): 
     292        self.assertCreole(""" 
     293            one 
     294            ---- 
     295            two 
     296        """, """ 
     297            <p>one</p> 
     298            <hr /> 
     299            <p>two</p> 
     300        """) 
     301 
    191302 
    192303