# HG changeset patch # User cmlenz # Date 1213005003 0 # Node ID f9544a7cc57a6611b10ac4bff26b443904101fe9 # Parent 1f3c561f740a3ad8f9d46bb251ef56a281d84fcb Preparing for [milestone:0.5] release. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,6 @@ Version 0.5 http://svn.edgewall.org/repos/genshi/tags/0.5.0/ -(?, from branches/stable/0.5.x) +(Jun 9 2008, from branches/stable/0.5.x) * Added #include directive for text templates (ticket #115). * Added new markup transformation filter contributed by Alec Thomas. This diff --git a/doc/streams.txt b/doc/streams.txt --- a/doc/streams.txt +++ b/doc/streams.txt @@ -8,7 +8,7 @@ .. contents:: Contents - :depth: 1 + :depth: 2 .. sectnum:: @@ -132,10 +132,11 @@ events, which you'll need when you want to transmit or store the results of generating or otherwise processing markup. -The ``Stream`` class provides two methods for serialization: ``serialize()`` and -``render()``. The former is a generator that yields chunks of ``Markup`` objects -(which are basically unicode strings that are considered safe for output on the -web). The latter returns a single string, by default UTF-8 encoded. +The ``Stream`` class provides two methods for serialization: ``serialize()`` +and ``render()``. The former is a generator that yields chunks of ``Markup`` +objects (which are basically unicode strings that are considered safe for +output on the web). The latter returns a single string, by default UTF-8 +encoded. Here's the output from ``serialize()``: @@ -161,8 +162,8 @@

Some text and a link.

Both methods can be passed a ``method`` parameter that determines how exactly -the events are serialzed to text. This parameter can be either “xml” (the -default), “xhtml”, “html”, “text”, or a custom serializer class: +the events are serialized to text. This parameter can be either a string or a +custom serializer class: .. code-block:: pycon @@ -170,7 +171,7 @@

Some text and a link.

Note how the `
` element isn't closed, which is the right thing to do for -HTML. +HTML. See `serialization methods`_ for more details. In addition, the ``render()`` method takes an ``encoding`` parameter, which defaults to “UTF-8”. If set to ``None``, the result will be a unicode string. @@ -193,6 +194,54 @@ Some text and a link. +.. _`serialization methods`: + +Serialization Methods +--------------------- + +Genshi supports the use of different serialization methods to use for creating +a text representation of a markup stream. + +``xml`` + The ``XMLSerializer`` is the default serialization method and results in + proper XML output including namespace support, the XML declaration, CDATA + sections, and so on. It is not generally not suitable for serving HTML or + XHTML web pages (unless you want to use true XHTML 1.1), for which the + ``xhtml`` and ``html`` serializers described below should be preferred. + +``xhtml`` + The ``XHTMLSerializer`` is a specialization of the generic ``XMLSerializer`` + that understands the pecularities of producing XML-compliant output that can + also be parsed without problems by the HTML parsers found in modern web + browsers. Thus, the output by this serializer should be usable whether sent + as "text/html" or "application/xhtml+html" (although there are a lot of + subtle issues to pay attention to when switching between the two, in + particular with respect to differences in the DOM and CSS). + + For example, instead of rendering a script tag as ````. Also, it will normalize any boolean attributes values + that are minimized in HTML, so that for example ``
`` + becomes ``
``. + + This serializer supports the use of namespaces for compound documents, for + example to use inline SVG inside an XHTML document. + +``html`` + The ``HTMLSerializer`` produces proper HTML markup. The main differences + compared to ``xhtml`` serialization are that boolean attributes are + minimized, empty tags are not self-closing (so it's ``
`` instead of + ``
``), and that the contents of ``