- The parser needs to be passed “strip_cdata” so that read CDATA blocks are preserved.
- Code needs to be wrapped in an instance of the CDATA class
- A dirty hack to quote the encapsulated CDATA blocks in multi-line comments to accommodate older browsers:
html.replace('<![CDATA[', '/*<![CDATA[*/').replace(']]>', '/*]]>*/')
content = (content.replace('</script>"', '</scr" + "ipt>"') .replace("</script>'", "</scr' + 'ipt>'"))
Warning: This script is not suited to parse any JS & CSS. It does though work for my task.
The source can be found here: http://github.com/cburgmer/deniz/blob/master/embed_media.pyThe next step will be to include images as base64 urls.