~jtaylor/ubuntu/oneiric/genshi/dh_python2

« back to all changes in this revision

Viewing changes to doc/api/genshi.output.TextSerializer-class.html

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-05-05 02:05:51 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100505020551-zmiep9cjs3s5c093
Tags: 0.6-1ubuntu1
* Merge from debian unstable.  Remaining changes:
  - debian/rules: Enable testsuite.
  - Update maintainer according to specification.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
<pre class="py-doctest">
70
70
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">from</span> genshi.builder <span class="py-keyword">import</span> tag
71
71
<span class="py-prompt">&gt;&gt;&gt; </span>elem = tag.div(tag.a(<span class="py-string">'&lt;Hello!&gt;'</span>, href=<span class="py-string">'foo'</span>), tag.br)
72
 
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">print</span> elem
 
72
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">print</span>(elem)
73
73
<span class="py-output">&lt;div&gt;&lt;a href=&quot;foo&quot;&gt;&amp;lt;Hello!&amp;gt;&lt;/a&gt;&lt;br/&gt;&lt;/div&gt;</span>
74
 
<span class="py-output"></span><span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">print</span> <span class="py-string">''</span>.join(TextSerializer()(elem.generate()))
 
74
<span class="py-output"></span><span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">print</span>(<span class="py-string">''</span>.join(TextSerializer()(elem.generate())))
75
75
<span class="py-output">&lt;Hello!&gt;</span></pre>
76
76
<p>If text events contain literal markup (instances of the <a href="genshi.core.Markup-class.html" class="link">Markup</a> class),
77
77
that markup is by default passed through unchanged:</p>
78
78
<pre class="py-doctest">
79
79
<span class="py-prompt">&gt;&gt;&gt; </span>elem = tag.div(Markup(<span class="py-string">'&lt;a href=&quot;foo&quot;&gt;Hello &amp;amp; Bye!&lt;/a&gt;&lt;br/&gt;'</span>))
80
 
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">print</span> elem.generate().render(TextSerializer)
 
80
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">print</span>(elem.generate().render(TextSerializer, encoding=None))
81
81
<span class="py-output">&lt;a href=&quot;foo&quot;&gt;Hello &amp;amp; Bye!&lt;/a&gt;&lt;br/&gt;</span></pre>
82
82
<p>You can use the <tt class="rst-docutils literal"><span class="pre">strip_markup</span></tt> to change this behavior, so that tags and
83
83
entities are stripped from the output (or in the case of entities,
84
84
replaced with the equivalent character):</p>
85
85
<pre class="py-doctest">
86
 
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">print</span> elem.generate().render(TextSerializer, strip_markup=True)
 
86
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">print</span>(elem.generate().render(TextSerializer, strip_markup=True,
 
87
<span class="py-more">... </span>                             encoding=None))
87
88
<span class="py-output">Hello &amp; Bye!</span></pre>
88
89
 
89
90
<!-- ==================== INSTANCE METHODS ==================== -->
133
134
    <td colspan="2" class="summary">
134
135
    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
135
136
      <code>__delattr__</code>,
 
137
      <code>__format__</code>,
136
138
      <code>__getattribute__</code>,
137
139
      <code>__hash__</code>,
138
140
      <code>__new__</code>,
140
142
      <code>__reduce_ex__</code>,
141
143
      <code>__repr__</code>,
142
144
      <code>__setattr__</code>,
143
 
      <code>__str__</code>
 
145
      <code>__sizeof__</code>,
 
146
      <code>__str__</code>,
 
147
      <code>__subclasshook__</code>
144
148
      </p>
145
149
    </td>
146
150
  </tr>
231
235
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
232
236
  <tr>
233
237
    <td align="left" class="footer">
234
 
    Generated by Epydoc 3.0.1 on Wed Jul  9 18:16:21 2008
 
238
    Generated by Epydoc 3.0.1 on Thu Apr 22 14:10:36 2010
235
239
    </td>
236
240
    <td align="right" class="footer">
237
241
      <a target="mainFrame" href="http://epydoc.sourceforge.net"