Back to index

plone3  3.1.7
html_to_text.py
Go to the documentation of this file.
00001 from Products.PortalTransforms.libtransforms.retransform import retransform
00002 
00003 class html_to_text(retransform):
00004     inputs  = ('text/html',)
00005     output = 'text/plain'
00006 
00007 def register():
00008     # XXX convert entites with htmlentitydefs.name2codepoint ?
00009     return html_to_text("html_to_text",
00010                        ('<script [^>]>.*</script>(?im)', ' '),
00011                        ('<style [^>]>.*</style>(?im)', ' '),
00012                        ('<head [^>]>.*</head>(?im)', ' '),
00013                        ('(?im)</?(font|em|i|strong|b)(?=\W)[^>]*>', ''),
00014                        ('<[^>]*>(?i)(?m)', ' '),
00015                        )