Back to index

plone3  3.1.7
html_to_web_intelligent_plain_text.py
Go to the documentation of this file.
00001 from Products.PortalTransforms.interfaces import itransform
00002 from plone.intelligenttext.transforms import convertHtmlToWebIntelligentPlainText
00003 
00004 class HtmlToWebIntelligentPlainText:
00005     """Transform which replaces urls and email into hyperlinks"""
00006 
00007     __implements__ = itransform
00008 
00009     __name__ = "html_to_web_intelligent_plain_text"
00010     output = "text/x-web-intelligent"
00011 
00012     def __init__(self, name=None, inputs=('text/html',), tab_width = 4):
00013         self.config = { 'inputs' : inputs, 'tab_width' : 4}
00014         self.config_metadata = {
00015             'inputs' : ('list', 'Inputs', 'Input(s) MIME type. Change with care.'),
00016             'tab_width' : ('string', 'Tab width', 'Number of spaces for a tab in the input')
00017             }
00018         if name:
00019             self.__name__ = name
00020             
00021     def name(self):
00022         return self.__name__
00023 
00024     def __getattr__(self, attr):
00025         if attr in self.config:
00026             return self.config[attr]
00027         raise AttributeError(attr)
00028 
00029     def convert(self, orig, data, **kwargs):
00030         text = convertHtmlToWebIntelligentPlainText(orig)            
00031         data.setData(text)
00032         return data
00033 
00034 def register():
00035     return HtmlToWebIntelligentPlainText()