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

* udpate creole markup

  • better html code style
  • add some bugfixes
  • pass-throug html code lines
  • add more tests
  • update creole help page
Files:
1 modified

Legend:

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

    r1764 r1766  
    1212    ~~~~~~~~~~ 
    1313    http://code.google.com/p/creoleparser/source/browse/trunk/creoleparser/tests.py 
    14     http://hg.moinmo.in/moin/1.7/file/tip/MoinMoin/parser/ 
     14    http://hg.moinmo.in/moin/1.8/file/tip/MoinMoin/parser/ 
    1515    http://sheep.art.pl/devel/creole/file/tip 
    16     http://djikiki.googlecode.com/svn/trunk/djikiki/creole/ 
     16    http://code.google.com/p/djikiki/source/browse/#svn/trunk/djikiki/creole 
     17    http://creoleparser.googlepages.com/cheatsheetplus.html 
     18    http://www.wikicreole.org/creole-sandbox/EditX.jsp?page=Home 
     19    http://www.wikicreole.org/wiki/Sandbox 
    1720 
    1821    Differences to Creole 1.0 
     
    8386    def test_creole_basic1(self): 
    8487        out_string = self._parse("a text line.") 
    85         self.assertEqual(out_string, "<p>a text line.</p>\n\n") 
     88        self.assertEqual(out_string, "<p>a text line.</p>\n") 
    8689 
    8790    def test_creole_basic2(self): 
     
    9497 
    9598    def test_creole_basic3(self): 
    96         self.assertCreole(r""" 
    97             Basics: **bold** or //italic// 
    98             or **//both//** or //**both**// 
    99         """, """ 
    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  
    104     def test_creole_basic4(self): 
    10599        self.assertCreole(r""" 
    106100            Here is [[a internal]] link. 
     
    122116            The current page name: >{{ PAGE.name }}< great? 
    123117            A {% lucidTag page_update_list count=10 %} PyLucid plugin 
    124  
    125118            {% sourcecode py %} 
    126119            import sys 
     
    128121            sys.stdout("Hello World!") 
    129122            {% endsourcecode %} 
    130  
    131123            A [[www.domain.tld|link]]. 
    132124            a {{/image.jpg|My Image}} image 
     
    137129            <p>The current page name: &gt;{{ PAGE.name }}&lt; great?<br /> 
    138130            A {% lucidTag page_update_list count=10 %} PyLucid plugin</p> 
    139  
    140131            {% sourcecode py %} 
    141132            import sys 
     
    143134            sys.stdout("Hello World!") 
    144135            {% endsourcecode %} 
    145  
    146136            <p>A <a href="www.domain.tld">link</a>.<br /> 
    147137            a <img src="/image.jpg" alt="My Image"> image</p> 
    148  
     138             
    149139            <p>no image: {{ foo|bar }}!<br /> 
    150140            picture <a href="www.domain.tld"><img src="foo.JPG" alt="Foo"></a> as a link</p> 
     
    153143    def test_nowiki1(self): 
    154144        self.assertCreole(r""" 
     145            this: 
    155146            {{{ 
    156147            //This// does **not** get [[formatted]] 
    157148            }}} 
    158         """, """ 
     149            and this: {{{** <i>this</i> ** }}} 
     150             
     151            === Closing braces in nowiki: 
     152            {{{ 
     153            if (x != NULL) { 
     154              for (i = 0; i < size; i++) { 
     155                if (x[i] > 0) { 
     156                  x[i]--; 
     157              }}} 
     158            }}} 
     159        """, """ 
     160            <p>this:</p> 
    159161            <pre> 
    160162            //This// does **not** get [[formatted]] 
    161163            </pre> 
     164            <p>and this: <tt>** &lt;i&gt;this&lt;/i&gt; **</tt></p> 
     165             
     166            <h3>Closing braces in nowiki:</h3> 
     167            <pre> 
     168            if (x != NULL) { 
     169              for (i = 0; i &lt; size; i++) { 
     170                if (x[i] &gt; 0) { 
     171                  x[i]--; 
     172              }}} 
     173            </pre> 
    162174        """) 
    163175 
     
    166178            111 
    167179            222 
    168  
    169180            {{{ 
    170181            333 
    171182            }}} 
    172  
    173183            444 
     184             
     185            one 
     186            {{{ 
     187            foobar 
     188            }}} 
     189             
     190            two 
    174191        """, """ 
    175192            <p>111<br /> 
    176193            222</p> 
    177  
    178194            <pre> 
    179195            333 
    180196            </pre> 
    181197            <p>444</p> 
     198             
     199            <p>one</p> 
     200            <pre> 
     201            foobar 
     202            </pre> 
     203            <p>two</p> 
     204        """) 
     205 
     206    def test_escape_char(self): 
     207        self.assertCreole(r""" 
     208            ~#1 
     209            http://domain.tld/~bar/ 
     210            ~http://domain.tld/ 
     211            [[Link]] 
     212            ~[[Link]] 
     213        """, """ 
     214            <p>#1<br /> 
     215            <a href="http://domain.tld/~bar/">http://domain.tld/~bar/</a><br /> 
     216            http://domain.tld/<br /> 
     217            <a href="Link">Link</a><br /> 
     218            [[Link]]</p> 
    182219        """) 
    183220 
     
    187224            //**bold italics**// 
    188225            //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> 
     226             
     227            //[[a page|this is italic]]// 
     228            **[[a page]]** 
     229            //**[[a page]]**// 
     230        """, """ 
     231            <p><strong><i>bold italics</i></strong><br /> 
     232            <i><strong>bold italics</strong></i><br /> 
     233            <i>This is <strong>also</strong> good.</i></p> 
     234             
     235            <p><i><a href="a page">this is italic</a></i><br /> 
     236            <strong><a href="a page">a page</a></strong><br /> 
     237            <i><strong><a href="a page">a page</a></strong></i></p> 
    193238        """) 
    194239 
    195240    def test_cross_paragraphs(self): 
    196         self.assertCreole(""" 
     241        self.assertCreole(r""" 
    197242            Bold and italics should //be 
    198243            able// to cross lines. 
     
    204249            <p>Bold and italics should <i>be<br /> 
    205250            able</i> to cross lines.</p> 
    206  
     251             
    207252            <p>But, should <i>not be...</i></p> 
    208  
     253             
    209254            <p>...able<i> to cross paragraphs.</i></p> 
    210255        """) 
    211256 
    212257    def test_headlines(self): 
    213         self.assertCreole(""" 
     258        self.assertCreole(r""" 
    214259            = Level 1 (largest) = 
    215260            == Level 2 == 
     
    221266            === Also level 3 = 
    222267            === Also level 3 == 
    223             === **not** //parsed// === 
     268            === **not** \\ //parsed// === 
    224269            No == headline == or? 
    225         """, """ 
     270        """, r""" 
    226271            <h1>Level 1 (largest)</h1> 
    227272            <h2>Level 2</h2> 
     
    233278            <h3>Also level 3</h3> 
    234279            <h3>Also level 3</h3> 
    235             <h3>**not** //parsed//</h3> 
     280            <h3>**not** \\ //parsed//</h3> 
    236281            <p>No == headline == or?</p> 
    237282        """) 
    238283 
    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  
    291284    def test_horizontal_rule(self): 
    292         self.assertCreole(""" 
     285        self.assertCreole(r""" 
    293286            one 
    294287            ---- 
     
    298291            <hr /> 
    299292            <p>two</p> 
     293        """) 
     294 
     295    def test_bullet_list(self): 
     296        self.assertCreole(r""" 
     297            * Item 1 
     298            ** Item 1.1 
     299            ** a **bold** Item 1.2 
     300            * Item 2 
     301            ** Item 2.1 
     302            *** [[a link Item 3.1]] 
     303            *** Force\\linebreak 3.2 
     304                *** item 3.3 
     305              *** item 3.4 
     306               
     307            up to five levels 
     308            * 1 
     309            ** 2 
     310            *** 3 
     311            **** 4 
     312            ***** 5 
     313        """, """ 
     314            <ul> 
     315            \t<li>Item 1 
     316            \t<ul> 
     317            \t\t<li>Item 1.1</li> 
     318            \t\t<li>a <strong>bold</strong> Item 1.2</li> 
     319            \t</ul></li> 
     320            \t<li>Item 2 
     321            \t<ul> 
     322            \t\t<li>Item 2.1 
     323            \t\t<ul> 
     324            \t\t\t<li><a href="a link Item 3.1">a link Item 3.1</a></li> 
     325            \t\t\t<li>Force<br /> 
     326            \t\t\tlinebreak 3.2</li> 
     327            \t\t\t<li>item 3.3</li> 
     328            \t\t\t<li>item 3.4</li> 
     329            \t\t</ul></li> 
     330            \t</ul></li> 
     331            </ul> 
     332            <p>up to five levels</p> 
     333            <ul> 
     334            \t<li>1 
     335            \t<ul> 
     336            \t\t<li>2 
     337            \t\t<ul> 
     338            \t\t\t<li>3 
     339            \t\t\t<ul> 
     340            \t\t\t\t<li>4 
     341            \t\t\t\t<ul> 
     342            \t\t\t\t\t<li>5</li> 
     343            \t\t\t\t</ul></li> 
     344            \t\t\t</ul></li> 
     345            \t\t</ul></li> 
     346            \t</ul></li> 
     347            </ul> 
     348        """) 
     349 
     350    def test_number_list(self): 
     351        self.assertCreole(r""" 
     352            # Item 1 
     353            ## Item 1.1 
     354            ## a **bold** Item 1.2 
     355            # Item 2 
     356            ## Item 2.1 
     357            ### [[a link Item 3.1]] 
     358            ### Force\\linebreak 3.2 
     359                ### item 3.3 
     360              ### item 3.4 
     361             
     362            up to five levels 
     363            # 1 
     364            ## 2 
     365            ### 3 
     366            #### 4 
     367            ##### 5 
     368        """, """ 
     369            <ol> 
     370            \t<li>Item 1 
     371            \t<ol> 
     372            \t\t<li>Item 1.1</li> 
     373            \t\t<li>a <strong>bold</strong> Item 1.2</li> 
     374            \t</ol></li> 
     375            \t<li>Item 2 
     376            \t<ol> 
     377            \t\t<li>Item 2.1 
     378            \t\t<ol> 
     379            \t\t\t<li><a href="a link Item 3.1">a link Item 3.1</a></li> 
     380            \t\t\t<li>Force<br /> 
     381            \t\t\tlinebreak 3.2</li> 
     382            \t\t\t<li>item 3.3</li> 
     383            \t\t\t<li>item 3.4</li> 
     384            \t\t</ol></li> 
     385            \t</ol></li> 
     386            </ol> 
     387            <p>up to five levels</p> 
     388            <ol> 
     389            \t<li>1 
     390            \t<ol> 
     391            \t\t<li>2 
     392            \t\t<ol> 
     393            \t\t\t<li>3 
     394            \t\t\t<ol> 
     395            \t\t\t\t<li>4 
     396            \t\t\t\t<ol> 
     397            \t\t\t\t\t<li>5</li> 
     398            \t\t\t\t</ol></li> 
     399            \t\t\t</ol></li> 
     400            \t\t</ol></li> 
     401            \t</ol></li> 
     402            </ol> 
     403        """) 
     404         
     405    def test_list(self): 
     406        """ Bold, Italics, Links, Pre in Lists """ 
     407        self.assertCreole(r""" 
     408            * **bold** item 
     409            * //italic// item 
     410             
     411            # item about a [[certain_page]] 
     412            # {{{ //this// is **not** [[processed]] }}} 
     413        """, """ 
     414            <ul> 
     415            \t<li><strong>bold</strong> item</li> 
     416            \t<li><i>italic</i> item</li> 
     417            </ul> 
     418            <ol> 
     419            \t<li>item about a <a href="certain_page">certain_page</a></li> 
     420            \t<li><tt>//this// is **not** [[processed]]</tt></li> 
     421            </ol> 
     422        """) 
     423 
     424    def test_table(self): 
     425        self.assertCreole(r""" 
     426            A Table... 
     427            |= Headline  |= a other\\headline    |= the **big end        | 
     428            | a cell     | a **big** cell        |**//bold italics//**   | 
     429            | next\\line | No == headline == or? |                       | 
     430            |            |                       | open end 
     431            ...end 
     432        """, """ 
     433            <p>A Table...</p> 
     434            <table> 
     435            <tr> 
     436            \t<th>Headline</th> 
     437            \t<th>a other<br /> 
     438            \t\theadline</th> 
     439            \t<th>the <strong>big end</strong></th> 
     440            </tr> 
     441            <tr> 
     442            \t<td>a cell</td> 
     443            \t<td>a <strong>big</strong> cell</td> 
     444            \t<td><strong><i>bold italics</i></strong></td> 
     445            </tr> 
     446            <tr> 
     447            \t<td>next<br /> 
     448            \t\tline</td> 
     449            \t<td>No == headline == or?</td> 
     450            \t<td></td> 
     451            </tr> 
     452            <tr> 
     453            \t<td></td> 
     454            \t<td></td> 
     455            \t<td>open end</td> 
     456            </tr> 
     457            </table> 
     458            <p>...end</p> 
     459        """) 
     460 
     461    def test_html_lines(self): 
     462        self.assertCreole(r""" 
     463            This is a normal Text block witch would 
     464            escape html chars like < and > ;) 
     465            <p>this <strong class="my">html code</strong> line pass-through</p> 
     466            end 
     467        """, """ 
     468            <p>This is a normal Text block witch would<br /> 
     469            escape html chars like &lt; and &gt; ;)</p> 
     470            <p>this <strong class="my">html code</strong> line pass-through</p> 
     471            <p>end</p> 
    300472        """) 
    301473