69
69
<pre class="py-doctest">
70
70
<span class="py-prompt">>>> </span><span class="py-keyword">from</span> genshi.builder <span class="py-keyword">import</span> tag
71
71
<span class="py-prompt">>>> </span>elem = tag.div(tag.a(<span class="py-string">'<Hello!>'</span>, href=<span class="py-string">'foo'</span>), tag.br)
72
<span class="py-prompt">>>> </span><span class="py-keyword">print</span> elem
72
<span class="py-prompt">>>> </span><span class="py-keyword">print</span>(elem)
73
73
<span class="py-output"><div><a href="foo">&lt;Hello!&gt;</a><br/></div></span>
74
<span class="py-output"></span><span class="py-prompt">>>> </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">>>> </span><span class="py-keyword">print</span>(<span class="py-string">''</span>.join(TextSerializer()(elem.generate())))
75
75
<span class="py-output"><Hello!></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">>>> </span>elem = tag.div(Markup(<span class="py-string">'<a href="foo">Hello &amp; Bye!</a><br/>'</span>))
80
<span class="py-prompt">>>> </span><span class="py-keyword">print</span> elem.generate().render(TextSerializer)
80
<span class="py-prompt">>>> </span><span class="py-keyword">print</span>(elem.generate().render(TextSerializer, encoding=None))
81
81
<span class="py-output"><a href="foo">Hello &amp; Bye!</a><br/></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">>>> </span><span class="py-keyword">print</span> elem.generate().render(TextSerializer, strip_markup=True)
86
<span class="py-prompt">>>> </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 & Bye!</span></pre>
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>,
231
235
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
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
236
240
<td align="right" class="footer">
237
241
<a target="mainFrame" href="http://epydoc.sourceforge.net"