def _transformContentForPublishing(self, zblog, zxhtmlDocument): #@UnusedVariable u"""_transformContentForPublishing(ZBlog, ZXhtmlDocument) -> string representation of content. Subclasses can override to convert the xhtml document to a string prior to publishing. """ #$NON-NLS-1$ # simply serialize the body content (but not including the body element). content = extractBody(zxhtmlDocument.getBody().serialize()) # ---- START ---- # # To avoid getting self-terminating "iframe" tags, we filter the body content through "tidyutil.py". # ChuahTC Date: 2013-Sept-3 # # print "DEBUG (blogpublisher:_transformContentForPublishing) BEFORE: ", content # DEBUG: ChuahTC 2013-Sep-3 # Set "output_xml=0" instead of 1 to fix the problem with (occasional) empty content after filtering through # "tidyutil.py" when "iframe" tags are present. # # ChuahTC Date: 2014-Mar-19 # # tidyOptions = dict(output_xml=1, show_body_only=1, quiet=1, char_encoding="utf8", \ # output_error=0, show_warnings=0, quote_nbsp=0, raw=1) tidyOptions = dict(output_xml=0, show_body_only=1, quiet=1, char_encoding="utf8", \ output_error=0, show_warnings=0, quote_nbsp=0, raw=1) content = tidyutil.tidyHtml(content, tidyOptions) # print "DEBUG (blogpublisher:_transformContentForPublishing) AFTER: ", content # DEBUG: ChuahTC 2013-Sep-3 # ---- END ----- removeNewLines = zblog.getPreferences().getUserPreferenceBool(IZBlogAppUserPrefsKeys.SP_REMOVE_NEWLINES, False) if removeNewLines: transformer = ZXhtmlRemoveNewLinesTransformer() content = transformer.transform(content) # ---- START ---- # print "DEBUG (blogpublisher:_transformContentForPublishing)NewLinesRemoved: ", content # DEBUG: ChuahTC 2013-Sep-3 # ---- END ----- return content
def setXhtmlDocument(self, xhtmlDoc): # Override base class to show 'pretty print' version of the xhtml document body content. body = xhtmlDoc.getBody() xhtmlString = body.serialize() xhtmlString = tidyutil.tidyHtml(xhtmlString, tidyutil.SOURCE_OPTIONS) self.setValue(xhtmlString)
def _tidyHtml(self, xhtmlString): xhtmlString = tidyutil.tidyHtml(xhtmlString, tidyutil.EDITING_OPTIONS) xhtmlString = xhtmlString.replace( u"""<?xml version="1.0" encoding="utf-8"?>""", u"") #$NON-NLS-1$ #$NON-NLS-2$ return xhtmlString.lstrip()
def _tidyHtml(self, xhtmlString): xhtmlString = tidyutil.tidyHtml(xhtmlString, tidyutil.EDITING_OPTIONS) xhtmlString = xhtmlString.replace(u"""<?xml version="1.0" encoding="utf-8"?>""", u"") #$NON-NLS-1$ #$NON-NLS-2$ return xhtmlString.lstrip()