[gen] XhtmlCleaner now only keeps useful CSS attributes within XHTML style attributes.
This commit is contained in:
parent
9477865f44
commit
d16b03e0d6
4 changed files with 42 additions and 8 deletions
|
@ -217,7 +217,7 @@ class Renderer:
|
|||
'text': pe.NS_TEXT}))
|
||||
self.stylesParser = self.createPodParser('styles.xml', context,
|
||||
stylesInserts)
|
||||
# Stores the styles mapping
|
||||
# Store the styles mapping
|
||||
self.setStylesMapping(stylesMapping)
|
||||
|
||||
def createPodParser(self, odtFile, context, inserts):
|
||||
|
@ -398,6 +398,12 @@ class Renderer:
|
|||
and, on the other hand, ODT styles found into the template.'''
|
||||
try:
|
||||
stylesMapping = self.stylesManager.checkStylesMapping(stylesMapping)
|
||||
# The predefined styles below are currently ignored, because the
|
||||
# xhtml2odt parser does not take into account span tags.
|
||||
if 'span[font-weight=bold]' not in stylesMapping:
|
||||
stylesMapping['span[font-weight=bold]'] = 'podBold'
|
||||
if 'span[font-style=italic]' not in stylesMapping:
|
||||
stylesMapping['span[font-style=italic]'] = 'podItalic'
|
||||
self.stylesManager.stylesMapping = stylesMapping
|
||||
except PodError, po:
|
||||
self.contentParser.env.currentBuffer.content.close()
|
||||
|
|
|
@ -22,6 +22,7 @@ from UserDict import UserDict
|
|||
import appy.pod
|
||||
from appy.pod import *
|
||||
from appy.pod.odf_parser import OdfEnvironment, OdfParser
|
||||
from appy.shared.css import parseStyleAttribute
|
||||
|
||||
# Possible states for the parser
|
||||
READING = 0 # Default state
|
||||
|
@ -329,12 +330,7 @@ class StylesManager:
|
|||
else: return
|
||||
# If I am here, I have style info. Check if it corresponds to some style
|
||||
# in p_styles.
|
||||
infos = attrs['style'].split(';')
|
||||
styleInfo = {}
|
||||
for info in infos:
|
||||
if not info.strip(): continue
|
||||
name, value = info.split(':')
|
||||
styleInfo[name.strip()] = value.strip()
|
||||
styleInfo = parseStyleAttribute(attrs['style'], asDict=True)
|
||||
for matchingAttrs, style in styles:
|
||||
if self.styleMatch(styleInfo, matchingAttrs):
|
||||
return style
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue