Mercurial > genshi > genshi-test
diff genshi/output.py @ 347:c0a4114786cc experimental-inline
cspeedups branch: Merged [423:426/trunk].
author | cmlenz |
---|---|
date | Fri, 10 Nov 2006 17:38:50 +0000 |
parents | 6e6950ac0e56 |
children | 49aa525b8f83 |
line wrap: on
line diff
--- a/genshi/output.py +++ b/genshi/output.py @@ -98,7 +98,7 @@ ns_attrib.append((QName('xmlns'), namespace)) buf = ['<', tagname] - for attr, value in attrib + ns_attrib: + for attr, value in attrib + tuple(ns_attrib): attrname = attr.localname if attr.namespace: prefix = ns_mapping.get(attr.namespace) @@ -183,7 +183,10 @@ _BOOLEAN_ATTRS = frozenset(['selected', 'checked', 'compact', 'declare', 'defer', 'disabled', 'ismap', 'multiple', 'nohref', 'noresize', 'noshade', 'nowrap']) - _PRESERVE_SPACE = frozenset([QName('pre'), QName('textarea')]) + _PRESERVE_SPACE = frozenset([ + QName('pre'), QName('http://www.w3.org/1999/xhtml}pre'), + QName('textarea'), QName('http://www.w3.org/1999/xhtml}textarea') + ]) def __call__(self, stream): namespace = self.NAMESPACE @@ -213,7 +216,7 @@ ns_attrib.append((QName('xmlns'), tagns)) buf = ['<', tagname] - for attr, value in attrib + ns_attrib: + for attr, value in chain(attrib, ns_attrib): attrname = attr.localname if attr.namespace: prefix = ns_mapping.get(attr.namespace) @@ -461,8 +464,8 @@ @param noescape: a set or sequence of tag names for which text content should not be escaped - Both the `preserve` and `noescape` sets are expected to refer to - elements that cannot contain further child elements. + The `noescape` set is expected to refer to elements that cannot contain + further child elements (such as <style> or <script> in HTML documents). """ if preserve is None: preserve = [] @@ -476,7 +479,7 @@ collapse_lines=re.compile('\n{2,}').sub): mjoin = Markup('').join preserve_elems = self.preserve - preserve = False + preserve = 0 noescape_elems = self.noescape noescape = False @@ -500,15 +503,17 @@ yield TEXT, Markup(text), pos if kind is START: - tag, attrib = data - if not preserve and (tag in preserve_elems or - attrib.get(space) == 'preserve'): - preserve = True + tag, attrs = data + if preserve or (tag in preserve_elems or + attrs.get(space) == 'preserve'): + preserve += 1 if not noescape and tag in noescape_elems: noescape = True elif kind is END: - preserve = noescape = False + noescape = False + if preserve: + preserve -= 1 elif kind is START_CDATA: noescape = True