Exemplo n.º 1
0
 def _textToXhtml(self, xhtmlString):
     if not xhtmlutil.hasXhtmlMarkup(xhtmlString):
         self._addMessage(ZXhtmlValidationMessage.INFO, -1, -1, u"Converting plain text to xhtml markup.")  #$NON-NLS-1$
         # convert plain text to xhtml
         transformer = ZTextToXhtmlTransformer()
         xhtmlString = transformer.transform(xhtmlString)
     return xhtmlString
Exemplo n.º 2
0
    def _prepareForLoading(self, xhtmlString):
        u"""Prepares the raw xhtml string for loading into zDom."""  #$NON-NLS-1$
        xhtmlString = xhtmlString.lstrip()
        if xhtmlString.startswith(u"<!DOCTYPE"):  #$NON-NLS-1$
            xhtmlString = xhtmlString[xhtmlString.find(u">") +
                                      1:]  #$NON-NLS-1$

        xhtmlString = xhtmlString.replace(u'&nbsp;',
                                          u' ')  #$NON-NLS-1$ #$NON-NLS-2$
        (bOk,
         xhtmlString) = self._cleanupMsOffice(xhtmlString)  #@UnusedVariable

        # if the string content does not have a <body/> then convert to xhtml and wrap it
        # with <html><body/></html>
        if not xhtmlutil.hasBody(xhtmlString):
            if not xhtmlutil.hasXhtmlMarkup(xhtmlString):
                self.messages.append(
                    u"Converting plain text to xhtml markup.")  #$NON-NLS-1$
                # convert plain text to xhtml
                transformer = ZTextToXhtmlTransformer()
                xhtmlString = transformer.transform(xhtmlString)
            xhtmlString = xhtmlutil.wrapHtmlBody(xhtmlString)
            self.messages.append(
                u"Adding <html><body></body></html> wrapper.")  #$NON-NLS-1$
        return xhtmlString
Exemplo n.º 3
0
 def _textToXhtml(self, xhtmlString):
     if not xhtmlutil.hasXhtmlMarkup(xhtmlString):
         self._addMessage(
             ZXhtmlValidationMessage.INFO, -1, -1,
             u"Converting plain text to xhtml markup.")  #$NON-NLS-1$
         # convert plain text to xhtml
         transformer = ZTextToXhtmlTransformer()
         xhtmlString = transformer.transform(xhtmlString)
     return xhtmlString
Exemplo n.º 4
0
    def _prepareForLoading(self, xhtmlString):
        u"""Prepares the raw xhtml string for loading into zDom."""  #$NON-NLS-1$
        xhtmlString = xhtmlString.lstrip()
        if xhtmlString.startswith(u"<!DOCTYPE"): #$NON-NLS-1$
            xhtmlString = xhtmlString[xhtmlString.find(u">") + 1:] #$NON-NLS-1$

        xhtmlString = xhtmlString.replace(u'&nbsp;', u' ') #$NON-NLS-1$ #$NON-NLS-2$
        (bOk, xhtmlString) = self._cleanupMsOffice(xhtmlString) #@UnusedVariable

        # if the string content does not have a <body/> then convert to xhtml and wrap it
        # with <html><body/></html>
        if not xhtmlutil.hasBody(xhtmlString):
            if not xhtmlutil.hasXhtmlMarkup(xhtmlString):
                self.messages.append(u"Converting plain text to xhtml markup.")  #$NON-NLS-1$
                # convert plain text to xhtml
                transformer = ZTextToXhtmlTransformer()
                xhtmlString = transformer.transform(xhtmlString)
            xhtmlString = xhtmlutil.wrapHtmlBody(xhtmlString)
            self.messages.append(u"Adding <html><body></body></html> wrapper.")  #$NON-NLS-1$
        return xhtmlString