Back to index

plone3  3.1.7
textile_to_html.py
Go to the documentation of this file.
00001 """
00002 Uses Roberto A. F. De Almeida's http://dealmeida.net/ module to do its handy work
00003 
00004 author: Tom Lazar <tom@tomster.org> at the archipelago sprint 2006
00005 
00006 """
00007 
00008 from Products.PortalTransforms.interfaces import itransform
00009 from Products.PortalTransforms.libtransforms.utils import bin_search, sansext
00010 from Products.PortalTransforms.libtransforms.commandtransform import commandtransform
00011 from Products.CMFDefault.utils import bodyfinder
00012 import os
00013 
00014 try:
00015     import textile as textile_transformer
00016 except ImportError:
00017     HAS_TEXTILE = False
00018 else:
00019     HAS_TEXTILE = True
00020     
00021 
00022 class textile:
00023     __implements__ = itransform
00024 
00025     __name__ = "textile_to_html"
00026     inputs  = ("text/x-web-textile",)
00027     output = "text/html"
00028 
00029     def name(self):
00030         return self.__name__
00031 
00032     def convert(self, orig, data, **kwargs):
00033         if HAS_TEXTILE:
00034             html = textile_transformer.textile(orig, encoding='utf-8', output='utf-8')
00035         else:
00036             html = orig
00037         data.setData(html)
00038         return data
00039 
00040 def register():
00041     return textile()