work in progress: wiki:. sample implementation with reStructuredText format
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3061 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
40861ccff1
commit
6057cfa3a0
2 changed files with 17 additions and 3 deletions
|
@ -26,8 +26,12 @@ We format the content of the start page using the restructured text format.
|
|||
As we have not yet registered any formatting plugins rendering the page
|
||||
returns it content unchanged.
|
||||
|
||||
>>> tree = startPage.parse()
|
||||
|
||||
>>> print startPage.render()
|
||||
**Welcome to the Demo Wiki**
|
||||
<p><strong>Welcome to the Demo Wiki</strong></p>
|
||||
|
||||
**Welcome to the Demo Wiki**
|
||||
|
||||
|
||||
A Very Basic Wiki Format
|
||||
|
|
|
@ -22,6 +22,8 @@ A Wiki manager managing wikis and wiki-related objects, esp plugins.
|
|||
$Id$
|
||||
"""
|
||||
|
||||
from docutils.core import publish_doctree, publish_from_doctree
|
||||
from docutils.writers.html4css1 import HTMLTranslator, Writer
|
||||
from zope.interface import implements
|
||||
|
||||
from cybertools.wiki.interfaces import IWikiManager, IWiki, IWikiPage
|
||||
|
@ -74,7 +76,15 @@ class WikiPage(object):
|
|||
return self.write(self.parse())
|
||||
|
||||
def parse(self):
|
||||
return self.text
|
||||
return publish_doctree(self.text)
|
||||
|
||||
def write(self, tree):
|
||||
return tree
|
||||
writer = Writer()
|
||||
writer.translator_class = HTMLBodyTranslator
|
||||
return publish_from_doctree(tree, writer=writer)
|
||||
|
||||
|
||||
class HTMLBodyTranslator(HTMLTranslator):
|
||||
|
||||
def astext(self):
|
||||
return u''.join(self.body_pre_docinfo + self.docinfo + self.body)
|
||||
|
|
Loading…
Add table
Reference in a new issue