Package creoleparser
[hide private]
[frames] | no frames]

Source Code for Package creoleparser

 1  # __init__.py 
 2  # 
 3  # Copyright (c) 2007 Stephen Day 
 4  # 
 5  # This module is part of Creoleparser and is released under 
 6  # the MIT License: http://www.opensource.org/licenses/mit-license.php 
 7  # 
 8  """ 
 9  This is a Python implementation of a parser for the Creole wiki markup language. 
10  The specification of that can be found at http://wikicreole.org/wiki/Creole1.0 
11   
12  Basic Usage 
13  =========== 
14  >>> from creoleparser import text2html 
15   
16  Simply call the text2html() function with one argument (the text to be parsed): 
17   
18  >>> print text2html("Some real **simple** mark-up"), 
19  <p>Some real <strong>simple</strong> mark-up</p> 
20   
21  To customize things a little, create your own dialect and parser: 
22   
23  >>> from creoleparser.dialects import Creole10 
24  >>> from creoleparser.core import Parser 
25   
26  >>> my_dialect=Creole10(wiki_links_base_url='http://www.mysite.net/', 
27  ... interwiki_links_base_urls=dict(wikicreole='http://wikicreole.org/wiki/')) 
28   
29  >>> my_parser = Parser(dialect=my_dialect) 
30   
31  >>> print my_parser("[[Home]] and [[wikicreole:Home]]"), 
32  <p><a href="http://www.mysite.net/Home">Home</a> and <a href="http://wikicreole.org/wiki/Home">wikicreole:Home</a></p> 
33   
34  If you want pure Creole 1.0 (i.e., no additions), use creole2html() instead of text2html(). 
35   
36  """ 
37   
38  from core import Parser 
39  from dialects import Creole10 
40   
41  __docformat__ = 'restructuredtext en' 
42   
43  creole2html = Parser(dialect=Creole10(wiki_links_base_url='http://www.wikicreole.org/wiki/', 
44                               interwiki_links_base_urls={'Ohana':'http://wikiohana.net/cgi-bin/wiki.pl/'}, 
45                           use_additions=False,no_wiki_monospace=True)) 
46  """This is a pure Creole 1.0 parser created for convenience""" 
47   
48  creole_to_xhtml = creole2html 
49  """Same as creole2html""" 
50   
51  text2html = Parser(dialect=Creole10(wiki_links_base_url='http://www.wikicreole.org/wiki/', 
52                               interwiki_links_base_urls={'Ohana':'http://wikiohana.net/cgi-bin/wiki.pl/'}, 
53                           use_additions=True,no_wiki_monospace=False)) 
54  """This is a Creole 1.0 parser (+ additions) created for convenience""" 
55   
56 -def _test():
57 import doctest 58 doctest.testmod()
59 60 if __name__ == "__main__": 61 _test() 62