コード例 #1
0
ファイル: blogpublisher.py プロジェクト: Tidosho/zoundryraven
 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())
     removeNewLines = zblog.getPreferences().getUserPreferenceBool(IZBlogAppUserPrefsKeys.SP_REMOVE_NEWLINES, False)
     if removeNewLines:
         transformer = ZXhtmlRemoveNewLinesTransformer()
         content = transformer.transform(content)
     return content
コード例 #2
0
 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())
     removeNewLines = zblog.getPreferences().getUserPreferenceBool(
         IZBlogAppUserPrefsKeys.SP_REMOVE_NEWLINES, False)
     if removeNewLines:
         transformer = ZXhtmlRemoveNewLinesTransformer()
         content = transformer.transform(content)
     return content
コード例 #3
0
    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