comparison MoinMoin/formatter/text_html.py @ 529:20f8bda12a7b

fix table *bgcolor trouble, cleanup style synth, fix html_gedit api imported from: moin--main--1.5--patch-533
author Thomas Waldmann <tw@waldmann-edv.de>
date Fri, 07 Apr 2006 19:23:56 +0000
parents 66c0297e3fd0
children d827734692ac
comparison
equal deleted inserted replaced
528:92faed4fbd76 529:20f8bda12a7b
1238 """ 1238 """
1239 if not attrs: 1239 if not attrs:
1240 return {} 1240 return {}
1241 1241
1242 result = {} 1242 result = {}
1243 s = "" # we collect synthesized style in s 1243 s = [] # we collect synthesized style in s
1244 for key, val in attrs.items(): 1244 for key, val in attrs.items():
1245 # Ignore keys that don't start with prefix 1245 # Ignore keys that don't start with prefix
1246 if prefix and key[:len(prefix)] != prefix: 1246 if prefix and key[:len(prefix)] != prefix:
1247 continue 1247 continue
1248 key = key[len(prefix):] 1248 key = key[len(prefix):]
1249 val = val.strip('"') 1249 val = val.strip('"')
1250 # remove invalid attrs from dict and synthesize style 1250 # remove invalid attrs from dict and synthesize style
1251 if key == 'width': 1251 if key == 'width':
1252 s += "width: %s;" % val 1252 s.append("width: %s" % val)
1253 elif key == 'height': 1253 elif key == 'height':
1254 s += "height: %s;" % val 1254 s.append("height: %s" % val)
1255 elif key == 'bgcolor': 1255 elif key == 'bgcolor':
1256 s += "background-color: %s;" % val 1256 s.append("background-color: %s" % val)
1257 elif key == 'align': 1257 elif key == 'align':
1258 s += "text-align: %s;" % val 1258 s.append("text-align: %s" % val)
1259 elif key == 'valign': 1259 elif key == 'valign':
1260 s += "vertical-align: %s;" % val 1260 s.append("vertical-align: %s" % val)
1261 # Ignore unknown keys 1261 # Ignore unknown keys
1262 if key not in self._allowed_table_attrs[prefix]: 1262 if key not in self._allowed_table_attrs[prefix]:
1263 continue 1263 continue
1264 result[key] = val 1264 result[key] = val
1265 if s: 1265 st = result.get('style', '').split(';')
1266 if result.has_key('style'): 1266 st = '; '.join(st + s)
1267 result['style'] += s 1267 st = st.strip(';')
1268 else: 1268 st = st.strip()
1269 result['style'] = s 1269 if not st:
1270 #self.request.log("_checkTableAttr returns %r" % result) 1270 try:
1271 del result['style'] # avoid empty style attr
1272 except:
1273 pass
1274 else:
1275 result['style'] = st
1276 self.request.log("_checkTableAttr returns %r" % result)
1271 return result 1277 return result
1272 1278
1273 1279
1274 def table(self, on, attrs=None, **kw): 1280 def table(self, on, attrs=None, **kw):
1275 """ Create table 1281 """ Create table