Mercurial > genshi > mirror
diff markup/input.py @ 143:3d4c214c979a trunk
CDATA sections in XML input now appear as CDATA sections in the output. This should address the problem with escaping the contents of `<style>` and `<script>` elements, which would only get interpreted correctly if the output was served as `application/xhtml+xml`. Closes #24.
author | cmlenz |
---|---|
date | Fri, 11 Aug 2006 14:08:13 +0000 |
parents | c1f4390d50f8 |
children | d1ce85a7f296 |
line wrap: on
line diff
--- a/markup/input.py +++ b/markup/input.py @@ -69,6 +69,8 @@ parser.StartDoctypeDeclHandler = self._handle_doctype parser.StartNamespaceDeclHandler = self._handle_start_ns parser.EndNamespaceDeclHandler = self._handle_end_ns + parser.StartCdataSectionHandler = self._handle_start_cdata + parser.EndCdataSectionHandler = self._handle_end_cdata parser.ProcessingInstructionHandler = self._handle_pi parser.CommentHandler = self._handle_comment parser.DefaultHandler = self._handle_other @@ -105,7 +107,7 @@ msg += ', in ' + self.filename raise ParseError(msg, self.filename, e.lineno, e.offset) - def _enqueue(self, kind, data, pos=None): + def _enqueue(self, kind, data=None, pos=None): if pos is None: pos = self._getpos() if kind is Stream.TEXT: @@ -149,6 +151,12 @@ def _handle_end_ns(self, prefix): self._enqueue(Stream.END_NS, prefix or '') + def _handle_start_cdata(self): + self._enqueue(Stream.START_CDATA) + + def _handle_end_cdata(self): + self._enqueue(Stream.END_CDATA) + def _handle_pi(self, target, data): self._enqueue(Stream.PI, (target, data))