Show
Ignore:
Timestamp:
09/11/08 11:38:30 (18 months ago)
Author:
JensDiemer
Message:

-patch the creole markup, so it don't clashes with django template tags.
-Add a unitest and merge some parts from the tinxTextile markup test.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/pylucid_project/PyLucid/system/markups/creole2html.py

    r1634 r1761  
    184184 
    185185if __name__=="__main__": 
    186     #~ import sys 
    187     #~ document = Parser(unicode(sys.stdin.read(), 'utf-8', 'ignore')).parse() 
    188     #~ sys.stdout.write(HtmlEmitter(document).emit().encode('utf-8', 'ignore')) 
    189  
    190186    """ 
    191187    http://code.google.com/p/creoleparser/source/browse/trunk/creoleparser/tests.py 
     
    194190    http://djikiki.googlecode.com/svn/trunk/djikiki/creole/ 
    195191    """ 
    196  
    197     test1 = u""" 
    198 == Textauszeichnung 
    199  
    200 Das ist **fett** und //kursiv//. 
    201 Und noch eine Zeile... 
    202  
    203 == Links 
    204  
    205 Ein [[Interner Link ]] und ein normaler Link: 
    206 [[http://domain.tld/page/| Link Text]] 
    207  
    208 ---- 
    209  
    210 Bilder mit {{Image.jpg|Ein Bild}} toll. 
    211  
    212 Eine Liste: 
    213  * eins 
    214  * zwei 
    215  ** drei 
    216  ### Nummer 1 
    217  ### Nummer 2 
    218  
    219 == Tabelle 
    220  
    221   |= Item|= Size|= Price | 
    222   | fish | **big**  |cheap   | 
    223   | crab | small|expesive| 
    224  
    225   |= Item|= Size|= Price 
    226   | fish | big  |//cheap// 
    227   | crab | small|**very\\expesive** 
    228  
    229 == preformatted 
    230  
    231 {{{ 
    232 == [[NoWiki]]: 
    233 //**don't** format// 
    234  
    235 Good work! 
    236 }}}""" 
    237  
    238  
    239     test2 = u"""= Top-level heading (1) 
    240 == This a test for creole 0.1 (2) 
    241 === This is a Subheading (3) 
    242 ==== Subsub (4) 
    243 ===== Subsubsub (5) 
    244  
    245 The ending equal signs should not be displayed: 
    246  
    247 = Top-level heading (1) = 
    248 == This a test for creole 0.1 (2) == 
    249 === This is a Subheading (3) === 
    250 ==== Subsub (4) ==== 
    251 ===== Subsubsub (5) ===== 
    252  
    253  
    254 You can make things **bold** or //italic// or **//both//** or //**both**//. 
    255  
    256 Character formatting extends across line breaks: **bold, 
    257 this is still bold. This line deliberately does not end in star-star. 
    258  
    259 Not bold. Character formatting does not cross paragraph boundaries. 
    260  
    261 You can use [[internal links]] or [[http://www.wikicreole.org|external links]], 
    262 give the link a [[internal links|different]] name. 
    263  
    264 Here's another sentence: This wisdom is taken from [[Ward Cunningham's]] 
    265 [[http://www.c2.com/doc/wikisym/WikiSym2006.pdf|Presentation at the Wikisym 06]]. 
    266  
    267 Here's a external link without a description: [[http://www.wikicreole.org]] 
    268  
    269 Be careful that italic links are rendered properly:  //[[http://my.book.example/|My Book Title]]//  
    270  
    271 Free links without braces should be rendered as well, like http://www.wikicreole.org/ and http://www.wikicreole.org/users/~example.  
    272  
    273 Creole1.0 specifies that http://bar and ftp://bar should not render italic, 
    274 something like foo://bar should render as italic. 
    275  
    276 You can use this to draw a line to separate the page: 
    277 ---- 
    278  
    279 You can use lists, start it at the first column for now, please... 
    280  
    281 unnumbered lists are like 
    282 * item a 
    283 * item b 
    284 * **bold item c** 
    285  
    286 blank space is also permitted before lists like: 
    287   *   item a 
    288  * item b 
    289 * item c 
    290  ** item c.a 
    291  
    292 or you can number them 
    293 # [[item 1]] 
    294 # item 2 
    295 # // italic item 3 // 
    296     ## item 3.1 
    297   ## item 3.2 
    298  
    299 up to five levels 
    300 * 1 
    301 ** 2 
    302 *** 3 
    303 **** 4 
    304 ***** 5 
    305  
    306 * You can have 
    307 multiline list items 
    308 * this is a second multiline 
    309 list item 
    310  
    311 You can use nowiki syntax if you would like do stuff like this: 
    312  
    313 {{{ 
    314 Guitar Chord C: 
    315  
    316 ||---|---|---| 
    317 ||-0-|---|---| 
    318 ||---|---|---| 
    319 ||---|-0-|---| 
    320 ||---|---|-0-| 
    321 ||---|---|---| 
    322 }}} 
    323  
    324 Note: if you look at the source code of the above, you see the escape char (tilde, ~ ) 
    325 being used to escape the closing triple curly braces. This is to do nowiki nesting in this 
    326 wiki which doesn't follow Creole 1.0 yet (closing triple curly braces should be indented 
    327 by one space). 
    328  
    329 You can also use it inline nowiki {{{ in a sentence }}} like this. 
    330  
    331 !!! Escapes  
    332 Normal Link: http://wikicreole.org/ - now same link, but escaped: ~http://wikicreole.org/  
    333  
    334 Normal asterisks: ~**not bold~** 
    335  
    336 a tilde alone: ~ 
    337  
    338 a tilde escapes itself: ~~xxx 
    339  
    340 !! Creole 0.2  
    341  
    342 This should be a flower with the ALT text "this is a flower" if your wiki supports ALT text on images: 
    343  
    344 [{ImagePro src='Red-Flower.jpg' caption='here is a red flower' }] 
    345  
    346 !! Creole 0.4  
    347  
    348 Tables are done like this: 
    349  
    350 ||header col1||header col2 
    351 |col1|col2 
    352 |you         |can          
    353 |also        |align\\ it.  
    354  
    355 You can format an address by simply forcing linebreaks: 
    356  
    357 My contact dates:\\ 
    358 Pone: xyz\\ 
    359 Fax: +45\\ 
    360 Mobile: abc 
    361  
    362 !! Creole 0.5  
    363  
    364 || Header title               || Another header title      
    365 | {{{ //not italic text// }}} | {{{ **not bold text** }}}  
    366 | ''italic text''             | __  bold text __           
    367  
    368 !! Creole 1.0  
    369  
    370 If interwiki links are setup in your wiki, this links to the WikiCreole page about Creole 1.0 test cases: [WikiCreole:Creole1.0TestCases]. 
     192     
     193    txt = """ 
     194== Headline 
     195 
     196This is **bold**... 
     197Wow... 
     198 
     199The current page name: >{{ PAGE.name }}< great? 
     200Some {% lucidTag page_update_list count=10 %} text. 
     201 
     202a [[www.google.de|Google]] link 
     203a ((/image.jpg|My Image)) image 
     204a {{/image.jpg|My Image}} image 
     205 
     206no image: {{ foo|bar }}! 
     207A picture [[http://google.com | {{ campfire.JPG | campfire.jpg }} ]] as a link. 
    371208 
    372209""" 
    373210 
    374     document = Parser(test2).parse() 
     211    document = Parser(txt).parse() 
    375212    print HtmlEmitter(document).emit() 
    376  
    377