Imported Upstream version 2.3.5
[platform/upstream/python-lxml.git] / doc / html / api / lxml.html.diff-pysrc.html
1 <?xml version="1.0" encoding="ascii"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
3           "DTD/xhtml1-transitional.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 <head>
6   <title>lxml.html.diff</title>
7   <link rel="stylesheet" href="epydoc.css" type="text/css" />
8   <script type="text/javascript" src="epydoc.js"></script>
9 </head>
10
11 <body bgcolor="white" text="black" link="blue" vlink="#204080"
12       alink="#204080">
13 <!-- ==================== NAVIGATION BAR ==================== -->
14 <table class="navbar" border="0" width="100%" cellpadding="0"
15        bgcolor="#a0c0ff" cellspacing="0">
16   <tr valign="middle">
17   <!-- Home link -->
18       <th>&nbsp;&nbsp;&nbsp;<a
19         href="lxml-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
20
21   <!-- Tree link -->
22       <th>&nbsp;&nbsp;&nbsp;<a
23         href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
24
25   <!-- Index link -->
26       <th>&nbsp;&nbsp;&nbsp;<a
27         href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
28
29   <!-- Help link -->
30       <th>&nbsp;&nbsp;&nbsp;<a
31         href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
32
33   <!-- Project homepage -->
34       <th class="navbar" align="right" width="100%">
35         <table border="0" cellpadding="0" cellspacing="0">
36           <tr><th class="navbar" align="center"
37             ><a class="navbar" target="_top" href="/">lxml API</a></th>
38           </tr></table></th>
39   </tr>
40 </table>
41 <table width="100%" cellpadding="0" cellspacing="0">
42   <tr valign="top">
43     <td width="100%">
44       <span class="breadcrumbs">
45         <a href="lxml-module.html">Package&nbsp;lxml</a> ::
46         <a href="lxml.html-module.html">Package&nbsp;html</a> ::
47         Module&nbsp;diff
48       </span>
49     </td>
50     <td>
51       <table cellpadding="0" cellspacing="0">
52         <!-- hide/show private -->
53         <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
54     onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
55         <tr><td align="right"><span class="options"
56             >[<a href="frames.html" target="_top">frames</a
57             >]&nbsp;|&nbsp;<a href="lxml.html.diff-pysrc.html"
58             target="_top">no&nbsp;frames</a>]</span></td></tr>
59       </table>
60     </td>
61   </tr>
62 </table>
63 <h1 class="epydoc">Source Code for <a href="lxml.html.diff-module.html">Module lxml.html.diff</a></h1>
64 <pre class="py-src">
65 <a name="L1"></a><tt class="py-lineno">  1</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">difflib</tt> </tt>
66 <a name="L2"></a><tt class="py-lineno">  2</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt id="link-0" class="py-name" targets="Package lxml=lxml-module.html"><a title="lxml" class="py-name" href="#" onclick="return doclink('link-0', 'lxml', 'link-0');">lxml</a></tt> <tt class="py-keyword">import</tt> <tt id="link-1" class="py-name" targets="Module lxml.etree=lxml.etree-module.html,Variable lxml.sax.ElementTreeContentHandler.etree=lxml.sax.ElementTreeContentHandler-class.html#etree,Variable lxml.tests.test_elementtree.CElementTreeTestCase.etree=lxml.tests.test_elementtree.CElementTreeTestCase-class.html#etree,Variable lxml.tests.test_elementtree.ETreeTestCaseBase.etree=lxml.tests.test_elementtree.ETreeTestCaseBase-class.html#etree,Variable lxml.tests.test_io.IOTestCaseBase.etree=lxml.tests.test_io.IOTestCaseBase-class.html#etree"><a title="lxml.etree
67 lxml.sax.ElementTreeContentHandler.etree
68 lxml.tests.test_elementtree.CElementTreeTestCase.etree
69 lxml.tests.test_elementtree.ETreeTestCaseBase.etree
70 lxml.tests.test_io.IOTestCaseBase.etree" class="py-name" href="#" onclick="return doclink('link-1', 'etree', 'link-1');">etree</a></tt> </tt>
71 <a name="L3"></a><tt class="py-lineno">  3</tt>  <tt class="py-line"><tt class="py-keyword">from</tt> <tt id="link-2" class="py-name"><a title="lxml" class="py-name" href="#" onclick="return doclink('link-2', 'lxml', 'link-0');">lxml</a></tt><tt class="py-op">.</tt><tt id="link-3" class="py-name" targets="Package lxml.html=lxml.html-module.html,Method lxml.html.diff.href_token.html()=lxml.html.diff.href_token-class.html#html,Method lxml.html.diff.tag_token.html()=lxml.html.diff.tag_token-class.html#html,Method lxml.html.diff.token.html()=lxml.html.diff.token-class.html#html"><a title="lxml.html
72 lxml.html.diff.href_token.html
73 lxml.html.diff.tag_token.html
74 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-3', 'html', 'link-3');">html</a></tt> <tt class="py-keyword">import</tt> <tt id="link-4" class="py-name" targets="Function lxml.html.fragment_fromstring()=lxml.html-module.html#fragment_fromstring,Function lxml.html.html5parser.fragment_fromstring()=lxml.html.html5parser-module.html#fragment_fromstring"><a title="lxml.html.fragment_fromstring
75 lxml.html.html5parser.fragment_fromstring" class="py-name" href="#" onclick="return doclink('link-4', 'fragment_fromstring', 'link-4');">fragment_fromstring</a></tt> </tt>
76 <a name="L4"></a><tt class="py-lineno">  4</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">cgi</tt> </tt>
77 <a name="L5"></a><tt class="py-lineno">  5</tt>  <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">re</tt> </tt>
78 <a name="L6"></a><tt class="py-lineno">  6</tt>  <tt class="py-line"> </tt>
79 <a name="L7"></a><tt class="py-lineno">  7</tt>  <tt class="py-line"><tt class="py-name">__all__</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-string">'html_annotate'</tt><tt class="py-op">,</tt> <tt class="py-string">'htmldiff'</tt><tt class="py-op">]</tt> </tt>
80 <a name="L8"></a><tt class="py-lineno">  8</tt>  <tt class="py-line"> </tt>
81 <a name="L9"></a><tt class="py-lineno">  9</tt>  <tt class="py-line"><tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
82 <a name="L10"></a><tt class="py-lineno"> 10</tt>  <tt class="py-line">    <tt class="py-name">_unicode</tt> <tt class="py-op">=</tt> <tt class="py-name">unicode</tt> </tt>
83 <a name="L11"></a><tt class="py-lineno"> 11</tt>  <tt class="py-line"><tt class="py-keyword">except</tt> <tt class="py-name">NameError</tt><tt class="py-op">:</tt> </tt>
84 <a name="L12"></a><tt class="py-lineno"> 12</tt>  <tt class="py-line">    <tt class="py-comment"># Python 3</tt> </tt>
85 <a name="L13"></a><tt class="py-lineno"> 13</tt>  <tt class="py-line">    <tt class="py-name">_unicode</tt> <tt class="py-op">=</tt> <tt class="py-name">str</tt> </tt>
86 <a name="L14"></a><tt class="py-lineno"> 14</tt>  <tt class="py-line"><tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
87 <a name="L15"></a><tt class="py-lineno"> 15</tt>  <tt class="py-line">    <tt class="py-name">basestring</tt> <tt class="py-op">=</tt> <tt class="py-name">__builtins__</tt><tt class="py-op">[</tt><tt class="py-string">"basestring"</tt><tt class="py-op">]</tt> </tt>
88 <a name="L16"></a><tt class="py-lineno"> 16</tt>  <tt class="py-line"><tt class="py-keyword">except</tt> <tt class="py-op">(</tt><tt class="py-name">KeyError</tt><tt class="py-op">,</tt> <tt class="py-name">NameError</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
89 <a name="L17"></a><tt class="py-lineno"> 17</tt>  <tt class="py-line">    <tt class="py-comment"># Python 3</tt> </tt>
90 <a name="L18"></a><tt class="py-lineno"> 18</tt>  <tt class="py-line">    <tt class="py-name">basestring</tt> <tt class="py-op">=</tt> <tt class="py-name">str</tt> </tt>
91 <a name="L19"></a><tt class="py-lineno"> 19</tt>  <tt class="py-line"> </tt>
92 <a name="L20"></a><tt class="py-lineno"> 20</tt>  <tt class="py-line"><tt class="py-comment">############################################################</tt> </tt>
93 <a name="L21"></a><tt class="py-lineno"> 21</tt>  <tt class="py-line"><tt class="py-comment">## Annotation</tt> </tt>
94 <a name="L22"></a><tt class="py-lineno"> 22</tt>  <tt class="py-line"><tt class="py-comment">############################################################</tt> </tt>
95 <a name="L23"></a><tt class="py-lineno"> 23</tt>  <tt class="py-line"> </tt>
96 <a name="default_markup"></a><div id="default_markup-def"><a name="L24"></a><tt class="py-lineno"> 24</tt> <a class="py-toggle" href="#" id="default_markup-toggle" onclick="return toggle('default_markup');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#default_markup">default_markup</a><tt class="py-op">(</tt><tt class="py-param">text</tt><tt class="py-op">,</tt> <tt class="py-param">version</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
97 </div><div id="default_markup-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="default_markup-expanded"><a name="L25"></a><tt class="py-lineno"> 25</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-string">'&lt;span title="%s"&gt;%s&lt;/span&gt;'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt> </tt>
98 <a name="L26"></a><tt class="py-lineno"> 26</tt>  <tt class="py-line">        <tt class="py-name">cgi</tt><tt class="py-op">.</tt><tt class="py-name">escape</tt><tt class="py-op">(</tt><tt class="py-name">_unicode</tt><tt class="py-op">(</tt><tt id="link-5" class="py-name" targets="Variable lxml.etree._BaseParser.version=lxml.etree._BaseParser-class.html#version"><a title="lxml.etree._BaseParser.version" class="py-name" href="#" onclick="return doclink('link-5', 'version', 'link-5');">version</a></tt><tt class="py-op">)</tt><tt class="py-op">,</tt> <tt class="py-number">1</tt><tt class="py-op">)</tt><tt class="py-op">,</tt> <tt id="link-6" class="py-name" targets="Variable lxml.etree.QName.text=lxml.etree.QName-class.html#text,Variable lxml.etree._AppendOnlyElementProxy.text=lxml.etree._AppendOnlyElementProxy-class.html#text,Variable lxml.etree._Element.text=lxml.etree._Element-class.html#text,Variable lxml.etree._Entity.text=lxml.etree._Entity-class.html#text,Variable lxml.etree._ModifyContentOnlyProxy.text=lxml.etree._ModifyContentOnlyProxy-class.html#text,Variable lxml.etree._ReadOnlyEntityProxy.text=lxml.etree._ReadOnlyEntityProxy-class.html#text,Variable lxml.etree._ReadOnlyProxy.text=lxml.etree._ReadOnlyProxy-class.html#text,Variable lxml.etree.__ContentOnlyElement.text=lxml.etree.__ContentOnlyElement-class.html#text,Variable lxml.objectify.ObjectifiedElement.text=lxml.objectify.ObjectifiedElement-class.html#text,Variable xml.etree.ElementTree.Element.text=xml.etree.ElementTree.Element-class.html#text"><a title="lxml.etree.QName.text
99 lxml.etree._AppendOnlyElementProxy.text
100 lxml.etree._Element.text
101 lxml.etree._Entity.text
102 lxml.etree._ModifyContentOnlyProxy.text
103 lxml.etree._ReadOnlyEntityProxy.text
104 lxml.etree._ReadOnlyProxy.text
105 lxml.etree.__ContentOnlyElement.text
106 lxml.objectify.ObjectifiedElement.text
107 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-6', 'text', 'link-6');">text</a></tt><tt class="py-op">)</tt> </tt>
108 </div><a name="L27"></a><tt class="py-lineno"> 27</tt>  <tt class="py-line"> </tt>
109 <a name="html_annotate"></a><div id="html_annotate-def"><a name="L28"></a><tt class="py-lineno"> 28</tt> <a class="py-toggle" href="#" id="html_annotate-toggle" onclick="return toggle('html_annotate');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#html_annotate">html_annotate</a><tt class="py-op">(</tt><tt class="py-param">doclist</tt><tt class="py-op">,</tt> <tt class="py-param">markup</tt><tt class="py-op">=</tt><tt id="link-7" class="py-name" targets="Function lxml.html.diff.default_markup()=lxml.html.diff-module.html#default_markup"><a title="lxml.html.diff.default_markup" class="py-name" href="#" onclick="return doclink('link-7', 'default_markup', 'link-7');">default_markup</a></tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
110 </div><div id="html_annotate-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="html_annotate-expanded"><a name="L29"></a><tt class="py-lineno"> 29</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
111 <a name="L30"></a><tt class="py-lineno"> 30</tt>  <tt class="py-line"><tt class="py-docstring">    doclist should be ordered from oldest to newest, like::</tt> </tt>
112 <a name="L31"></a><tt class="py-lineno"> 31</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
113 <a name="L32"></a><tt class="py-lineno"> 32</tt>  <tt class="py-line"><tt class="py-docstring">        &gt;&gt;&gt; version1 = 'Hello World'</tt> </tt>
114 <a name="L33"></a><tt class="py-lineno"> 33</tt>  <tt class="py-line"><tt class="py-docstring">        &gt;&gt;&gt; version2 = 'Goodbye World'</tt> </tt>
115 <a name="L34"></a><tt class="py-lineno"> 34</tt>  <tt class="py-line"><tt class="py-docstring">        &gt;&gt;&gt; print(html_annotate([(version1, 'version 1'),</tt> </tt>
116 <a name="L35"></a><tt class="py-lineno"> 35</tt>  <tt class="py-line"><tt class="py-docstring">        ...                      (version2, 'version 2')]))</tt> </tt>
117 <a name="L36"></a><tt class="py-lineno"> 36</tt>  <tt class="py-line"><tt class="py-docstring">        &lt;span title="version 2"&gt;Goodbye&lt;/span&gt; &lt;span title="version 1"&gt;World&lt;/span&gt;</tt> </tt>
118 <a name="L37"></a><tt class="py-lineno"> 37</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
119 <a name="L38"></a><tt class="py-lineno"> 38</tt>  <tt class="py-line"><tt class="py-docstring">    The documents must be *fragments* (str/UTF8 or unicode), not</tt> </tt>
120 <a name="L39"></a><tt class="py-lineno"> 39</tt>  <tt class="py-line"><tt class="py-docstring">    complete documents</tt> </tt>
121 <a name="L40"></a><tt class="py-lineno"> 40</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
122 <a name="L41"></a><tt class="py-lineno"> 41</tt>  <tt class="py-line"><tt class="py-docstring">    The markup argument is a function to markup the spans of words.</tt> </tt>
123 <a name="L42"></a><tt class="py-lineno"> 42</tt>  <tt class="py-line"><tt class="py-docstring">    This function is called like markup('Hello', 'version 2'), and</tt> </tt>
124 <a name="L43"></a><tt class="py-lineno"> 43</tt>  <tt class="py-line"><tt class="py-docstring">    returns HTML.  The first argument is text and never includes any</tt> </tt>
125 <a name="L44"></a><tt class="py-lineno"> 44</tt>  <tt class="py-line"><tt class="py-docstring">    markup.  The default uses a span with a title:</tt> </tt>
126 <a name="L45"></a><tt class="py-lineno"> 45</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
127 <a name="L46"></a><tt class="py-lineno"> 46</tt>  <tt class="py-line"><tt class="py-docstring">        &gt;&gt;&gt; print(default_markup('Some Text', 'by Joe'))</tt> </tt>
128 <a name="L47"></a><tt class="py-lineno"> 47</tt>  <tt class="py-line"><tt class="py-docstring">        &lt;span title="by Joe"&gt;Some Text&lt;/span&gt;</tt> </tt>
129 <a name="L48"></a><tt class="py-lineno"> 48</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
130 <a name="L49"></a><tt class="py-lineno"> 49</tt>  <tt class="py-line">    <tt class="py-comment"># The basic strategy we have is to split the documents up into</tt> </tt>
131 <a name="L50"></a><tt class="py-lineno"> 50</tt>  <tt class="py-line">    <tt class="py-comment"># logical tokens (which are words with attached markup).  We then</tt> </tt>
132 <a name="L51"></a><tt class="py-lineno"> 51</tt>  <tt class="py-line">    <tt class="py-comment"># do diffs of each of the versions to track when a token first</tt> </tt>
133 <a name="L52"></a><tt class="py-lineno"> 52</tt>  <tt class="py-line">    <tt class="py-comment"># appeared in the document; the annotation attached to the token</tt> </tt>
134 <a name="L53"></a><tt class="py-lineno"> 53</tt>  <tt class="py-line">    <tt class="py-comment"># is the version where it first appeared.</tt> </tt>
135 <a name="L54"></a><tt class="py-lineno"> 54</tt>  <tt class="py-line">    <tt class="py-name">tokenlist</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt id="link-8" class="py-name" targets="Function lxml.html.diff.tokenize_annotated()=lxml.html.diff-module.html#tokenize_annotated"><a title="lxml.html.diff.tokenize_annotated" class="py-name" href="#" onclick="return doclink('link-8', 'tokenize_annotated', 'link-8');">tokenize_annotated</a></tt><tt class="py-op">(</tt><tt class="py-name">doc</tt><tt class="py-op">,</tt> <tt id="link-9" class="py-name"><a title="lxml.etree._BaseParser.version" class="py-name" href="#" onclick="return doclink('link-9', 'version', 'link-5');">version</a></tt><tt class="py-op">)</tt> </tt>
136 <a name="L55"></a><tt class="py-lineno"> 55</tt>  <tt class="py-line">                 <tt class="py-keyword">for</tt> <tt class="py-name">doc</tt><tt class="py-op">,</tt> <tt id="link-10" class="py-name"><a title="lxml.etree._BaseParser.version" class="py-name" href="#" onclick="return doclink('link-10', 'version', 'link-5');">version</a></tt> <tt class="py-keyword">in</tt> <tt class="py-name">doclist</tt><tt class="py-op">]</tt> </tt>
137 <a name="L56"></a><tt class="py-lineno"> 56</tt>  <tt class="py-line">    <tt class="py-name">cur_tokens</tt> <tt class="py-op">=</tt> <tt class="py-name">tokenlist</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt> </tt>
138 <a name="L57"></a><tt class="py-lineno"> 57</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt class="py-name">tokens</tt> <tt class="py-keyword">in</tt> <tt class="py-name">tokenlist</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">:</tt><tt class="py-op">]</tt><tt class="py-op">:</tt> </tt>
139 <a name="L58"></a><tt class="py-lineno"> 58</tt>  <tt class="py-line">        <tt id="link-11" class="py-name" targets="Function lxml.html.diff.html_annotate_merge_annotations()=lxml.html.diff-module.html#html_annotate_merge_annotations"><a title="lxml.html.diff.html_annotate_merge_annotations" class="py-name" href="#" onclick="return doclink('link-11', 'html_annotate_merge_annotations', 'link-11');">html_annotate_merge_annotations</a></tt><tt class="py-op">(</tt><tt class="py-name">cur_tokens</tt><tt class="py-op">,</tt> <tt class="py-name">tokens</tt><tt class="py-op">)</tt> </tt>
140 <a name="L59"></a><tt class="py-lineno"> 59</tt>  <tt class="py-line">        <tt class="py-name">cur_tokens</tt> <tt class="py-op">=</tt> <tt class="py-name">tokens</tt> </tt>
141 <a name="L60"></a><tt class="py-lineno"> 60</tt>  <tt class="py-line"> </tt>
142 <a name="L61"></a><tt class="py-lineno"> 61</tt>  <tt class="py-line">    <tt class="py-comment"># After we've tracked all the tokens, we can combine spans of text</tt> </tt>
143 <a name="L62"></a><tt class="py-lineno"> 62</tt>  <tt class="py-line">    <tt class="py-comment"># that are adjacent and have the same annotation</tt> </tt>
144 <a name="L63"></a><tt class="py-lineno"> 63</tt>  <tt class="py-line">    <tt class="py-name">cur_tokens</tt> <tt class="py-op">=</tt> <tt id="link-12" class="py-name" targets="Function lxml.html.diff.compress_tokens()=lxml.html.diff-module.html#compress_tokens"><a title="lxml.html.diff.compress_tokens" class="py-name" href="#" onclick="return doclink('link-12', 'compress_tokens', 'link-12');">compress_tokens</a></tt><tt class="py-op">(</tt><tt class="py-name">cur_tokens</tt><tt class="py-op">)</tt> </tt>
145 <a name="L64"></a><tt class="py-lineno"> 64</tt>  <tt class="py-line">    <tt class="py-comment"># And finally add markup</tt> </tt>
146 <a name="L65"></a><tt class="py-lineno"> 65</tt>  <tt class="py-line">    <tt class="py-name">result</tt> <tt class="py-op">=</tt> <tt id="link-13" class="py-name" targets="Function lxml.html.diff.markup_serialize_tokens()=lxml.html.diff-module.html#markup_serialize_tokens"><a title="lxml.html.diff.markup_serialize_tokens" class="py-name" href="#" onclick="return doclink('link-13', 'markup_serialize_tokens', 'link-13');">markup_serialize_tokens</a></tt><tt class="py-op">(</tt><tt class="py-name">cur_tokens</tt><tt class="py-op">,</tt> <tt class="py-name">markup</tt><tt class="py-op">)</tt> </tt>
147 <a name="L66"></a><tt class="py-lineno"> 66</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-string">''</tt><tt class="py-op">.</tt><tt id="link-14" class="py-name" targets="Method lxml.cssselect.XPathExpr.join()=lxml.cssselect.XPathExpr-class.html#join"><a title="lxml.cssselect.XPathExpr.join" class="py-name" href="#" onclick="return doclink('link-14', 'join', 'link-14');">join</a></tt><tt class="py-op">(</tt><tt class="py-name">result</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt id="link-15" class="py-name" targets="Function lxml.doctestcompare.strip()=lxml.doctestcompare-module.html#strip"><a title="lxml.doctestcompare.strip" class="py-name" href="#" onclick="return doclink('link-15', 'strip', 'link-15');">strip</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
148 </div><a name="L67"></a><tt class="py-lineno"> 67</tt>  <tt class="py-line"> </tt>
149 <a name="tokenize_annotated"></a><div id="tokenize_annotated-def"><a name="L68"></a><tt class="py-lineno"> 68</tt> <a class="py-toggle" href="#" id="tokenize_annotated-toggle" onclick="return toggle('tokenize_annotated');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#tokenize_annotated">tokenize_annotated</a><tt class="py-op">(</tt><tt class="py-param">doc</tt><tt class="py-op">,</tt> <tt class="py-param">annotation</tt><tt class="py-op">)</tt><tt class="py-op">:</tt>  </tt>
150 </div><a name="L69"></a><tt class="py-lineno"> 69</tt>  <tt class="py-line">    <tt class="py-docstring">"""Tokenize a document and add an annotation attribute to each token</tt> </tt>
151 <a name="L70"></a><tt class="py-lineno"> 70</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
152 <a name="L71"></a><tt class="py-lineno"> 71</tt>  <tt class="py-line">    <tt class="py-name">tokens</tt> <tt class="py-op">=</tt> <tt id="link-16" class="py-name" targets="Function lxml.cssselect.tokenize()=lxml.cssselect-module.html#tokenize,Function lxml.html.diff.tokenize()=lxml.html.diff-module.html#tokenize"><a title="lxml.cssselect.tokenize
153 lxml.html.diff.tokenize" class="py-name" href="#" onclick="return doclink('link-16', 'tokenize', 'link-16');">tokenize</a></tt><tt class="py-op">(</tt><tt class="py-name">doc</tt><tt class="py-op">,</tt> <tt class="py-name">include_hrefs</tt><tt class="py-op">=</tt><tt class="py-name">False</tt><tt class="py-op">)</tt> </tt>
154 <a name="L72"></a><tt class="py-lineno"> 72</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt class="py-name">tok</tt> <tt class="py-keyword">in</tt> <tt class="py-name">tokens</tt><tt class="py-op">:</tt>  </tt>
155 <a name="L73"></a><tt class="py-lineno"> 73</tt>  <tt class="py-line">        <tt class="py-name">tok</tt><tt class="py-op">.</tt><tt class="py-name">annotation</tt> <tt class="py-op">=</tt> <tt class="py-name">annotation</tt> </tt>
156 <a name="L74"></a><tt class="py-lineno"> 74</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">tokens</tt> </tt>
157 </div><a name="L75"></a><tt class="py-lineno"> 75</tt>  <tt class="py-line"> </tt>
158 <a name="html_annotate_merge_annotations"></a><div id="html_annotate_merge_annotations-def"><a name="L76"></a><tt class="py-lineno"> 76</tt> <a class="py-toggle" href="#" id="html_annotate_merge_annotations-toggle" onclick="return toggle('html_annotate_merge_annotations');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#html_annotate_merge_annotations">html_annotate_merge_annotations</a><tt class="py-op">(</tt><tt class="py-param">tokens_old</tt><tt class="py-op">,</tt> <tt class="py-param">tokens_new</tt><tt class="py-op">)</tt><tt class="py-op">:</tt>  </tt>
159 </div><a name="L77"></a><tt class="py-lineno"> 77</tt>  <tt class="py-line">    <tt class="py-docstring">"""Merge the annotations from tokens_old into tokens_new, when the</tt> </tt>
160 <a name="L78"></a><tt class="py-lineno"> 78</tt>  <tt class="py-line"><tt class="py-docstring">    tokens in the new document already existed in the old document.</tt> </tt>
161 <a name="L79"></a><tt class="py-lineno"> 79</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
162 <a name="L80"></a><tt class="py-lineno"> 80</tt>  <tt class="py-line">    <tt class="py-name">s</tt> <tt class="py-op">=</tt> <tt id="link-17" class="py-name" targets="Class lxml.html.diff.InsensitiveSequenceMatcher=lxml.html.diff.InsensitiveSequenceMatcher-class.html"><a title="lxml.html.diff.InsensitiveSequenceMatcher" class="py-name" href="#" onclick="return doclink('link-17', 'InsensitiveSequenceMatcher', 'link-17');">InsensitiveSequenceMatcher</a></tt><tt class="py-op">(</tt><tt class="py-name">a</tt><tt class="py-op">=</tt><tt class="py-name">tokens_old</tt><tt class="py-op">,</tt> <tt class="py-name">b</tt><tt class="py-op">=</tt><tt class="py-name">tokens_new</tt><tt class="py-op">)</tt> </tt>
163 <a name="L81"></a><tt class="py-lineno"> 81</tt>  <tt class="py-line">    <tt class="py-name">commands</tt> <tt class="py-op">=</tt> <tt class="py-name">s</tt><tt class="py-op">.</tt><tt class="py-name">get_opcodes</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
164 <a name="L82"></a><tt class="py-lineno"> 82</tt>  <tt class="py-line"> </tt>
165 <a name="L83"></a><tt class="py-lineno"> 83</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt class="py-name">command</tt><tt class="py-op">,</tt> <tt class="py-name">i1</tt><tt class="py-op">,</tt> <tt class="py-name">i2</tt><tt class="py-op">,</tt> <tt class="py-name">j1</tt><tt class="py-op">,</tt> <tt class="py-name">j2</tt> <tt class="py-keyword">in</tt> <tt class="py-name">commands</tt><tt class="py-op">:</tt> </tt>
166 <a name="L84"></a><tt class="py-lineno"> 84</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">command</tt> <tt class="py-op">==</tt> <tt class="py-string">'equal'</tt><tt class="py-op">:</tt>  </tt>
167 <a name="L85"></a><tt class="py-lineno"> 85</tt>  <tt class="py-line">            <tt class="py-name">eq_old</tt> <tt class="py-op">=</tt> <tt class="py-name">tokens_old</tt><tt class="py-op">[</tt><tt class="py-name">i1</tt><tt class="py-op">:</tt><tt class="py-name">i2</tt><tt class="py-op">]</tt> </tt>
168 <a name="L86"></a><tt class="py-lineno"> 86</tt>  <tt class="py-line">            <tt class="py-name">eq_new</tt> <tt class="py-op">=</tt> <tt class="py-name">tokens_new</tt><tt class="py-op">[</tt><tt class="py-name">j1</tt><tt class="py-op">:</tt><tt class="py-name">j2</tt><tt class="py-op">]</tt> </tt>
169 <a name="L87"></a><tt class="py-lineno"> 87</tt>  <tt class="py-line">            <tt id="link-18" class="py-name" targets="Function lxml.html.diff.copy_annotations()=lxml.html.diff-module.html#copy_annotations"><a title="lxml.html.diff.copy_annotations" class="py-name" href="#" onclick="return doclink('link-18', 'copy_annotations', 'link-18');">copy_annotations</a></tt><tt class="py-op">(</tt><tt class="py-name">eq_old</tt><tt class="py-op">,</tt> <tt class="py-name">eq_new</tt><tt class="py-op">)</tt> </tt>
170 </div><a name="L88"></a><tt class="py-lineno"> 88</tt>  <tt class="py-line"> </tt>
171 <a name="copy_annotations"></a><div id="copy_annotations-def"><a name="L89"></a><tt class="py-lineno"> 89</tt> <a class="py-toggle" href="#" id="copy_annotations-toggle" onclick="return toggle('copy_annotations');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#copy_annotations">copy_annotations</a><tt class="py-op">(</tt><tt class="py-param">src</tt><tt class="py-op">,</tt> <tt class="py-param">dest</tt><tt class="py-op">)</tt><tt class="py-op">:</tt>  </tt>
172 </div><a name="L90"></a><tt class="py-lineno"> 90</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
173 <a name="L91"></a><tt class="py-lineno"> 91</tt>  <tt class="py-line"><tt class="py-docstring">    Copy annotations from the tokens listed in src to the tokens in dest</tt> </tt>
174 <a name="L92"></a><tt class="py-lineno"> 92</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
175 <a name="L93"></a><tt class="py-lineno"> 93</tt>  <tt class="py-line">    <tt class="py-keyword">assert</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">src</tt><tt class="py-op">)</tt> <tt class="py-op">==</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">dest</tt><tt class="py-op">)</tt> </tt>
176 <a name="L94"></a><tt class="py-lineno"> 94</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt class="py-name">src_tok</tt><tt class="py-op">,</tt> <tt class="py-name">dest_tok</tt> <tt class="py-keyword">in</tt> <tt class="py-name">zip</tt><tt class="py-op">(</tt><tt class="py-name">src</tt><tt class="py-op">,</tt> <tt class="py-name">dest</tt><tt class="py-op">)</tt><tt class="py-op">:</tt>  </tt>
177 <a name="L95"></a><tt class="py-lineno"> 95</tt>  <tt class="py-line">        <tt class="py-name">dest_tok</tt><tt class="py-op">.</tt><tt class="py-name">annotation</tt> <tt class="py-op">=</tt> <tt class="py-name">src_tok</tt><tt class="py-op">.</tt><tt class="py-name">annotation</tt> </tt>
178 </div><a name="L96"></a><tt class="py-lineno"> 96</tt>  <tt class="py-line"> </tt>
179 <a name="compress_tokens"></a><div id="compress_tokens-def"><a name="L97"></a><tt class="py-lineno"> 97</tt> <a class="py-toggle" href="#" id="compress_tokens-toggle" onclick="return toggle('compress_tokens');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#compress_tokens">compress_tokens</a><tt class="py-op">(</tt><tt class="py-param">tokens</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
180 </div><div id="compress_tokens-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="compress_tokens-expanded"><a name="L98"></a><tt class="py-lineno"> 98</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
181 <a name="L99"></a><tt class="py-lineno"> 99</tt>  <tt class="py-line"><tt class="py-docstring">    Combine adjacent tokens when there is no HTML between the tokens, </tt> </tt>
182 <a name="L100"></a><tt class="py-lineno">100</tt>  <tt class="py-line"><tt class="py-docstring">    and they share an annotation</tt> </tt>
183 <a name="L101"></a><tt class="py-lineno">101</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
184 <a name="L102"></a><tt class="py-lineno">102</tt>  <tt class="py-line">    <tt class="py-name">result</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-name">tokens</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">]</tt>  </tt>
185 <a name="L103"></a><tt class="py-lineno">103</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt class="py-name">tok</tt> <tt class="py-keyword">in</tt> <tt class="py-name">tokens</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">:</tt><tt class="py-op">]</tt><tt class="py-op">:</tt>  </tt>
186 <a name="L104"></a><tt class="py-lineno">104</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-op">(</tt><tt class="py-keyword">not</tt> <tt class="py-name">result</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt class="py-name">post_tags</tt> <tt class="py-keyword">and</tt>  </tt>
187 <a name="L105"></a><tt class="py-lineno">105</tt>  <tt class="py-line">            <tt class="py-keyword">not</tt> <tt class="py-name">tok</tt><tt class="py-op">.</tt><tt class="py-name">pre_tags</tt> <tt class="py-keyword">and</tt>  </tt>
188 <a name="L106"></a><tt class="py-lineno">106</tt>  <tt class="py-line">            <tt class="py-name">result</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt class="py-name">annotation</tt> <tt class="py-op">==</tt> <tt class="py-name">tok</tt><tt class="py-op">.</tt><tt class="py-name">annotation</tt><tt class="py-op">)</tt><tt class="py-op">:</tt>  </tt>
189 <a name="L107"></a><tt class="py-lineno">107</tt>  <tt class="py-line">            <tt id="link-19" class="py-name" targets="Function lxml.html.diff.compress_merge_back()=lxml.html.diff-module.html#compress_merge_back"><a title="lxml.html.diff.compress_merge_back" class="py-name" href="#" onclick="return doclink('link-19', 'compress_merge_back', 'link-19');">compress_merge_back</a></tt><tt class="py-op">(</tt><tt class="py-name">result</tt><tt class="py-op">,</tt> <tt class="py-name">tok</tt><tt class="py-op">)</tt> </tt>
190 <a name="L108"></a><tt class="py-lineno">108</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt>  </tt>
191 <a name="L109"></a><tt class="py-lineno">109</tt>  <tt class="py-line">            <tt class="py-name">result</tt><tt class="py-op">.</tt><tt id="link-20" class="py-name" targets="Method lxml.etree._AppendOnlyElementProxy.append()=lxml.etree._AppendOnlyElementProxy-class.html#append,Method lxml.etree._Element.append()=lxml.etree._Element-class.html#append,Method lxml.etree._OpaqueDocumentWrapper.append()=lxml.etree._OpaqueDocumentWrapper-class.html#append,Method lxml.etree.__ContentOnlyElement.append()=lxml.etree.__ContentOnlyElement-class.html#append"><a title="lxml.etree._AppendOnlyElementProxy.append
192 lxml.etree._Element.append
193 lxml.etree._OpaqueDocumentWrapper.append
194 lxml.etree.__ContentOnlyElement.append" class="py-name" href="#" onclick="return doclink('link-20', 'append', 'link-20');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">tok</tt><tt class="py-op">)</tt> </tt>
195 <a name="L110"></a><tt class="py-lineno">110</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">result</tt> </tt>
196 </div><a name="L111"></a><tt class="py-lineno">111</tt>  <tt class="py-line"> </tt>
197 <a name="compress_merge_back"></a><div id="compress_merge_back-def"><a name="L112"></a><tt class="py-lineno">112</tt> <a class="py-toggle" href="#" id="compress_merge_back-toggle" onclick="return toggle('compress_merge_back');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#compress_merge_back">compress_merge_back</a><tt class="py-op">(</tt><tt class="py-param">tokens</tt><tt class="py-op">,</tt> <tt class="py-param">tok</tt><tt class="py-op">)</tt><tt class="py-op">:</tt>  </tt>
198 </div><a name="L113"></a><tt class="py-lineno">113</tt>  <tt class="py-line">    <tt class="py-docstring">""" Merge tok into the last element of tokens (modifying the list of</tt> </tt>
199 <a name="L114"></a><tt class="py-lineno">114</tt>  <tt class="py-line"><tt class="py-docstring">    tokens in-place).  """</tt> </tt>
200 <a name="L115"></a><tt class="py-lineno">115</tt>  <tt class="py-line">    <tt class="py-name">last</tt> <tt class="py-op">=</tt> <tt class="py-name">tokens</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> </tt>
201 <a name="L116"></a><tt class="py-lineno">116</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt id="link-21" class="py-name" targets="Variable lxml.etree._LogEntry.type=lxml.etree._LogEntry-class.html#type,Variable lxml.html.InputElement.type=lxml.html.InputElement-class.html#type"><a title="lxml.etree._LogEntry.type
202 lxml.html.InputElement.type" class="py-name" href="#" onclick="return doclink('link-21', 'type', 'link-21');">type</a></tt><tt class="py-op">(</tt><tt class="py-name">last</tt><tt class="py-op">)</tt> <tt class="py-keyword">is</tt> <tt class="py-keyword">not</tt> <tt id="link-22" class="py-name" targets="Class lxml.html.diff.token=lxml.html.diff.token-class.html"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-22', 'token', 'link-22');">token</a></tt> <tt class="py-keyword">or</tt> <tt id="link-23" class="py-name"><a title="lxml.etree._LogEntry.type
203 lxml.html.InputElement.type" class="py-name" href="#" onclick="return doclink('link-23', 'type', 'link-21');">type</a></tt><tt class="py-op">(</tt><tt class="py-name">tok</tt><tt class="py-op">)</tt> <tt class="py-keyword">is</tt> <tt class="py-keyword">not</tt> <tt id="link-24" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-24', 'token', 'link-22');">token</a></tt><tt class="py-op">:</tt>  </tt>
204 <a name="L117"></a><tt class="py-lineno">117</tt>  <tt class="py-line">        <tt class="py-name">tokens</tt><tt class="py-op">.</tt><tt id="link-25" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.append
205 lxml.etree._Element.append
206 lxml.etree._OpaqueDocumentWrapper.append
207 lxml.etree.__ContentOnlyElement.append" class="py-name" href="#" onclick="return doclink('link-25', 'append', 'link-20');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">tok</tt><tt class="py-op">)</tt> </tt>
208 <a name="L118"></a><tt class="py-lineno">118</tt>  <tt class="py-line">    <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
209 <a name="L119"></a><tt class="py-lineno">119</tt>  <tt class="py-line">        <tt id="link-26" class="py-name"><a title="lxml.etree.QName.text
210 lxml.etree._AppendOnlyElementProxy.text
211 lxml.etree._Element.text
212 lxml.etree._Entity.text
213 lxml.etree._ModifyContentOnlyProxy.text
214 lxml.etree._ReadOnlyEntityProxy.text
215 lxml.etree._ReadOnlyProxy.text
216 lxml.etree.__ContentOnlyElement.text
217 lxml.objectify.ObjectifiedElement.text
218 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-26', 'text', 'link-6');">text</a></tt> <tt class="py-op">=</tt> <tt class="py-name">_unicode</tt><tt class="py-op">(</tt><tt class="py-name">last</tt><tt class="py-op">)</tt> </tt>
219 <a name="L120"></a><tt class="py-lineno">120</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">last</tt><tt class="py-op">.</tt><tt class="py-name">trailing_whitespace</tt><tt class="py-op">:</tt> </tt>
220 <a name="L121"></a><tt class="py-lineno">121</tt>  <tt class="py-line">            <tt id="link-27" class="py-name"><a title="lxml.etree.QName.text
221 lxml.etree._AppendOnlyElementProxy.text
222 lxml.etree._Element.text
223 lxml.etree._Entity.text
224 lxml.etree._ModifyContentOnlyProxy.text
225 lxml.etree._ReadOnlyEntityProxy.text
226 lxml.etree._ReadOnlyProxy.text
227 lxml.etree.__ContentOnlyElement.text
228 lxml.objectify.ObjectifiedElement.text
229 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-27', 'text', 'link-6');">text</a></tt> <tt class="py-op">+=</tt> <tt class="py-string">' '</tt> </tt>
230 <a name="L122"></a><tt class="py-lineno">122</tt>  <tt class="py-line">        <tt id="link-28" class="py-name"><a title="lxml.etree.QName.text
231 lxml.etree._AppendOnlyElementProxy.text
232 lxml.etree._Element.text
233 lxml.etree._Entity.text
234 lxml.etree._ModifyContentOnlyProxy.text
235 lxml.etree._ReadOnlyEntityProxy.text
236 lxml.etree._ReadOnlyProxy.text
237 lxml.etree.__ContentOnlyElement.text
238 lxml.objectify.ObjectifiedElement.text
239 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-28', 'text', 'link-6');">text</a></tt> <tt class="py-op">+=</tt> <tt class="py-name">tok</tt> </tt>
240 <a name="L123"></a><tt class="py-lineno">123</tt>  <tt class="py-line">        <tt class="py-name">merged</tt> <tt class="py-op">=</tt> <tt id="link-29" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-29', 'token', 'link-22');">token</a></tt><tt class="py-op">(</tt><tt id="link-30" class="py-name"><a title="lxml.etree.QName.text
241 lxml.etree._AppendOnlyElementProxy.text
242 lxml.etree._Element.text
243 lxml.etree._Entity.text
244 lxml.etree._ModifyContentOnlyProxy.text
245 lxml.etree._ReadOnlyEntityProxy.text
246 lxml.etree._ReadOnlyProxy.text
247 lxml.etree.__ContentOnlyElement.text
248 lxml.objectify.ObjectifiedElement.text
249 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-30', 'text', 'link-6');">text</a></tt><tt class="py-op">,</tt> </tt>
250 <a name="L124"></a><tt class="py-lineno">124</tt>  <tt class="py-line">                       <tt class="py-name">pre_tags</tt><tt class="py-op">=</tt><tt class="py-name">last</tt><tt class="py-op">.</tt><tt class="py-name">pre_tags</tt><tt class="py-op">,</tt> </tt>
251 <a name="L125"></a><tt class="py-lineno">125</tt>  <tt class="py-line">                       <tt class="py-name">post_tags</tt><tt class="py-op">=</tt><tt class="py-name">tok</tt><tt class="py-op">.</tt><tt class="py-name">post_tags</tt><tt class="py-op">,</tt> </tt>
252 <a name="L126"></a><tt class="py-lineno">126</tt>  <tt class="py-line">                       <tt class="py-name">trailing_whitespace</tt><tt class="py-op">=</tt><tt class="py-name">tok</tt><tt class="py-op">.</tt><tt class="py-name">trailing_whitespace</tt><tt class="py-op">)</tt> </tt>
253 <a name="L127"></a><tt class="py-lineno">127</tt>  <tt class="py-line">        <tt class="py-name">merged</tt><tt class="py-op">.</tt><tt class="py-name">annotation</tt> <tt class="py-op">=</tt> <tt class="py-name">last</tt><tt class="py-op">.</tt><tt class="py-name">annotation</tt> </tt>
254 <a name="L128"></a><tt class="py-lineno">128</tt>  <tt class="py-line">        <tt class="py-name">tokens</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-name">merged</tt> </tt>
255 </div><a name="L129"></a><tt class="py-lineno">129</tt>  <tt class="py-line">     </tt>
256 <a name="markup_serialize_tokens"></a><div id="markup_serialize_tokens-def"><a name="L130"></a><tt class="py-lineno">130</tt> <a class="py-toggle" href="#" id="markup_serialize_tokens-toggle" onclick="return toggle('markup_serialize_tokens');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#markup_serialize_tokens">markup_serialize_tokens</a><tt class="py-op">(</tt><tt class="py-param">tokens</tt><tt class="py-op">,</tt> <tt class="py-param">markup_func</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
257 </div><div id="markup_serialize_tokens-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="markup_serialize_tokens-expanded"><a name="L131"></a><tt class="py-lineno">131</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
258 <a name="L132"></a><tt class="py-lineno">132</tt>  <tt class="py-line"><tt class="py-docstring">    Serialize the list of tokens into a list of text chunks, calling</tt> </tt>
259 <a name="L133"></a><tt class="py-lineno">133</tt>  <tt class="py-line"><tt class="py-docstring">    markup_func around text to add annotations.</tt> </tt>
260 <a name="L134"></a><tt class="py-lineno">134</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
261 <a name="L135"></a><tt class="py-lineno">135</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt id="link-31" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-31', 'token', 'link-22');">token</a></tt> <tt class="py-keyword">in</tt> <tt class="py-name">tokens</tt><tt class="py-op">:</tt> </tt>
262 <a name="L136"></a><tt class="py-lineno">136</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt class="py-name">pre</tt> <tt class="py-keyword">in</tt> <tt id="link-32" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-32', 'token', 'link-22');">token</a></tt><tt class="py-op">.</tt><tt class="py-name">pre_tags</tt><tt class="py-op">:</tt> </tt>
263 <a name="L137"></a><tt class="py-lineno">137</tt>  <tt class="py-line">            <tt class="py-keyword">yield</tt> <tt class="py-name">pre</tt> </tt>
264 <a name="L138"></a><tt class="py-lineno">138</tt>  <tt class="py-line">        <tt id="link-33" class="py-name"><a title="lxml.html
265 lxml.html.diff.href_token.html
266 lxml.html.diff.tag_token.html
267 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-33', 'html', 'link-3');">html</a></tt> <tt class="py-op">=</tt> <tt id="link-34" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-34', 'token', 'link-22');">token</a></tt><tt class="py-op">.</tt><tt id="link-35" class="py-name"><a title="lxml.html
268 lxml.html.diff.href_token.html
269 lxml.html.diff.tag_token.html
270 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-35', 'html', 'link-3');">html</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
271 <a name="L139"></a><tt class="py-lineno">139</tt>  <tt class="py-line">        <tt id="link-36" class="py-name"><a title="lxml.html
272 lxml.html.diff.href_token.html
273 lxml.html.diff.tag_token.html
274 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-36', 'html', 'link-3');">html</a></tt> <tt class="py-op">=</tt> <tt class="py-name">markup_func</tt><tt class="py-op">(</tt><tt id="link-37" class="py-name"><a title="lxml.html
275 lxml.html.diff.href_token.html
276 lxml.html.diff.tag_token.html
277 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-37', 'html', 'link-3');">html</a></tt><tt class="py-op">,</tt> <tt id="link-38" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-38', 'token', 'link-22');">token</a></tt><tt class="py-op">.</tt><tt class="py-name">annotation</tt><tt class="py-op">)</tt> </tt>
278 <a name="L140"></a><tt class="py-lineno">140</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt id="link-39" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-39', 'token', 'link-22');">token</a></tt><tt class="py-op">.</tt><tt class="py-name">trailing_whitespace</tt><tt class="py-op">:</tt> </tt>
279 <a name="L141"></a><tt class="py-lineno">141</tt>  <tt class="py-line">            <tt id="link-40" class="py-name"><a title="lxml.html
280 lxml.html.diff.href_token.html
281 lxml.html.diff.tag_token.html
282 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-40', 'html', 'link-3');">html</a></tt> <tt class="py-op">+=</tt> <tt class="py-string">' '</tt> </tt>
283 <a name="L142"></a><tt class="py-lineno">142</tt>  <tt class="py-line">        <tt class="py-keyword">yield</tt> <tt id="link-41" class="py-name"><a title="lxml.html
284 lxml.html.diff.href_token.html
285 lxml.html.diff.tag_token.html
286 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-41', 'html', 'link-3');">html</a></tt> </tt>
287 <a name="L143"></a><tt class="py-lineno">143</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt class="py-name">post</tt> <tt class="py-keyword">in</tt> <tt id="link-42" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-42', 'token', 'link-22');">token</a></tt><tt class="py-op">.</tt><tt class="py-name">post_tags</tt><tt class="py-op">:</tt> </tt>
288 <a name="L144"></a><tt class="py-lineno">144</tt>  <tt class="py-line">            <tt class="py-keyword">yield</tt> <tt class="py-name">post</tt> </tt>
289 </div><a name="L145"></a><tt class="py-lineno">145</tt>  <tt class="py-line"> </tt>
290 <a name="L146"></a><tt class="py-lineno">146</tt>  <tt class="py-line"> </tt>
291 <a name="L147"></a><tt class="py-lineno">147</tt>  <tt class="py-line"><tt class="py-comment">############################################################</tt> </tt>
292 <a name="L148"></a><tt class="py-lineno">148</tt>  <tt class="py-line"><tt class="py-comment">## HTML Diffs</tt> </tt>
293 <a name="L149"></a><tt class="py-lineno">149</tt>  <tt class="py-line"><tt class="py-comment">############################################################</tt> </tt>
294 <a name="L150"></a><tt class="py-lineno">150</tt>  <tt class="py-line"> </tt>
295 <a name="htmldiff"></a><div id="htmldiff-def"><a name="L151"></a><tt class="py-lineno">151</tt> <a class="py-toggle" href="#" id="htmldiff-toggle" onclick="return toggle('htmldiff');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#htmldiff">htmldiff</a><tt class="py-op">(</tt><tt class="py-param">old_html</tt><tt class="py-op">,</tt> <tt class="py-param">new_html</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
296 </div><div id="htmldiff-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="htmldiff-expanded"><a name="L152"></a><tt class="py-lineno">152</tt>  <tt class="py-line">    <tt class="py-comment">## FIXME: this should take parsed documents too, and use their body</tt> </tt>
297 <a name="L153"></a><tt class="py-lineno">153</tt>  <tt class="py-line">    <tt class="py-comment">## or other content.</tt> </tt>
298 <a name="L154"></a><tt class="py-lineno">154</tt>  <tt class="py-line">    <tt class="py-docstring">""" Do a diff of the old and new document.  The documents are HTML</tt> </tt>
299 <a name="L155"></a><tt class="py-lineno">155</tt>  <tt class="py-line"><tt class="py-docstring">    *fragments* (str/UTF8 or unicode), they are not complete documents</tt> </tt>
300 <a name="L156"></a><tt class="py-lineno">156</tt>  <tt class="py-line"><tt class="py-docstring">    (i.e., no &lt;html&gt; tag).</tt> </tt>
301 <a name="L157"></a><tt class="py-lineno">157</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
302 <a name="L158"></a><tt class="py-lineno">158</tt>  <tt class="py-line"><tt class="py-docstring">    Returns HTML with &lt;ins&gt; and &lt;del&gt; tags added around the</tt> </tt>
303 <a name="L159"></a><tt class="py-lineno">159</tt>  <tt class="py-line"><tt class="py-docstring">    appropriate text.  </tt> </tt>
304 <a name="L160"></a><tt class="py-lineno">160</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
305 <a name="L161"></a><tt class="py-lineno">161</tt>  <tt class="py-line"><tt class="py-docstring">    Markup is generally ignored, with the markup from new_html</tt> </tt>
306 <a name="L162"></a><tt class="py-lineno">162</tt>  <tt class="py-line"><tt class="py-docstring">    preserved, and possibly some markup from old_html (though it is</tt> </tt>
307 <a name="L163"></a><tt class="py-lineno">163</tt>  <tt class="py-line"><tt class="py-docstring">    considered acceptable to lose some of the old markup).  Only the</tt> </tt>
308 <a name="L164"></a><tt class="py-lineno">164</tt>  <tt class="py-line"><tt class="py-docstring">    words in the HTML are diffed.  The exception is &lt;img&gt; tags, which</tt> </tt>
309 <a name="L165"></a><tt class="py-lineno">165</tt>  <tt class="py-line"><tt class="py-docstring">    are treated like words, and the href attribute of &lt;a&gt; tags, which</tt> </tt>
310 <a name="L166"></a><tt class="py-lineno">166</tt>  <tt class="py-line"><tt class="py-docstring">    are noted inside the tag itself when there are changes.</tt> </tt>
311 <a name="L167"></a><tt class="py-lineno">167</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt>  </tt>
312 <a name="L168"></a><tt class="py-lineno">168</tt>  <tt class="py-line">    <tt class="py-name">old_html_tokens</tt> <tt class="py-op">=</tt> <tt id="link-43" class="py-name"><a title="lxml.cssselect.tokenize
313 lxml.html.diff.tokenize" class="py-name" href="#" onclick="return doclink('link-43', 'tokenize', 'link-16');">tokenize</a></tt><tt class="py-op">(</tt><tt class="py-name">old_html</tt><tt class="py-op">)</tt> </tt>
314 <a name="L169"></a><tt class="py-lineno">169</tt>  <tt class="py-line">    <tt class="py-name">new_html_tokens</tt> <tt class="py-op">=</tt> <tt id="link-44" class="py-name"><a title="lxml.cssselect.tokenize
315 lxml.html.diff.tokenize" class="py-name" href="#" onclick="return doclink('link-44', 'tokenize', 'link-16');">tokenize</a></tt><tt class="py-op">(</tt><tt class="py-name">new_html</tt><tt class="py-op">)</tt> </tt>
316 <a name="L170"></a><tt class="py-lineno">170</tt>  <tt class="py-line">    <tt class="py-name">result</tt> <tt class="py-op">=</tt> <tt id="link-45" class="py-name" targets="Function lxml.html.diff.htmldiff_tokens()=lxml.html.diff-module.html#htmldiff_tokens"><a title="lxml.html.diff.htmldiff_tokens" class="py-name" href="#" onclick="return doclink('link-45', 'htmldiff_tokens', 'link-45');">htmldiff_tokens</a></tt><tt class="py-op">(</tt><tt class="py-name">old_html_tokens</tt><tt class="py-op">,</tt> <tt class="py-name">new_html_tokens</tt><tt class="py-op">)</tt> </tt>
317 <a name="L171"></a><tt class="py-lineno">171</tt>  <tt class="py-line">    <tt class="py-name">result</tt> <tt class="py-op">=</tt> <tt class="py-string">''</tt><tt class="py-op">.</tt><tt id="link-46" class="py-name"><a title="lxml.cssselect.XPathExpr.join" class="py-name" href="#" onclick="return doclink('link-46', 'join', 'link-14');">join</a></tt><tt class="py-op">(</tt><tt class="py-name">result</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt id="link-47" class="py-name"><a title="lxml.doctestcompare.strip" class="py-name" href="#" onclick="return doclink('link-47', 'strip', 'link-15');">strip</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
318 <a name="L172"></a><tt class="py-lineno">172</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt id="link-48" class="py-name" targets="Function lxml.html.diff.fixup_ins_del_tags()=lxml.html.diff-module.html#fixup_ins_del_tags"><a title="lxml.html.diff.fixup_ins_del_tags" class="py-name" href="#" onclick="return doclink('link-48', 'fixup_ins_del_tags', 'link-48');">fixup_ins_del_tags</a></tt><tt class="py-op">(</tt><tt class="py-name">result</tt><tt class="py-op">)</tt> </tt>
319 </div><a name="L173"></a><tt class="py-lineno">173</tt>  <tt class="py-line"> </tt>
320 <a name="htmldiff_tokens"></a><div id="htmldiff_tokens-def"><a name="L174"></a><tt class="py-lineno">174</tt> <a class="py-toggle" href="#" id="htmldiff_tokens-toggle" onclick="return toggle('htmldiff_tokens');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#htmldiff_tokens">htmldiff_tokens</a><tt class="py-op">(</tt><tt class="py-param">html1_tokens</tt><tt class="py-op">,</tt> <tt class="py-param">html2_tokens</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
321 </div><div id="htmldiff_tokens-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="htmldiff_tokens-expanded"><a name="L175"></a><tt class="py-lineno">175</tt>  <tt class="py-line">    <tt class="py-docstring">""" Does a diff on the tokens themselves, returning a list of text</tt> </tt>
322 <a name="L176"></a><tt class="py-lineno">176</tt>  <tt class="py-line"><tt class="py-docstring">    chunks (not tokens).</tt> </tt>
323 <a name="L177"></a><tt class="py-lineno">177</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
324 <a name="L178"></a><tt class="py-lineno">178</tt>  <tt class="py-line">    <tt class="py-comment"># There are several passes as we do the differences.  The tokens</tt> </tt>
325 <a name="L179"></a><tt class="py-lineno">179</tt>  <tt class="py-line">    <tt class="py-comment"># isolate the portion of the content we care to diff; difflib does</tt> </tt>
326 <a name="L180"></a><tt class="py-lineno">180</tt>  <tt class="py-line">    <tt class="py-comment"># all the actual hard work at that point.  </tt> </tt>
327 <a name="L181"></a><tt class="py-lineno">181</tt>  <tt class="py-line">    <tt class="py-comment">#</tt> </tt>
328 <a name="L182"></a><tt class="py-lineno">182</tt>  <tt class="py-line">    <tt class="py-comment"># Then we must create a valid document from pieces of both the old</tt> </tt>
329 <a name="L183"></a><tt class="py-lineno">183</tt>  <tt class="py-line">    <tt class="py-comment"># document and the new document.  We generally prefer to take</tt> </tt>
330 <a name="L184"></a><tt class="py-lineno">184</tt>  <tt class="py-line">    <tt class="py-comment"># markup from the new document, and only do a best effort attempt</tt> </tt>
331 <a name="L185"></a><tt class="py-lineno">185</tt>  <tt class="py-line">    <tt class="py-comment"># to keep markup from the old document; anything that we can't</tt> </tt>
332 <a name="L186"></a><tt class="py-lineno">186</tt>  <tt class="py-line">    <tt class="py-comment"># resolve we throw away.  Also we try to put the deletes as close</tt> </tt>
333 <a name="L187"></a><tt class="py-lineno">187</tt>  <tt class="py-line">    <tt class="py-comment"># to the location where we think they would have been -- because</tt> </tt>
334 <a name="L188"></a><tt class="py-lineno">188</tt>  <tt class="py-line">    <tt class="py-comment"># we are only keeping the markup from the new document, it can be</tt> </tt>
335 <a name="L189"></a><tt class="py-lineno">189</tt>  <tt class="py-line">    <tt class="py-comment"># fuzzy where in the new document the old text would have gone.</tt> </tt>
336 <a name="L190"></a><tt class="py-lineno">190</tt>  <tt class="py-line">    <tt class="py-comment"># Again we just do a best effort attempt.</tt> </tt>
337 <a name="L191"></a><tt class="py-lineno">191</tt>  <tt class="py-line">    <tt class="py-name">s</tt> <tt class="py-op">=</tt> <tt id="link-49" class="py-name"><a title="lxml.html.diff.InsensitiveSequenceMatcher" class="py-name" href="#" onclick="return doclink('link-49', 'InsensitiveSequenceMatcher', 'link-17');">InsensitiveSequenceMatcher</a></tt><tt class="py-op">(</tt><tt class="py-name">a</tt><tt class="py-op">=</tt><tt class="py-name">html1_tokens</tt><tt class="py-op">,</tt> <tt class="py-name">b</tt><tt class="py-op">=</tt><tt class="py-name">html2_tokens</tt><tt class="py-op">)</tt> </tt>
338 <a name="L192"></a><tt class="py-lineno">192</tt>  <tt class="py-line">    <tt class="py-name">commands</tt> <tt class="py-op">=</tt> <tt class="py-name">s</tt><tt class="py-op">.</tt><tt class="py-name">get_opcodes</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
339 <a name="L193"></a><tt class="py-lineno">193</tt>  <tt class="py-line">    <tt class="py-name">result</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
340 <a name="L194"></a><tt class="py-lineno">194</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt class="py-name">command</tt><tt class="py-op">,</tt> <tt class="py-name">i1</tt><tt class="py-op">,</tt> <tt class="py-name">i2</tt><tt class="py-op">,</tt> <tt class="py-name">j1</tt><tt class="py-op">,</tt> <tt class="py-name">j2</tt> <tt class="py-keyword">in</tt> <tt class="py-name">commands</tt><tt class="py-op">:</tt> </tt>
341 <a name="L195"></a><tt class="py-lineno">195</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">command</tt> <tt class="py-op">==</tt> <tt class="py-string">'equal'</tt><tt class="py-op">:</tt> </tt>
342 <a name="L196"></a><tt class="py-lineno">196</tt>  <tt class="py-line">            <tt class="py-name">result</tt><tt class="py-op">.</tt><tt id="link-50" class="py-name" targets="Method lxml.etree._AppendOnlyElementProxy.extend()=lxml.etree._AppendOnlyElementProxy-class.html#extend,Method lxml.etree._Element.extend()=lxml.etree._Element-class.html#extend,Method lxml.etree._OpaqueDocumentWrapper.extend()=lxml.etree._OpaqueDocumentWrapper-class.html#extend"><a title="lxml.etree._AppendOnlyElementProxy.extend
343 lxml.etree._Element.extend
344 lxml.etree._OpaqueDocumentWrapper.extend" class="py-name" href="#" onclick="return doclink('link-50', 'extend', 'link-50');">extend</a></tt><tt class="py-op">(</tt><tt id="link-51" class="py-name" targets="Function lxml.html.diff.expand_tokens()=lxml.html.diff-module.html#expand_tokens"><a title="lxml.html.diff.expand_tokens" class="py-name" href="#" onclick="return doclink('link-51', 'expand_tokens', 'link-51');">expand_tokens</a></tt><tt class="py-op">(</tt><tt class="py-name">html2_tokens</tt><tt class="py-op">[</tt><tt class="py-name">j1</tt><tt class="py-op">:</tt><tt class="py-name">j2</tt><tt class="py-op">]</tt><tt class="py-op">,</tt> <tt class="py-name">equal</tt><tt class="py-op">=</tt><tt class="py-name">True</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
345 <a name="L197"></a><tt class="py-lineno">197</tt>  <tt class="py-line">            <tt class="py-keyword">continue</tt> </tt>
346 <a name="L198"></a><tt class="py-lineno">198</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">command</tt> <tt class="py-op">==</tt> <tt class="py-string">'insert'</tt> <tt class="py-keyword">or</tt> <tt class="py-name">command</tt> <tt class="py-op">==</tt> <tt class="py-string">'replace'</tt><tt class="py-op">:</tt> </tt>
347 <a name="L199"></a><tt class="py-lineno">199</tt>  <tt class="py-line">            <tt class="py-name">ins_tokens</tt> <tt class="py-op">=</tt> <tt id="link-52" class="py-name"><a title="lxml.html.diff.expand_tokens" class="py-name" href="#" onclick="return doclink('link-52', 'expand_tokens', 'link-51');">expand_tokens</a></tt><tt class="py-op">(</tt><tt class="py-name">html2_tokens</tt><tt class="py-op">[</tt><tt class="py-name">j1</tt><tt class="py-op">:</tt><tt class="py-name">j2</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
348 <a name="L200"></a><tt class="py-lineno">200</tt>  <tt class="py-line">            <tt id="link-53" class="py-name" targets="Function lxml.html.diff.merge_insert()=lxml.html.diff-module.html#merge_insert"><a title="lxml.html.diff.merge_insert" class="py-name" href="#" onclick="return doclink('link-53', 'merge_insert', 'link-53');">merge_insert</a></tt><tt class="py-op">(</tt><tt class="py-name">ins_tokens</tt><tt class="py-op">,</tt> <tt class="py-name">result</tt><tt class="py-op">)</tt> </tt>
349 <a name="L201"></a><tt class="py-lineno">201</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">command</tt> <tt class="py-op">==</tt> <tt class="py-string">'delete'</tt> <tt class="py-keyword">or</tt> <tt class="py-name">command</tt> <tt class="py-op">==</tt> <tt class="py-string">'replace'</tt><tt class="py-op">:</tt> </tt>
350 <a name="L202"></a><tt class="py-lineno">202</tt>  <tt class="py-line">            <tt class="py-name">del_tokens</tt> <tt class="py-op">=</tt> <tt id="link-54" class="py-name"><a title="lxml.html.diff.expand_tokens" class="py-name" href="#" onclick="return doclink('link-54', 'expand_tokens', 'link-51');">expand_tokens</a></tt><tt class="py-op">(</tt><tt class="py-name">html1_tokens</tt><tt class="py-op">[</tt><tt class="py-name">i1</tt><tt class="py-op">:</tt><tt class="py-name">i2</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
351 <a name="L203"></a><tt class="py-lineno">203</tt>  <tt class="py-line">            <tt id="link-55" class="py-name" targets="Function lxml.html.diff.merge_delete()=lxml.html.diff-module.html#merge_delete"><a title="lxml.html.diff.merge_delete" class="py-name" href="#" onclick="return doclink('link-55', 'merge_delete', 'link-55');">merge_delete</a></tt><tt class="py-op">(</tt><tt class="py-name">del_tokens</tt><tt class="py-op">,</tt> <tt class="py-name">result</tt><tt class="py-op">)</tt> </tt>
352 <a name="L204"></a><tt class="py-lineno">204</tt>  <tt class="py-line">    <tt class="py-comment"># If deletes were inserted directly as &lt;del&gt; then we'd have an</tt> </tt>
353 <a name="L205"></a><tt class="py-lineno">205</tt>  <tt class="py-line">    <tt class="py-comment"># invalid document at this point.  Instead we put in special</tt> </tt>
354 <a name="L206"></a><tt class="py-lineno">206</tt>  <tt class="py-line">    <tt class="py-comment"># markers, and when the complete diffed document has been created</tt> </tt>
355 <a name="L207"></a><tt class="py-lineno">207</tt>  <tt class="py-line">    <tt class="py-comment"># we try to move the deletes around and resolve any problems.</tt> </tt>
356 <a name="L208"></a><tt class="py-lineno">208</tt>  <tt class="py-line">    <tt class="py-name">result</tt> <tt class="py-op">=</tt> <tt id="link-56" class="py-name" targets="Function lxml.html.diff.cleanup_delete()=lxml.html.diff-module.html#cleanup_delete"><a title="lxml.html.diff.cleanup_delete" class="py-name" href="#" onclick="return doclink('link-56', 'cleanup_delete', 'link-56');">cleanup_delete</a></tt><tt class="py-op">(</tt><tt class="py-name">result</tt><tt class="py-op">)</tt> </tt>
357 <a name="L209"></a><tt class="py-lineno">209</tt>  <tt class="py-line"> </tt>
358 <a name="L210"></a><tt class="py-lineno">210</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">result</tt> </tt>
359 </div><a name="L211"></a><tt class="py-lineno">211</tt>  <tt class="py-line"> </tt>
360 <a name="expand_tokens"></a><div id="expand_tokens-def"><a name="L212"></a><tt class="py-lineno">212</tt> <a class="py-toggle" href="#" id="expand_tokens-toggle" onclick="return toggle('expand_tokens');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#expand_tokens">expand_tokens</a><tt class="py-op">(</tt><tt class="py-param">tokens</tt><tt class="py-op">,</tt> <tt class="py-param">equal</tt><tt class="py-op">=</tt><tt class="py-name">False</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
361 </div><div id="expand_tokens-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="expand_tokens-expanded"><a name="L213"></a><tt class="py-lineno">213</tt>  <tt class="py-line">    <tt class="py-docstring">"""Given a list of tokens, return a generator of the chunks of</tt> </tt>
362 <a name="L214"></a><tt class="py-lineno">214</tt>  <tt class="py-line"><tt class="py-docstring">    text for the data in the tokens.</tt> </tt>
363 <a name="L215"></a><tt class="py-lineno">215</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
364 <a name="L216"></a><tt class="py-lineno">216</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt id="link-57" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-57', 'token', 'link-22');">token</a></tt> <tt class="py-keyword">in</tt> <tt class="py-name">tokens</tt><tt class="py-op">:</tt> </tt>
365 <a name="L217"></a><tt class="py-lineno">217</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt class="py-name">pre</tt> <tt class="py-keyword">in</tt> <tt id="link-58" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-58', 'token', 'link-22');">token</a></tt><tt class="py-op">.</tt><tt class="py-name">pre_tags</tt><tt class="py-op">:</tt> </tt>
366 <a name="L218"></a><tt class="py-lineno">218</tt>  <tt class="py-line">            <tt class="py-keyword">yield</tt> <tt class="py-name">pre</tt> </tt>
367 <a name="L219"></a><tt class="py-lineno">219</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">equal</tt> <tt class="py-keyword">or</tt> <tt class="py-keyword">not</tt> <tt id="link-59" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-59', 'token', 'link-22');">token</a></tt><tt class="py-op">.</tt><tt id="link-60" class="py-name" targets="Variable lxml.html.diff.href_token.hide_when_equal=lxml.html.diff.href_token-class.html#hide_when_equal,Variable lxml.html.diff.token.hide_when_equal=lxml.html.diff.token-class.html#hide_when_equal"><a title="lxml.html.diff.href_token.hide_when_equal
368 lxml.html.diff.token.hide_when_equal" class="py-name" href="#" onclick="return doclink('link-60', 'hide_when_equal', 'link-60');">hide_when_equal</a></tt><tt class="py-op">:</tt> </tt>
369 <a name="L220"></a><tt class="py-lineno">220</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt id="link-61" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-61', 'token', 'link-22');">token</a></tt><tt class="py-op">.</tt><tt class="py-name">trailing_whitespace</tt><tt class="py-op">:</tt> </tt>
370 <a name="L221"></a><tt class="py-lineno">221</tt>  <tt class="py-line">                <tt class="py-keyword">yield</tt> <tt id="link-62" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-62', 'token', 'link-22');">token</a></tt><tt class="py-op">.</tt><tt id="link-63" class="py-name"><a title="lxml.html
371 lxml.html.diff.href_token.html
372 lxml.html.diff.tag_token.html
373 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-63', 'html', 'link-3');">html</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt class="py-string">' '</tt> </tt>
374 <a name="L222"></a><tt class="py-lineno">222</tt>  <tt class="py-line">            <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
375 <a name="L223"></a><tt class="py-lineno">223</tt>  <tt class="py-line">                <tt class="py-keyword">yield</tt> <tt id="link-64" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-64', 'token', 'link-22');">token</a></tt><tt class="py-op">.</tt><tt id="link-65" class="py-name"><a title="lxml.html
376 lxml.html.diff.href_token.html
377 lxml.html.diff.tag_token.html
378 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-65', 'html', 'link-3');">html</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
379 <a name="L224"></a><tt class="py-lineno">224</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt class="py-name">post</tt> <tt class="py-keyword">in</tt> <tt id="link-66" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-66', 'token', 'link-22');">token</a></tt><tt class="py-op">.</tt><tt class="py-name">post_tags</tt><tt class="py-op">:</tt> </tt>
380 <a name="L225"></a><tt class="py-lineno">225</tt>  <tt class="py-line">            <tt class="py-keyword">yield</tt> <tt class="py-name">post</tt> </tt>
381 </div><a name="L226"></a><tt class="py-lineno">226</tt>  <tt class="py-line"> </tt>
382 <a name="merge_insert"></a><div id="merge_insert-def"><a name="L227"></a><tt class="py-lineno">227</tt> <a class="py-toggle" href="#" id="merge_insert-toggle" onclick="return toggle('merge_insert');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#merge_insert">merge_insert</a><tt class="py-op">(</tt><tt class="py-param">ins_chunks</tt><tt class="py-op">,</tt> <tt class="py-param">doc</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
383 </div><div id="merge_insert-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="merge_insert-expanded"><a name="L228"></a><tt class="py-lineno">228</tt>  <tt class="py-line">    <tt class="py-docstring">""" doc is the already-handled document (as a list of text chunks);</tt> </tt>
384 <a name="L229"></a><tt class="py-lineno">229</tt>  <tt class="py-line"><tt class="py-docstring">    here we add &lt;ins&gt;ins_chunks&lt;/ins&gt; to the end of that.  """</tt> </tt>
385 <a name="L230"></a><tt class="py-lineno">230</tt>  <tt class="py-line">    <tt class="py-comment"># Though we don't throw away unbalanced_start or unbalanced_end</tt> </tt>
386 <a name="L231"></a><tt class="py-lineno">231</tt>  <tt class="py-line">    <tt class="py-comment"># (we assume there is accompanying markup later or earlier in the</tt> </tt>
387 <a name="L232"></a><tt class="py-lineno">232</tt>  <tt class="py-line">    <tt class="py-comment"># document), we only put &lt;ins&gt; around the balanced portion.</tt> </tt>
388 <a name="L233"></a><tt class="py-lineno">233</tt>  <tt class="py-line">    <tt class="py-name">unbalanced_start</tt><tt class="py-op">,</tt> <tt class="py-name">balanced</tt><tt class="py-op">,</tt> <tt class="py-name">unbalanced_end</tt> <tt class="py-op">=</tt> <tt id="link-67" class="py-name" targets="Function lxml.html.diff.split_unbalanced()=lxml.html.diff-module.html#split_unbalanced"><a title="lxml.html.diff.split_unbalanced" class="py-name" href="#" onclick="return doclink('link-67', 'split_unbalanced', 'link-67');">split_unbalanced</a></tt><tt class="py-op">(</tt><tt class="py-name">ins_chunks</tt><tt class="py-op">)</tt> </tt>
389 <a name="L234"></a><tt class="py-lineno">234</tt>  <tt class="py-line">    <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt id="link-68" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.extend
390 lxml.etree._Element.extend
391 lxml.etree._OpaqueDocumentWrapper.extend" class="py-name" href="#" onclick="return doclink('link-68', 'extend', 'link-50');">extend</a></tt><tt class="py-op">(</tt><tt class="py-name">unbalanced_start</tt><tt class="py-op">)</tt> </tt>
392 <a name="L235"></a><tt class="py-lineno">235</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">doc</tt> <tt class="py-keyword">and</tt> <tt class="py-keyword">not</tt> <tt class="py-name">doc</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt class="py-name">endswith</tt><tt class="py-op">(</tt><tt class="py-string">' '</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
393 <a name="L236"></a><tt class="py-lineno">236</tt>  <tt class="py-line">        <tt class="py-comment"># Fix up the case where the word before the insert didn't end with </tt> </tt>
394 <a name="L237"></a><tt class="py-lineno">237</tt>  <tt class="py-line">        <tt class="py-comment"># a space</tt> </tt>
395 <a name="L238"></a><tt class="py-lineno">238</tt>  <tt class="py-line">        <tt class="py-name">doc</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> <tt class="py-op">+=</tt> <tt class="py-string">' '</tt> </tt>
396 <a name="L239"></a><tt class="py-lineno">239</tt>  <tt class="py-line">    <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt id="link-69" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.append
397 lxml.etree._Element.append
398 lxml.etree._OpaqueDocumentWrapper.append
399 lxml.etree.__ContentOnlyElement.append" class="py-name" href="#" onclick="return doclink('link-69', 'append', 'link-20');">append</a></tt><tt class="py-op">(</tt><tt class="py-string">'&lt;ins&gt;'</tt><tt class="py-op">)</tt> </tt>
400 <a name="L240"></a><tt class="py-lineno">240</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">balanced</tt> <tt class="py-keyword">and</tt> <tt class="py-name">balanced</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt class="py-name">endswith</tt><tt class="py-op">(</tt><tt class="py-string">' '</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
401 <a name="L241"></a><tt class="py-lineno">241</tt>  <tt class="py-line">        <tt class="py-comment"># We move space outside of &lt;/ins&gt;</tt> </tt>
402 <a name="L242"></a><tt class="py-lineno">242</tt>  <tt class="py-line">        <tt class="py-name">balanced</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-name">balanced</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">[</tt><tt class="py-op">:</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> </tt>
403 <a name="L243"></a><tt class="py-lineno">243</tt>  <tt class="py-line">    <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt id="link-70" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.extend
404 lxml.etree._Element.extend
405 lxml.etree._OpaqueDocumentWrapper.extend" class="py-name" href="#" onclick="return doclink('link-70', 'extend', 'link-50');">extend</a></tt><tt class="py-op">(</tt><tt class="py-name">balanced</tt><tt class="py-op">)</tt> </tt>
406 <a name="L244"></a><tt class="py-lineno">244</tt>  <tt class="py-line">    <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt id="link-71" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.append
407 lxml.etree._Element.append
408 lxml.etree._OpaqueDocumentWrapper.append
409 lxml.etree.__ContentOnlyElement.append" class="py-name" href="#" onclick="return doclink('link-71', 'append', 'link-20');">append</a></tt><tt class="py-op">(</tt><tt class="py-string">'&lt;/ins&gt; '</tt><tt class="py-op">)</tt> </tt>
410 <a name="L245"></a><tt class="py-lineno">245</tt>  <tt class="py-line">    <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt id="link-72" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.extend
411 lxml.etree._Element.extend
412 lxml.etree._OpaqueDocumentWrapper.extend" class="py-name" href="#" onclick="return doclink('link-72', 'extend', 'link-50');">extend</a></tt><tt class="py-op">(</tt><tt class="py-name">unbalanced_end</tt><tt class="py-op">)</tt> </tt>
413 </div><a name="L246"></a><tt class="py-lineno">246</tt>  <tt class="py-line"> </tt>
414 <a name="L247"></a><tt class="py-lineno">247</tt>  <tt class="py-line"><tt class="py-comment"># These are sentinals to represent the start and end of a &lt;del&gt;</tt> </tt>
415 <a name="L248"></a><tt class="py-lineno">248</tt>  <tt class="py-line"><tt class="py-comment"># segment, until we do the cleanup phase to turn them into proper</tt> </tt>
416 <a name="L249"></a><tt class="py-lineno">249</tt>  <tt class="py-line"><tt class="py-comment"># markup:</tt> </tt>
417 <a name="DEL_START"></a><div id="DEL_START-def"><a name="L250"></a><tt class="py-lineno">250</tt> <a class="py-toggle" href="#" id="DEL_START-toggle" onclick="return toggle('DEL_START');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="lxml.html.diff.DEL_START-class.html">DEL_START</a><tt class="py-op">:</tt> </tt>
418 </div><div id="DEL_START-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="DEL_START-expanded"><a name="L251"></a><tt class="py-lineno">251</tt>  <tt class="py-line">    <tt class="py-keyword">pass</tt> </tt>
419 </div><a name="DEL_END"></a><div id="DEL_END-def"><a name="L252"></a><tt class="py-lineno">252</tt> <a class="py-toggle" href="#" id="DEL_END-toggle" onclick="return toggle('DEL_END');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="lxml.html.diff.DEL_END-class.html">DEL_END</a><tt class="py-op">:</tt> </tt>
420 </div><div id="DEL_END-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="DEL_END-expanded"><a name="L253"></a><tt class="py-lineno">253</tt>  <tt class="py-line">    <tt class="py-keyword">pass</tt> </tt>
421 </div><a name="L254"></a><tt class="py-lineno">254</tt>  <tt class="py-line"> </tt>
422 <a name="NoDeletes"></a><div id="NoDeletes-def"><a name="L255"></a><tt class="py-lineno">255</tt> <a class="py-toggle" href="#" id="NoDeletes-toggle" onclick="return toggle('NoDeletes');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="lxml.html.diff.NoDeletes-class.html">NoDeletes</a><tt class="py-op">(</tt><tt class="py-base-class">Exception</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
423 </div><div id="NoDeletes-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="NoDeletes-expanded"><a name="L256"></a><tt class="py-lineno">256</tt>  <tt class="py-line">    <tt class="py-docstring">""" Raised when the document no longer contains any pending deletes</tt> </tt>
424 <a name="L257"></a><tt class="py-lineno">257</tt>  <tt class="py-line"><tt class="py-docstring">    (DEL_START/DEL_END) """</tt> </tt>
425 </div><a name="L258"></a><tt class="py-lineno">258</tt>  <tt class="py-line"> </tt>
426 <a name="merge_delete"></a><div id="merge_delete-def"><a name="L259"></a><tt class="py-lineno">259</tt> <a class="py-toggle" href="#" id="merge_delete-toggle" onclick="return toggle('merge_delete');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#merge_delete">merge_delete</a><tt class="py-op">(</tt><tt class="py-param">del_chunks</tt><tt class="py-op">,</tt> <tt class="py-param">doc</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
427 </div><div id="merge_delete-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="merge_delete-expanded"><a name="L260"></a><tt class="py-lineno">260</tt>  <tt class="py-line">    <tt class="py-docstring">""" Adds the text chunks in del_chunks to the document doc (another</tt> </tt>
428 <a name="L261"></a><tt class="py-lineno">261</tt>  <tt class="py-line"><tt class="py-docstring">    list of text chunks) with marker to show it is a delete.</tt> </tt>
429 <a name="L262"></a><tt class="py-lineno">262</tt>  <tt class="py-line"><tt class="py-docstring">    cleanup_delete later resolves these markers into &lt;del&gt; tags."""</tt> </tt>
430 <a name="L263"></a><tt class="py-lineno">263</tt>  <tt class="py-line">    <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt id="link-73" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.append
431 lxml.etree._Element.append
432 lxml.etree._OpaqueDocumentWrapper.append
433 lxml.etree.__ContentOnlyElement.append" class="py-name" href="#" onclick="return doclink('link-73', 'append', 'link-20');">append</a></tt><tt class="py-op">(</tt><tt id="link-74" class="py-name" targets="Class lxml.html.diff.DEL_START=lxml.html.diff.DEL_START-class.html"><a title="lxml.html.diff.DEL_START" class="py-name" href="#" onclick="return doclink('link-74', 'DEL_START', 'link-74');">DEL_START</a></tt><tt class="py-op">)</tt> </tt>
434 <a name="L264"></a><tt class="py-lineno">264</tt>  <tt class="py-line">    <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt id="link-75" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.extend
435 lxml.etree._Element.extend
436 lxml.etree._OpaqueDocumentWrapper.extend" class="py-name" href="#" onclick="return doclink('link-75', 'extend', 'link-50');">extend</a></tt><tt class="py-op">(</tt><tt class="py-name">del_chunks</tt><tt class="py-op">)</tt> </tt>
437 <a name="L265"></a><tt class="py-lineno">265</tt>  <tt class="py-line">    <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt id="link-76" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.append
438 lxml.etree._Element.append
439 lxml.etree._OpaqueDocumentWrapper.append
440 lxml.etree.__ContentOnlyElement.append" class="py-name" href="#" onclick="return doclink('link-76', 'append', 'link-20');">append</a></tt><tt class="py-op">(</tt><tt id="link-77" class="py-name" targets="Class lxml.html.diff.DEL_END=lxml.html.diff.DEL_END-class.html"><a title="lxml.html.diff.DEL_END" class="py-name" href="#" onclick="return doclink('link-77', 'DEL_END', 'link-77');">DEL_END</a></tt><tt class="py-op">)</tt> </tt>
441 </div><a name="L266"></a><tt class="py-lineno">266</tt>  <tt class="py-line"> </tt>
442 <a name="cleanup_delete"></a><div id="cleanup_delete-def"><a name="L267"></a><tt class="py-lineno">267</tt> <a class="py-toggle" href="#" id="cleanup_delete-toggle" onclick="return toggle('cleanup_delete');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#cleanup_delete">cleanup_delete</a><tt class="py-op">(</tt><tt class="py-param">chunks</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
443 </div><div id="cleanup_delete-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="cleanup_delete-expanded"><a name="L268"></a><tt class="py-lineno">268</tt>  <tt class="py-line">    <tt class="py-docstring">""" Cleans up any DEL_START/DEL_END markers in the document, replacing</tt> </tt>
444 <a name="L269"></a><tt class="py-lineno">269</tt>  <tt class="py-line"><tt class="py-docstring">    them with &lt;del&gt;&lt;/del&gt;.  To do this while keeping the document</tt> </tt>
445 <a name="L270"></a><tt class="py-lineno">270</tt>  <tt class="py-line"><tt class="py-docstring">    valid, it may need to drop some tags (either start or end tags).</tt> </tt>
446 <a name="L271"></a><tt class="py-lineno">271</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
447 <a name="L272"></a><tt class="py-lineno">272</tt>  <tt class="py-line"><tt class="py-docstring">    It may also move the del into adjacent tags to try to move it to a</tt> </tt>
448 <a name="L273"></a><tt class="py-lineno">273</tt>  <tt class="py-line"><tt class="py-docstring">    similar location where it was originally located (e.g., moving a</tt> </tt>
449 <a name="L274"></a><tt class="py-lineno">274</tt>  <tt class="py-line"><tt class="py-docstring">    delete into preceding &lt;div&gt; tag, if the del looks like (DEL_START,</tt> </tt>
450 <a name="L275"></a><tt class="py-lineno">275</tt>  <tt class="py-line"><tt class="py-docstring">    'Text&lt;/div&gt;', DEL_END)"""</tt> </tt>
451 <a name="L276"></a><tt class="py-lineno">276</tt>  <tt class="py-line">    <tt class="py-keyword">while</tt> <tt class="py-number">1</tt><tt class="py-op">:</tt> </tt>
452 <a name="L277"></a><tt class="py-lineno">277</tt>  <tt class="py-line">        <tt class="py-comment"># Find a pending DEL_START/DEL_END, splitting the document</tt> </tt>
453 <a name="L278"></a><tt class="py-lineno">278</tt>  <tt class="py-line">        <tt class="py-comment"># into stuff-preceding-DEL_START, stuff-inside, and</tt> </tt>
454 <a name="L279"></a><tt class="py-lineno">279</tt>  <tt class="py-line">        <tt class="py-comment"># stuff-following-DEL_END</tt> </tt>
455 <a name="L280"></a><tt class="py-lineno">280</tt>  <tt class="py-line">        <tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
456 <a name="L281"></a><tt class="py-lineno">281</tt>  <tt class="py-line">            <tt class="py-name">pre_delete</tt><tt class="py-op">,</tt> <tt class="py-name">delete</tt><tt class="py-op">,</tt> <tt class="py-name">post_delete</tt> <tt class="py-op">=</tt> <tt id="link-78" class="py-name" targets="Function lxml.html.diff.split_delete()=lxml.html.diff-module.html#split_delete"><a title="lxml.html.diff.split_delete" class="py-name" href="#" onclick="return doclink('link-78', 'split_delete', 'link-78');">split_delete</a></tt><tt class="py-op">(</tt><tt class="py-name">chunks</tt><tt class="py-op">)</tt> </tt>
457 <a name="L282"></a><tt class="py-lineno">282</tt>  <tt class="py-line">        <tt class="py-keyword">except</tt> <tt id="link-79" class="py-name" targets="Class lxml.html.diff.NoDeletes=lxml.html.diff.NoDeletes-class.html"><a title="lxml.html.diff.NoDeletes" class="py-name" href="#" onclick="return doclink('link-79', 'NoDeletes', 'link-79');">NoDeletes</a></tt><tt class="py-op">:</tt> </tt>
458 <a name="L283"></a><tt class="py-lineno">283</tt>  <tt class="py-line">            <tt class="py-comment"># Nothing found, we've cleaned up the entire doc</tt> </tt>
459 <a name="L284"></a><tt class="py-lineno">284</tt>  <tt class="py-line">            <tt class="py-keyword">break</tt> </tt>
460 <a name="L285"></a><tt class="py-lineno">285</tt>  <tt class="py-line">        <tt class="py-comment"># The stuff-inside-DEL_START/END may not be well balanced</tt> </tt>
461 <a name="L286"></a><tt class="py-lineno">286</tt>  <tt class="py-line">        <tt class="py-comment"># markup.  First we figure out what unbalanced portions there are:</tt> </tt>
462 <a name="L287"></a><tt class="py-lineno">287</tt>  <tt class="py-line">        <tt class="py-name">unbalanced_start</tt><tt class="py-op">,</tt> <tt class="py-name">balanced</tt><tt class="py-op">,</tt> <tt class="py-name">unbalanced_end</tt> <tt class="py-op">=</tt> <tt id="link-80" class="py-name"><a title="lxml.html.diff.split_unbalanced" class="py-name" href="#" onclick="return doclink('link-80', 'split_unbalanced', 'link-67');">split_unbalanced</a></tt><tt class="py-op">(</tt><tt class="py-name">delete</tt><tt class="py-op">)</tt> </tt>
463 <a name="L288"></a><tt class="py-lineno">288</tt>  <tt class="py-line">        <tt class="py-comment"># Then we move the span forward and/or backward based on these</tt> </tt>
464 <a name="L289"></a><tt class="py-lineno">289</tt>  <tt class="py-line">        <tt class="py-comment"># unbalanced portions:</tt> </tt>
465 <a name="L290"></a><tt class="py-lineno">290</tt>  <tt class="py-line">        <tt id="link-81" class="py-name" targets="Function lxml.html.diff.locate_unbalanced_start()=lxml.html.diff-module.html#locate_unbalanced_start"><a title="lxml.html.diff.locate_unbalanced_start" class="py-name" href="#" onclick="return doclink('link-81', 'locate_unbalanced_start', 'link-81');">locate_unbalanced_start</a></tt><tt class="py-op">(</tt><tt class="py-name">unbalanced_start</tt><tt class="py-op">,</tt> <tt class="py-name">pre_delete</tt><tt class="py-op">,</tt> <tt class="py-name">post_delete</tt><tt class="py-op">)</tt> </tt>
466 <a name="L291"></a><tt class="py-lineno">291</tt>  <tt class="py-line">        <tt id="link-82" class="py-name" targets="Function lxml.html.diff.locate_unbalanced_end()=lxml.html.diff-module.html#locate_unbalanced_end"><a title="lxml.html.diff.locate_unbalanced_end" class="py-name" href="#" onclick="return doclink('link-82', 'locate_unbalanced_end', 'link-82');">locate_unbalanced_end</a></tt><tt class="py-op">(</tt><tt class="py-name">unbalanced_end</tt><tt class="py-op">,</tt> <tt class="py-name">pre_delete</tt><tt class="py-op">,</tt> <tt class="py-name">post_delete</tt><tt class="py-op">)</tt> </tt>
467 <a name="L292"></a><tt class="py-lineno">292</tt>  <tt class="py-line">        <tt class="py-name">doc</tt> <tt class="py-op">=</tt> <tt class="py-name">pre_delete</tt> </tt>
468 <a name="L293"></a><tt class="py-lineno">293</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">doc</tt> <tt class="py-keyword">and</tt> <tt class="py-keyword">not</tt> <tt class="py-name">doc</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt class="py-name">endswith</tt><tt class="py-op">(</tt><tt class="py-string">' '</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
469 <a name="L294"></a><tt class="py-lineno">294</tt>  <tt class="py-line">            <tt class="py-comment"># Fix up case where the word before us didn't have a trailing space</tt> </tt>
470 <a name="L295"></a><tt class="py-lineno">295</tt>  <tt class="py-line">            <tt class="py-name">doc</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> <tt class="py-op">+=</tt> <tt class="py-string">' '</tt> </tt>
471 <a name="L296"></a><tt class="py-lineno">296</tt>  <tt class="py-line">        <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt id="link-83" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.append
472 lxml.etree._Element.append
473 lxml.etree._OpaqueDocumentWrapper.append
474 lxml.etree.__ContentOnlyElement.append" class="py-name" href="#" onclick="return doclink('link-83', 'append', 'link-20');">append</a></tt><tt class="py-op">(</tt><tt class="py-string">'&lt;del&gt;'</tt><tt class="py-op">)</tt> </tt>
475 <a name="L297"></a><tt class="py-lineno">297</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">balanced</tt> <tt class="py-keyword">and</tt> <tt class="py-name">balanced</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt class="py-name">endswith</tt><tt class="py-op">(</tt><tt class="py-string">' '</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
476 <a name="L298"></a><tt class="py-lineno">298</tt>  <tt class="py-line">            <tt class="py-comment"># We move space outside of &lt;/del&gt;</tt> </tt>
477 <a name="L299"></a><tt class="py-lineno">299</tt>  <tt class="py-line">            <tt class="py-name">balanced</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-name">balanced</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">[</tt><tt class="py-op">:</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> </tt>
478 <a name="L300"></a><tt class="py-lineno">300</tt>  <tt class="py-line">        <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt id="link-84" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.extend
479 lxml.etree._Element.extend
480 lxml.etree._OpaqueDocumentWrapper.extend" class="py-name" href="#" onclick="return doclink('link-84', 'extend', 'link-50');">extend</a></tt><tt class="py-op">(</tt><tt class="py-name">balanced</tt><tt class="py-op">)</tt> </tt>
481 <a name="L301"></a><tt class="py-lineno">301</tt>  <tt class="py-line">        <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt id="link-85" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.append
482 lxml.etree._Element.append
483 lxml.etree._OpaqueDocumentWrapper.append
484 lxml.etree.__ContentOnlyElement.append" class="py-name" href="#" onclick="return doclink('link-85', 'append', 'link-20');">append</a></tt><tt class="py-op">(</tt><tt class="py-string">'&lt;/del&gt; '</tt><tt class="py-op">)</tt> </tt>
485 <a name="L302"></a><tt class="py-lineno">302</tt>  <tt class="py-line">        <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt id="link-86" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.extend
486 lxml.etree._Element.extend
487 lxml.etree._OpaqueDocumentWrapper.extend" class="py-name" href="#" onclick="return doclink('link-86', 'extend', 'link-50');">extend</a></tt><tt class="py-op">(</tt><tt class="py-name">post_delete</tt><tt class="py-op">)</tt> </tt>
488 <a name="L303"></a><tt class="py-lineno">303</tt>  <tt class="py-line">        <tt class="py-name">chunks</tt> <tt class="py-op">=</tt> <tt class="py-name">doc</tt> </tt>
489 <a name="L304"></a><tt class="py-lineno">304</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">chunks</tt> </tt>
490 </div><a name="L305"></a><tt class="py-lineno">305</tt>  <tt class="py-line"> </tt>
491 <a name="split_unbalanced"></a><div id="split_unbalanced-def"><a name="L306"></a><tt class="py-lineno">306</tt> <a class="py-toggle" href="#" id="split_unbalanced-toggle" onclick="return toggle('split_unbalanced');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#split_unbalanced">split_unbalanced</a><tt class="py-op">(</tt><tt class="py-param">chunks</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
492 </div><div id="split_unbalanced-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="split_unbalanced-expanded"><a name="L307"></a><tt class="py-lineno">307</tt>  <tt class="py-line">    <tt class="py-docstring">"""Return (unbalanced_start, balanced, unbalanced_end), where each is</tt> </tt>
493 <a name="L308"></a><tt class="py-lineno">308</tt>  <tt class="py-line"><tt class="py-docstring">    a list of text and tag chunks.</tt> </tt>
494 <a name="L309"></a><tt class="py-lineno">309</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
495 <a name="L310"></a><tt class="py-lineno">310</tt>  <tt class="py-line"><tt class="py-docstring">    unbalanced_start is a list of all the tags that are opened, but</tt> </tt>
496 <a name="L311"></a><tt class="py-lineno">311</tt>  <tt class="py-line"><tt class="py-docstring">    not closed in this span.  Similarly, unbalanced_end is a list of</tt> </tt>
497 <a name="L312"></a><tt class="py-lineno">312</tt>  <tt class="py-line"><tt class="py-docstring">    tags that are closed but were not opened.  Extracting these might</tt> </tt>
498 <a name="L313"></a><tt class="py-lineno">313</tt>  <tt class="py-line"><tt class="py-docstring">    mean some reordering of the chunks."""</tt> </tt>
499 <a name="L314"></a><tt class="py-lineno">314</tt>  <tt class="py-line">    <tt id="link-87" class="py-name" targets="Method lxml.etree.TreeBuilder.start()=lxml.etree.TreeBuilder-class.html#start"><a title="lxml.etree.TreeBuilder.start" class="py-name" href="#" onclick="return doclink('link-87', 'start', 'link-87');">start</a></tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
500 <a name="L315"></a><tt class="py-lineno">315</tt>  <tt class="py-line">    <tt id="link-88" class="py-name" targets="Method lxml.etree.TreeBuilder.end()=lxml.etree.TreeBuilder-class.html#end"><a title="lxml.etree.TreeBuilder.end" class="py-name" href="#" onclick="return doclink('link-88', 'end', 'link-88');">end</a></tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
501 <a name="L316"></a><tt class="py-lineno">316</tt>  <tt class="py-line">    <tt class="py-name">tag_stack</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
502 <a name="L317"></a><tt class="py-lineno">317</tt>  <tt class="py-line">    <tt class="py-name">balanced</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
503 <a name="L318"></a><tt class="py-lineno">318</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt class="py-name">chunk</tt> <tt class="py-keyword">in</tt> <tt class="py-name">chunks</tt><tt class="py-op">:</tt> </tt>
504 <a name="L319"></a><tt class="py-lineno">319</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">chunk</tt><tt class="py-op">.</tt><tt class="py-name">startswith</tt><tt class="py-op">(</tt><tt class="py-string">'&lt;'</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
505 <a name="L320"></a><tt class="py-lineno">320</tt>  <tt class="py-line">            <tt class="py-name">balanced</tt><tt class="py-op">.</tt><tt id="link-89" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.append
506 lxml.etree._Element.append
507 lxml.etree._OpaqueDocumentWrapper.append
508 lxml.etree.__ContentOnlyElement.append" class="py-name" href="#" onclick="return doclink('link-89', 'append', 'link-20');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">chunk</tt><tt class="py-op">)</tt> </tt>
509 <a name="L321"></a><tt class="py-lineno">321</tt>  <tt class="py-line">            <tt class="py-keyword">continue</tt> </tt>
510 <a name="L322"></a><tt class="py-lineno">322</tt>  <tt class="py-line">        <tt class="py-name">endtag</tt> <tt class="py-op">=</tt> <tt class="py-name">chunk</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> <tt class="py-op">==</tt> <tt class="py-string">'/'</tt> </tt>
511 <a name="L323"></a><tt class="py-lineno">323</tt>  <tt class="py-line">        <tt id="link-90" class="py-name" targets="Variable lxml.etree._Entity.name=lxml.etree._Entity-class.html#name,Variable lxml.etree._ModifyContentOnlyEntityProxy.name=lxml.etree._ModifyContentOnlyEntityProxy-class.html#name,Variable lxml.etree._ReadOnlyEntityProxy.name=lxml.etree._ReadOnlyEntityProxy-class.html#name,Variable lxml.html.InputMixin.name=lxml.html.InputMixin-class.html#name,Variable lxml.objectify.PyType.name=lxml.objectify.PyType-class.html#name"><a title="lxml.etree._Entity.name
512 lxml.etree._ModifyContentOnlyEntityProxy.name
513 lxml.etree._ReadOnlyEntityProxy.name
514 lxml.html.InputMixin.name
515 lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-90', 'name', 'link-90');">name</a></tt> <tt class="py-op">=</tt> <tt class="py-name">chunk</tt><tt class="py-op">.</tt><tt class="py-name">split</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt id="link-91" class="py-name"><a title="lxml.doctestcompare.strip" class="py-name" href="#" onclick="return doclink('link-91', 'strip', 'link-15');">strip</a></tt><tt class="py-op">(</tt><tt class="py-string">'&lt;&gt;/'</tt><tt class="py-op">)</tt> </tt>
516 <a name="L324"></a><tt class="py-lineno">324</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt id="link-92" class="py-name"><a title="lxml.etree._Entity.name
517 lxml.etree._ModifyContentOnlyEntityProxy.name
518 lxml.etree._ReadOnlyEntityProxy.name
519 lxml.html.InputMixin.name
520 lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-92', 'name', 'link-90');">name</a></tt> <tt class="py-keyword">in</tt> <tt id="link-93" class="py-name" targets="Variable lxml.doctestcompare.LXMLOutputChecker.empty_tags=lxml.doctestcompare.LXMLOutputChecker-class.html#empty_tags,Variable lxml.html.defs.empty_tags=lxml.html.defs-module.html#empty_tags,Variable lxml.html.diff.empty_tags=lxml.html.diff-module.html#empty_tags"><a title="lxml.doctestcompare.LXMLOutputChecker.empty_tags
521 lxml.html.defs.empty_tags
522 lxml.html.diff.empty_tags" class="py-name" href="#" onclick="return doclink('link-93', 'empty_tags', 'link-93');">empty_tags</a></tt><tt class="py-op">:</tt> </tt>
523 <a name="L325"></a><tt class="py-lineno">325</tt>  <tt class="py-line">            <tt class="py-name">balanced</tt><tt class="py-op">.</tt><tt id="link-94" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.append
524 lxml.etree._Element.append
525 lxml.etree._OpaqueDocumentWrapper.append
526 lxml.etree.__ContentOnlyElement.append" class="py-name" href="#" onclick="return doclink('link-94', 'append', 'link-20');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">chunk</tt><tt class="py-op">)</tt> </tt>
527 <a name="L326"></a><tt class="py-lineno">326</tt>  <tt class="py-line">            <tt class="py-keyword">continue</tt> </tt>
528 <a name="L327"></a><tt class="py-lineno">327</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">endtag</tt><tt class="py-op">:</tt> </tt>
529 <a name="L328"></a><tt class="py-lineno">328</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">tag_stack</tt> <tt class="py-keyword">and</tt> <tt class="py-name">tag_stack</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt> <tt class="py-op">==</tt> <tt id="link-95" class="py-name"><a title="lxml.etree._Entity.name
530 lxml.etree._ModifyContentOnlyEntityProxy.name
531 lxml.etree._ReadOnlyEntityProxy.name
532 lxml.html.InputMixin.name
533 lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-95', 'name', 'link-90');">name</a></tt><tt class="py-op">:</tt> </tt>
534 <a name="L329"></a><tt class="py-lineno">329</tt>  <tt class="py-line">                <tt class="py-name">balanced</tt><tt class="py-op">.</tt><tt id="link-96" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.append
535 lxml.etree._Element.append
536 lxml.etree._OpaqueDocumentWrapper.append
537 lxml.etree.__ContentOnlyElement.append" class="py-name" href="#" onclick="return doclink('link-96', 'append', 'link-20');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">chunk</tt><tt class="py-op">)</tt> </tt>
538 <a name="L330"></a><tt class="py-lineno">330</tt>  <tt class="py-line">                <tt id="link-97" class="py-name"><a title="lxml.etree._Entity.name
539 lxml.etree._ModifyContentOnlyEntityProxy.name
540 lxml.etree._ReadOnlyEntityProxy.name
541 lxml.html.InputMixin.name
542 lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-97', 'name', 'link-90');">name</a></tt><tt class="py-op">,</tt> <tt class="py-name">pos</tt><tt class="py-op">,</tt> <tt id="link-98" class="py-name" targets="Variable lxml.etree._Comment.tag=lxml.etree._Comment-class.html#tag,Variable lxml.etree._Element.tag=lxml.etree._Element-class.html#tag,Variable lxml.etree._Entity.tag=lxml.etree._Entity-class.html#tag,Variable lxml.etree._ProcessingInstruction.tag=lxml.etree._ProcessingInstruction-class.html#tag,Variable lxml.etree._ReadOnlyProxy.tag=lxml.etree._ReadOnlyProxy-class.html#tag,Function lxml.tests.test_xpathevaluator.tag()=lxml.tests.test_xpathevaluator-module.html#tag,Variable xml.etree.ElementTree.Element.tag=xml.etree.ElementTree.Element-class.html#tag"><a title="lxml.etree._Comment.tag
543 lxml.etree._Element.tag
544 lxml.etree._Entity.tag
545 lxml.etree._ProcessingInstruction.tag
546 lxml.etree._ReadOnlyProxy.tag
547 lxml.tests.test_xpathevaluator.tag
548 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-98', 'tag', 'link-98');">tag</a></tt> <tt class="py-op">=</tt> <tt class="py-name">tag_stack</tt><tt class="py-op">.</tt><tt id="link-99" class="py-name" targets="Method lxml.etree._Attrib.pop()=lxml.etree._Attrib-class.html#pop"><a title="lxml.etree._Attrib.pop" class="py-name" href="#" onclick="return doclink('link-99', 'pop', 'link-99');">pop</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
549 <a name="L331"></a><tt class="py-lineno">331</tt>  <tt class="py-line">                <tt class="py-name">balanced</tt><tt class="py-op">[</tt><tt class="py-name">pos</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt id="link-100" class="py-name"><a title="lxml.etree._Comment.tag
550 lxml.etree._Element.tag
551 lxml.etree._Entity.tag
552 lxml.etree._ProcessingInstruction.tag
553 lxml.etree._ReadOnlyProxy.tag
554 lxml.tests.test_xpathevaluator.tag
555 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-100', 'tag', 'link-98');">tag</a></tt> </tt>
556 <a name="L332"></a><tt class="py-lineno">332</tt>  <tt class="py-line">            <tt class="py-keyword">elif</tt> <tt class="py-name">tag_stack</tt><tt class="py-op">:</tt> </tt>
557 <a name="L333"></a><tt class="py-lineno">333</tt>  <tt class="py-line">                <tt id="link-101" class="py-name"><a title="lxml.etree.TreeBuilder.start" class="py-name" href="#" onclick="return doclink('link-101', 'start', 'link-87');">start</a></tt><tt class="py-op">.</tt><tt id="link-102" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.extend
558 lxml.etree._Element.extend
559 lxml.etree._OpaqueDocumentWrapper.extend" class="py-name" href="#" onclick="return doclink('link-102', 'extend', 'link-50');">extend</a></tt><tt class="py-op">(</tt><tt class="py-op">[</tt><tt id="link-103" class="py-name"><a title="lxml.etree._Comment.tag
560 lxml.etree._Element.tag
561 lxml.etree._Entity.tag
562 lxml.etree._ProcessingInstruction.tag
563 lxml.etree._ReadOnlyProxy.tag
564 lxml.tests.test_xpathevaluator.tag
565 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-103', 'tag', 'link-98');">tag</a></tt> <tt class="py-keyword">for</tt> <tt id="link-104" class="py-name"><a title="lxml.etree._Entity.name
566 lxml.etree._ModifyContentOnlyEntityProxy.name
567 lxml.etree._ReadOnlyEntityProxy.name
568 lxml.html.InputMixin.name
569 lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-104', 'name', 'link-90');">name</a></tt><tt class="py-op">,</tt> <tt class="py-name">pos</tt><tt class="py-op">,</tt> <tt id="link-105" class="py-name"><a title="lxml.etree._Comment.tag
570 lxml.etree._Element.tag
571 lxml.etree._Entity.tag
572 lxml.etree._ProcessingInstruction.tag
573 lxml.etree._ReadOnlyProxy.tag
574 lxml.tests.test_xpathevaluator.tag
575 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-105', 'tag', 'link-98');">tag</a></tt> <tt class="py-keyword">in</tt> <tt class="py-name">tag_stack</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
576 <a name="L334"></a><tt class="py-lineno">334</tt>  <tt class="py-line">                <tt class="py-name">tag_stack</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
577 <a name="L335"></a><tt class="py-lineno">335</tt>  <tt class="py-line">                <tt id="link-106" class="py-name"><a title="lxml.etree.TreeBuilder.end" class="py-name" href="#" onclick="return doclink('link-106', 'end', 'link-88');">end</a></tt><tt class="py-op">.</tt><tt id="link-107" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.append
578 lxml.etree._Element.append
579 lxml.etree._OpaqueDocumentWrapper.append
580 lxml.etree.__ContentOnlyElement.append" class="py-name" href="#" onclick="return doclink('link-107', 'append', 'link-20');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">chunk</tt><tt class="py-op">)</tt> </tt>
581 <a name="L336"></a><tt class="py-lineno">336</tt>  <tt class="py-line">            <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
582 <a name="L337"></a><tt class="py-lineno">337</tt>  <tt class="py-line">                <tt id="link-108" class="py-name"><a title="lxml.etree.TreeBuilder.end" class="py-name" href="#" onclick="return doclink('link-108', 'end', 'link-88');">end</a></tt><tt class="py-op">.</tt><tt id="link-109" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.append
583 lxml.etree._Element.append
584 lxml.etree._OpaqueDocumentWrapper.append
585 lxml.etree.__ContentOnlyElement.append" class="py-name" href="#" onclick="return doclink('link-109', 'append', 'link-20');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">chunk</tt><tt class="py-op">)</tt> </tt>
586 <a name="L338"></a><tt class="py-lineno">338</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
587 <a name="L339"></a><tt class="py-lineno">339</tt>  <tt class="py-line">            <tt class="py-name">tag_stack</tt><tt class="py-op">.</tt><tt id="link-110" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.append
588 lxml.etree._Element.append
589 lxml.etree._OpaqueDocumentWrapper.append
590 lxml.etree.__ContentOnlyElement.append" class="py-name" href="#" onclick="return doclink('link-110', 'append', 'link-20');">append</a></tt><tt class="py-op">(</tt><tt class="py-op">(</tt><tt id="link-111" class="py-name"><a title="lxml.etree._Entity.name
591 lxml.etree._ModifyContentOnlyEntityProxy.name
592 lxml.etree._ReadOnlyEntityProxy.name
593 lxml.html.InputMixin.name
594 lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-111', 'name', 'link-90');">name</a></tt><tt class="py-op">,</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">balanced</tt><tt class="py-op">)</tt><tt class="py-op">,</tt> <tt class="py-name">chunk</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
595 <a name="L340"></a><tt class="py-lineno">340</tt>  <tt class="py-line">            <tt class="py-name">balanced</tt><tt class="py-op">.</tt><tt id="link-112" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.append
596 lxml.etree._Element.append
597 lxml.etree._OpaqueDocumentWrapper.append
598 lxml.etree.__ContentOnlyElement.append" class="py-name" href="#" onclick="return doclink('link-112', 'append', 'link-20');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">None</tt><tt class="py-op">)</tt> </tt>
599 <a name="L341"></a><tt class="py-lineno">341</tt>  <tt class="py-line">    <tt id="link-113" class="py-name"><a title="lxml.etree.TreeBuilder.start" class="py-name" href="#" onclick="return doclink('link-113', 'start', 'link-87');">start</a></tt><tt class="py-op">.</tt><tt id="link-114" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.extend
600 lxml.etree._Element.extend
601 lxml.etree._OpaqueDocumentWrapper.extend" class="py-name" href="#" onclick="return doclink('link-114', 'extend', 'link-50');">extend</a></tt><tt class="py-op">(</tt> </tt>
602 <a name="L342"></a><tt class="py-lineno">342</tt>  <tt class="py-line">        <tt class="py-op">[</tt><tt class="py-name">chunk</tt> <tt class="py-keyword">for</tt> <tt id="link-115" class="py-name"><a title="lxml.etree._Entity.name
603 lxml.etree._ModifyContentOnlyEntityProxy.name
604 lxml.etree._ReadOnlyEntityProxy.name
605 lxml.html.InputMixin.name
606 lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-115', 'name', 'link-90');">name</a></tt><tt class="py-op">,</tt> <tt class="py-name">pos</tt><tt class="py-op">,</tt> <tt class="py-name">chunk</tt> <tt class="py-keyword">in</tt> <tt class="py-name">tag_stack</tt><tt class="py-op">]</tt><tt class="py-op">)</tt> </tt>
607 <a name="L343"></a><tt class="py-lineno">343</tt>  <tt class="py-line">    <tt class="py-name">balanced</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-name">chunk</tt> <tt class="py-keyword">for</tt> <tt class="py-name">chunk</tt> <tt class="py-keyword">in</tt> <tt class="py-name">balanced</tt> <tt class="py-keyword">if</tt> <tt class="py-name">chunk</tt> <tt class="py-keyword">is</tt> <tt class="py-keyword">not</tt> <tt class="py-name">None</tt><tt class="py-op">]</tt> </tt>
608 <a name="L344"></a><tt class="py-lineno">344</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt id="link-116" class="py-name"><a title="lxml.etree.TreeBuilder.start" class="py-name" href="#" onclick="return doclink('link-116', 'start', 'link-87');">start</a></tt><tt class="py-op">,</tt> <tt class="py-name">balanced</tt><tt class="py-op">,</tt> <tt id="link-117" class="py-name"><a title="lxml.etree.TreeBuilder.end" class="py-name" href="#" onclick="return doclink('link-117', 'end', 'link-88');">end</a></tt> </tt>
609 </div><a name="L345"></a><tt class="py-lineno">345</tt>  <tt class="py-line"> </tt>
610 <a name="split_delete"></a><div id="split_delete-def"><a name="L346"></a><tt class="py-lineno">346</tt> <a class="py-toggle" href="#" id="split_delete-toggle" onclick="return toggle('split_delete');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#split_delete">split_delete</a><tt class="py-op">(</tt><tt class="py-param">chunks</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
611 </div><div id="split_delete-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="split_delete-expanded"><a name="L347"></a><tt class="py-lineno">347</tt>  <tt class="py-line">    <tt class="py-docstring">""" Returns (stuff_before_DEL_START, stuff_inside_DEL_START_END,</tt> </tt>
612 <a name="L348"></a><tt class="py-lineno">348</tt>  <tt class="py-line"><tt class="py-docstring">    stuff_after_DEL_END).  Returns the first case found (there may be</tt> </tt>
613 <a name="L349"></a><tt class="py-lineno">349</tt>  <tt class="py-line"><tt class="py-docstring">    more DEL_STARTs in stuff_after_DEL_END).  Raises NoDeletes if</tt> </tt>
614 <a name="L350"></a><tt class="py-lineno">350</tt>  <tt class="py-line"><tt class="py-docstring">    there's no DEL_START found. """</tt> </tt>
615 <a name="L351"></a><tt class="py-lineno">351</tt>  <tt class="py-line">    <tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
616 <a name="L352"></a><tt class="py-lineno">352</tt>  <tt class="py-line">        <tt class="py-name">pos</tt> <tt class="py-op">=</tt> <tt class="py-name">chunks</tt><tt class="py-op">.</tt><tt id="link-118" class="py-name" targets="Method lxml.etree._Element.index()=lxml.etree._Element-class.html#index"><a title="lxml.etree._Element.index" class="py-name" href="#" onclick="return doclink('link-118', 'index', 'link-118');">index</a></tt><tt class="py-op">(</tt><tt id="link-119" class="py-name"><a title="lxml.html.diff.DEL_START" class="py-name" href="#" onclick="return doclink('link-119', 'DEL_START', 'link-74');">DEL_START</a></tt><tt class="py-op">)</tt> </tt>
617 <a name="L353"></a><tt class="py-lineno">353</tt>  <tt class="py-line">    <tt class="py-keyword">except</tt> <tt class="py-name">ValueError</tt><tt class="py-op">:</tt> </tt>
618 <a name="L354"></a><tt class="py-lineno">354</tt>  <tt class="py-line">        <tt class="py-keyword">raise</tt> <tt id="link-120" class="py-name"><a title="lxml.html.diff.NoDeletes" class="py-name" href="#" onclick="return doclink('link-120', 'NoDeletes', 'link-79');">NoDeletes</a></tt> </tt>
619 <a name="L355"></a><tt class="py-lineno">355</tt>  <tt class="py-line">    <tt class="py-name">pos2</tt> <tt class="py-op">=</tt> <tt class="py-name">chunks</tt><tt class="py-op">.</tt><tt id="link-121" class="py-name"><a title="lxml.etree._Element.index" class="py-name" href="#" onclick="return doclink('link-121', 'index', 'link-118');">index</a></tt><tt class="py-op">(</tt><tt id="link-122" class="py-name"><a title="lxml.html.diff.DEL_END" class="py-name" href="#" onclick="return doclink('link-122', 'DEL_END', 'link-77');">DEL_END</a></tt><tt class="py-op">)</tt> </tt>
620 <a name="L356"></a><tt class="py-lineno">356</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">chunks</tt><tt class="py-op">[</tt><tt class="py-op">:</tt><tt class="py-name">pos</tt><tt class="py-op">]</tt><tt class="py-op">,</tt> <tt class="py-name">chunks</tt><tt class="py-op">[</tt><tt class="py-name">pos</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">:</tt><tt class="py-name">pos2</tt><tt class="py-op">]</tt><tt class="py-op">,</tt> <tt class="py-name">chunks</tt><tt class="py-op">[</tt><tt class="py-name">pos2</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">:</tt><tt class="py-op">]</tt> </tt>
621 </div><a name="L357"></a><tt class="py-lineno">357</tt>  <tt class="py-line"> </tt>
622 <a name="locate_unbalanced_start"></a><div id="locate_unbalanced_start-def"><a name="L358"></a><tt class="py-lineno">358</tt> <a class="py-toggle" href="#" id="locate_unbalanced_start-toggle" onclick="return toggle('locate_unbalanced_start');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#locate_unbalanced_start">locate_unbalanced_start</a><tt class="py-op">(</tt><tt class="py-param">unbalanced_start</tt><tt class="py-op">,</tt> <tt class="py-param">pre_delete</tt><tt class="py-op">,</tt> <tt class="py-param">post_delete</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
623 </div><div id="locate_unbalanced_start-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="locate_unbalanced_start-expanded"><a name="L359"></a><tt class="py-lineno">359</tt>  <tt class="py-line">    <tt class="py-docstring">""" pre_delete and post_delete implicitly point to a place in the</tt> </tt>
624 <a name="L360"></a><tt class="py-lineno">360</tt>  <tt class="py-line"><tt class="py-docstring">    document (where the two were split).  This moves that point (by</tt> </tt>
625 <a name="L361"></a><tt class="py-lineno">361</tt>  <tt class="py-line"><tt class="py-docstring">    popping items from one and pushing them onto the other).  It moves</tt> </tt>
626 <a name="L362"></a><tt class="py-lineno">362</tt>  <tt class="py-line"><tt class="py-docstring">    the point to try to find a place where unbalanced_start applies.</tt> </tt>
627 <a name="L363"></a><tt class="py-lineno">363</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
628 <a name="L364"></a><tt class="py-lineno">364</tt>  <tt class="py-line"><tt class="py-docstring">    As an example::</tt> </tt>
629 <a name="L365"></a><tt class="py-lineno">365</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
630 <a name="L366"></a><tt class="py-lineno">366</tt>  <tt class="py-line"><tt class="py-docstring">        &gt;&gt;&gt; unbalanced_start = ['&lt;div&gt;']</tt> </tt>
631 <a name="L367"></a><tt class="py-lineno">367</tt>  <tt class="py-line"><tt class="py-docstring">        &gt;&gt;&gt; doc = ['&lt;p&gt;', 'Text', '&lt;/p&gt;', '&lt;div&gt;', 'More Text', '&lt;/div&gt;']</tt> </tt>
632 <a name="L368"></a><tt class="py-lineno">368</tt>  <tt class="py-line"><tt class="py-docstring">        &gt;&gt;&gt; pre, post = doc[:3], doc[3:]</tt> </tt>
633 <a name="L369"></a><tt class="py-lineno">369</tt>  <tt class="py-line"><tt class="py-docstring">        &gt;&gt;&gt; pre, post</tt> </tt>
634 <a name="L370"></a><tt class="py-lineno">370</tt>  <tt class="py-line"><tt class="py-docstring">        (['&lt;p&gt;', 'Text', '&lt;/p&gt;'], ['&lt;div&gt;', 'More Text', '&lt;/div&gt;'])</tt> </tt>
635 <a name="L371"></a><tt class="py-lineno">371</tt>  <tt class="py-line"><tt class="py-docstring">        &gt;&gt;&gt; locate_unbalanced_start(unbalanced_start, pre, post)</tt> </tt>
636 <a name="L372"></a><tt class="py-lineno">372</tt>  <tt class="py-line"><tt class="py-docstring">        &gt;&gt;&gt; pre, post</tt> </tt>
637 <a name="L373"></a><tt class="py-lineno">373</tt>  <tt class="py-line"><tt class="py-docstring">        (['&lt;p&gt;', 'Text', '&lt;/p&gt;', '&lt;div&gt;'], ['More Text', '&lt;/div&gt;'])</tt> </tt>
638 <a name="L374"></a><tt class="py-lineno">374</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
639 <a name="L375"></a><tt class="py-lineno">375</tt>  <tt class="py-line"><tt class="py-docstring">    As you can see, we moved the point so that the dangling &lt;div&gt; that</tt> </tt>
640 <a name="L376"></a><tt class="py-lineno">376</tt>  <tt class="py-line"><tt class="py-docstring">    we found will be effectively replaced by the div in the original</tt> </tt>
641 <a name="L377"></a><tt class="py-lineno">377</tt>  <tt class="py-line"><tt class="py-docstring">    document.  If this doesn't work out, we just throw away</tt> </tt>
642 <a name="L378"></a><tt class="py-lineno">378</tt>  <tt class="py-line"><tt class="py-docstring">    unbalanced_start without doing anything.</tt> </tt>
643 <a name="L379"></a><tt class="py-lineno">379</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
644 <a name="L380"></a><tt class="py-lineno">380</tt>  <tt class="py-line">    <tt class="py-keyword">while</tt> <tt class="py-number">1</tt><tt class="py-op">:</tt> </tt>
645 <a name="L381"></a><tt class="py-lineno">381</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">unbalanced_start</tt><tt class="py-op">:</tt> </tt>
646 <a name="L382"></a><tt class="py-lineno">382</tt>  <tt class="py-line">            <tt class="py-comment"># We have totally succeded in finding the position</tt> </tt>
647 <a name="L383"></a><tt class="py-lineno">383</tt>  <tt class="py-line">            <tt class="py-keyword">break</tt> </tt>
648 <a name="L384"></a><tt class="py-lineno">384</tt>  <tt class="py-line">        <tt class="py-name">finding</tt> <tt class="py-op">=</tt> <tt class="py-name">unbalanced_start</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt> </tt>
649 <a name="L385"></a><tt class="py-lineno">385</tt>  <tt class="py-line">        <tt class="py-name">finding_name</tt> <tt class="py-op">=</tt> <tt class="py-name">finding</tt><tt class="py-op">.</tt><tt class="py-name">split</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt id="link-123" class="py-name"><a title="lxml.doctestcompare.strip" class="py-name" href="#" onclick="return doclink('link-123', 'strip', 'link-15');">strip</a></tt><tt class="py-op">(</tt><tt class="py-string">'&lt;&gt;'</tt><tt class="py-op">)</tt> </tt>
650 <a name="L386"></a><tt class="py-lineno">386</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">post_delete</tt><tt class="py-op">:</tt> </tt>
651 <a name="L387"></a><tt class="py-lineno">387</tt>  <tt class="py-line">            <tt class="py-keyword">break</tt> </tt>
652 <a name="L388"></a><tt class="py-lineno">388</tt>  <tt class="py-line">        <tt id="link-124" class="py-name" targets="Method lxml.cssselect.TokenStream.next()=lxml.cssselect.TokenStream-class.html#next,Method lxml.etree.ElementDepthFirstIterator.next()=lxml.etree.ElementDepthFirstIterator-class.html#next,Method lxml.etree.ElementTextIterator.next()=lxml.etree.ElementTextIterator-class.html#next,Method lxml.etree._AttribIterator.next()=lxml.etree._AttribIterator-class.html#next,Method lxml.etree._ElementIterator.next()=lxml.etree._ElementIterator-class.html#next,Method lxml.etree.iterparse.next()=lxml.etree.iterparse-class.html#next,Method lxml.etree.iterwalk.next()=lxml.etree.iterwalk-class.html#next"><a title="lxml.cssselect.TokenStream.next
653 lxml.etree.ElementDepthFirstIterator.next
654 lxml.etree.ElementTextIterator.next
655 lxml.etree._AttribIterator.next
656 lxml.etree._ElementIterator.next
657 lxml.etree.iterparse.next
658 lxml.etree.iterwalk.next" class="py-name" href="#" onclick="return doclink('link-124', 'next', 'link-124');">next</a></tt> <tt class="py-op">=</tt> <tt class="py-name">post_delete</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt> </tt>
659 <a name="L389"></a><tt class="py-lineno">389</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt id="link-125" class="py-name"><a title="lxml.cssselect.TokenStream.next
660 lxml.etree.ElementDepthFirstIterator.next
661 lxml.etree.ElementTextIterator.next
662 lxml.etree._AttribIterator.next
663 lxml.etree._ElementIterator.next
664 lxml.etree.iterparse.next
665 lxml.etree.iterwalk.next" class="py-name" href="#" onclick="return doclink('link-125', 'next', 'link-124');">next</a></tt> <tt class="py-keyword">is</tt> <tt id="link-126" class="py-name"><a title="lxml.html.diff.DEL_START" class="py-name" href="#" onclick="return doclink('link-126', 'DEL_START', 'link-74');">DEL_START</a></tt> <tt class="py-keyword">or</tt> <tt class="py-keyword">not</tt> <tt id="link-127" class="py-name"><a title="lxml.cssselect.TokenStream.next
666 lxml.etree.ElementDepthFirstIterator.next
667 lxml.etree.ElementTextIterator.next
668 lxml.etree._AttribIterator.next
669 lxml.etree._ElementIterator.next
670 lxml.etree.iterparse.next
671 lxml.etree.iterwalk.next" class="py-name" href="#" onclick="return doclink('link-127', 'next', 'link-124');">next</a></tt><tt class="py-op">.</tt><tt class="py-name">startswith</tt><tt class="py-op">(</tt><tt class="py-string">'&lt;'</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
672 <a name="L390"></a><tt class="py-lineno">390</tt>  <tt class="py-line">            <tt class="py-comment"># Reached a word, we can't move the delete text forward</tt> </tt>
673 <a name="L391"></a><tt class="py-lineno">391</tt>  <tt class="py-line">            <tt class="py-keyword">break</tt> </tt>
674 <a name="L392"></a><tt class="py-lineno">392</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt id="link-128" class="py-name"><a title="lxml.cssselect.TokenStream.next
675 lxml.etree.ElementDepthFirstIterator.next
676 lxml.etree.ElementTextIterator.next
677 lxml.etree._AttribIterator.next
678 lxml.etree._ElementIterator.next
679 lxml.etree.iterparse.next
680 lxml.etree.iterwalk.next" class="py-name" href="#" onclick="return doclink('link-128', 'next', 'link-124');">next</a></tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> <tt class="py-op">==</tt> <tt class="py-string">'/'</tt><tt class="py-op">:</tt> </tt>
681 <a name="L393"></a><tt class="py-lineno">393</tt>  <tt class="py-line">            <tt class="py-comment"># Reached a closing tag, can we go further?  Maybe not...</tt> </tt>
682 <a name="L394"></a><tt class="py-lineno">394</tt>  <tt class="py-line">            <tt class="py-keyword">break</tt> </tt>
683 <a name="L395"></a><tt class="py-lineno">395</tt>  <tt class="py-line">        <tt id="link-129" class="py-name"><a title="lxml.etree._Entity.name
684 lxml.etree._ModifyContentOnlyEntityProxy.name
685 lxml.etree._ReadOnlyEntityProxy.name
686 lxml.html.InputMixin.name
687 lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-129', 'name', 'link-90');">name</a></tt> <tt class="py-op">=</tt> <tt id="link-130" class="py-name"><a title="lxml.cssselect.TokenStream.next
688 lxml.etree.ElementDepthFirstIterator.next
689 lxml.etree.ElementTextIterator.next
690 lxml.etree._AttribIterator.next
691 lxml.etree._ElementIterator.next
692 lxml.etree.iterparse.next
693 lxml.etree.iterwalk.next" class="py-name" href="#" onclick="return doclink('link-130', 'next', 'link-124');">next</a></tt><tt class="py-op">.</tt><tt class="py-name">split</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt id="link-131" class="py-name"><a title="lxml.doctestcompare.strip" class="py-name" href="#" onclick="return doclink('link-131', 'strip', 'link-15');">strip</a></tt><tt class="py-op">(</tt><tt class="py-string">'&lt;&gt;'</tt><tt class="py-op">)</tt> </tt>
694 <a name="L396"></a><tt class="py-lineno">396</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt id="link-132" class="py-name"><a title="lxml.etree._Entity.name
695 lxml.etree._ModifyContentOnlyEntityProxy.name
696 lxml.etree._ReadOnlyEntityProxy.name
697 lxml.html.InputMixin.name
698 lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-132', 'name', 'link-90');">name</a></tt> <tt class="py-op">==</tt> <tt class="py-string">'ins'</tt><tt class="py-op">:</tt> </tt>
699 <a name="L397"></a><tt class="py-lineno">397</tt>  <tt class="py-line">            <tt class="py-comment"># Can't move into an insert</tt> </tt>
700 <a name="L398"></a><tt class="py-lineno">398</tt>  <tt class="py-line">            <tt class="py-keyword">break</tt> </tt>
701 <a name="L399"></a><tt class="py-lineno">399</tt>  <tt class="py-line">        <tt class="py-keyword">assert</tt> <tt id="link-133" class="py-name"><a title="lxml.etree._Entity.name
702 lxml.etree._ModifyContentOnlyEntityProxy.name
703 lxml.etree._ReadOnlyEntityProxy.name
704 lxml.html.InputMixin.name
705 lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-133', 'name', 'link-90');">name</a></tt> <tt class="py-op">!=</tt> <tt class="py-string">'del'</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt> </tt>
706 <a name="L400"></a><tt class="py-lineno">400</tt>  <tt class="py-line">            <tt class="py-string">"Unexpected delete tag: %r"</tt> <tt class="py-op">%</tt> <tt id="link-134" class="py-name"><a title="lxml.cssselect.TokenStream.next
707 lxml.etree.ElementDepthFirstIterator.next
708 lxml.etree.ElementTextIterator.next
709 lxml.etree._AttribIterator.next
710 lxml.etree._ElementIterator.next
711 lxml.etree.iterparse.next
712 lxml.etree.iterwalk.next" class="py-name" href="#" onclick="return doclink('link-134', 'next', 'link-124');">next</a></tt><tt class="py-op">)</tt> </tt>
713 <a name="L401"></a><tt class="py-lineno">401</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt id="link-135" class="py-name"><a title="lxml.etree._Entity.name
714 lxml.etree._ModifyContentOnlyEntityProxy.name
715 lxml.etree._ReadOnlyEntityProxy.name
716 lxml.html.InputMixin.name
717 lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-135', 'name', 'link-90');">name</a></tt> <tt class="py-op">==</tt> <tt class="py-name">finding_name</tt><tt class="py-op">:</tt> </tt>
718 <a name="L402"></a><tt class="py-lineno">402</tt>  <tt class="py-line">            <tt class="py-name">unbalanced_start</tt><tt class="py-op">.</tt><tt id="link-136" class="py-name"><a title="lxml.etree._Attrib.pop" class="py-name" href="#" onclick="return doclink('link-136', 'pop', 'link-99');">pop</a></tt><tt class="py-op">(</tt><tt class="py-number">0</tt><tt class="py-op">)</tt> </tt>
719 <a name="L403"></a><tt class="py-lineno">403</tt>  <tt class="py-line">            <tt class="py-name">pre_delete</tt><tt class="py-op">.</tt><tt id="link-137" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.append
720 lxml.etree._Element.append
721 lxml.etree._OpaqueDocumentWrapper.append
722 lxml.etree.__ContentOnlyElement.append" class="py-name" href="#" onclick="return doclink('link-137', 'append', 'link-20');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">post_delete</tt><tt class="py-op">.</tt><tt id="link-138" class="py-name"><a title="lxml.etree._Attrib.pop" class="py-name" href="#" onclick="return doclink('link-138', 'pop', 'link-99');">pop</a></tt><tt class="py-op">(</tt><tt class="py-number">0</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
723 <a name="L404"></a><tt class="py-lineno">404</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
724 <a name="L405"></a><tt class="py-lineno">405</tt>  <tt class="py-line">            <tt class="py-comment"># Found a tag that doesn't match</tt> </tt>
725 <a name="L406"></a><tt class="py-lineno">406</tt>  <tt class="py-line">            <tt class="py-keyword">break</tt> </tt>
726 </div><a name="L407"></a><tt class="py-lineno">407</tt>  <tt class="py-line"> </tt>
727 <a name="locate_unbalanced_end"></a><div id="locate_unbalanced_end-def"><a name="L408"></a><tt class="py-lineno">408</tt> <a class="py-toggle" href="#" id="locate_unbalanced_end-toggle" onclick="return toggle('locate_unbalanced_end');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#locate_unbalanced_end">locate_unbalanced_end</a><tt class="py-op">(</tt><tt class="py-param">unbalanced_end</tt><tt class="py-op">,</tt> <tt class="py-param">pre_delete</tt><tt class="py-op">,</tt> <tt class="py-param">post_delete</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
728 </div><div id="locate_unbalanced_end-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="locate_unbalanced_end-expanded"><a name="L409"></a><tt class="py-lineno">409</tt>  <tt class="py-line">    <tt class="py-docstring">""" like locate_unbalanced_start, except handling end tags and</tt> </tt>
729 <a name="L410"></a><tt class="py-lineno">410</tt>  <tt class="py-line"><tt class="py-docstring">    possibly moving the point earlier in the document.  """</tt> </tt>
730 <a name="L411"></a><tt class="py-lineno">411</tt>  <tt class="py-line">    <tt class="py-keyword">while</tt> <tt class="py-number">1</tt><tt class="py-op">:</tt> </tt>
731 <a name="L412"></a><tt class="py-lineno">412</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">unbalanced_end</tt><tt class="py-op">:</tt> </tt>
732 <a name="L413"></a><tt class="py-lineno">413</tt>  <tt class="py-line">            <tt class="py-comment"># Success</tt> </tt>
733 <a name="L414"></a><tt class="py-lineno">414</tt>  <tt class="py-line">            <tt class="py-keyword">break</tt> </tt>
734 <a name="L415"></a><tt class="py-lineno">415</tt>  <tt class="py-line">        <tt class="py-name">finding</tt> <tt class="py-op">=</tt> <tt class="py-name">unbalanced_end</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> </tt>
735 <a name="L416"></a><tt class="py-lineno">416</tt>  <tt class="py-line">        <tt class="py-name">finding_name</tt> <tt class="py-op">=</tt> <tt class="py-name">finding</tt><tt class="py-op">.</tt><tt class="py-name">split</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt id="link-139" class="py-name"><a title="lxml.doctestcompare.strip" class="py-name" href="#" onclick="return doclink('link-139', 'strip', 'link-15');">strip</a></tt><tt class="py-op">(</tt><tt class="py-string">'&lt;&gt;/'</tt><tt class="py-op">)</tt> </tt>
736 <a name="L417"></a><tt class="py-lineno">417</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">pre_delete</tt><tt class="py-op">:</tt> </tt>
737 <a name="L418"></a><tt class="py-lineno">418</tt>  <tt class="py-line">            <tt class="py-keyword">break</tt> </tt>
738 <a name="L419"></a><tt class="py-lineno">419</tt>  <tt class="py-line">        <tt id="link-140" class="py-name"><a title="lxml.cssselect.TokenStream.next
739 lxml.etree.ElementDepthFirstIterator.next
740 lxml.etree.ElementTextIterator.next
741 lxml.etree._AttribIterator.next
742 lxml.etree._ElementIterator.next
743 lxml.etree.iterparse.next
744 lxml.etree.iterwalk.next" class="py-name" href="#" onclick="return doclink('link-140', 'next', 'link-124');">next</a></tt> <tt class="py-op">=</tt> <tt class="py-name">pre_delete</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> </tt>
745 <a name="L420"></a><tt class="py-lineno">420</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt id="link-141" class="py-name"><a title="lxml.cssselect.TokenStream.next
746 lxml.etree.ElementDepthFirstIterator.next
747 lxml.etree.ElementTextIterator.next
748 lxml.etree._AttribIterator.next
749 lxml.etree._ElementIterator.next
750 lxml.etree.iterparse.next
751 lxml.etree.iterwalk.next" class="py-name" href="#" onclick="return doclink('link-141', 'next', 'link-124');">next</a></tt> <tt class="py-keyword">is</tt> <tt id="link-142" class="py-name"><a title="lxml.html.diff.DEL_END" class="py-name" href="#" onclick="return doclink('link-142', 'DEL_END', 'link-77');">DEL_END</a></tt> <tt class="py-keyword">or</tt> <tt class="py-keyword">not</tt> <tt id="link-143" class="py-name"><a title="lxml.cssselect.TokenStream.next
752 lxml.etree.ElementDepthFirstIterator.next
753 lxml.etree.ElementTextIterator.next
754 lxml.etree._AttribIterator.next
755 lxml.etree._ElementIterator.next
756 lxml.etree.iterparse.next
757 lxml.etree.iterwalk.next" class="py-name" href="#" onclick="return doclink('link-143', 'next', 'link-124');">next</a></tt><tt class="py-op">.</tt><tt class="py-name">startswith</tt><tt class="py-op">(</tt><tt class="py-string">'&lt;/'</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
758 <a name="L421"></a><tt class="py-lineno">421</tt>  <tt class="py-line">            <tt class="py-comment"># A word or a start tag</tt> </tt>
759 <a name="L422"></a><tt class="py-lineno">422</tt>  <tt class="py-line">            <tt class="py-keyword">break</tt> </tt>
760 <a name="L423"></a><tt class="py-lineno">423</tt>  <tt class="py-line">        <tt id="link-144" class="py-name"><a title="lxml.etree._Entity.name
761 lxml.etree._ModifyContentOnlyEntityProxy.name
762 lxml.etree._ReadOnlyEntityProxy.name
763 lxml.html.InputMixin.name
764 lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-144', 'name', 'link-90');">name</a></tt> <tt class="py-op">=</tt> <tt id="link-145" class="py-name"><a title="lxml.cssselect.TokenStream.next
765 lxml.etree.ElementDepthFirstIterator.next
766 lxml.etree.ElementTextIterator.next
767 lxml.etree._AttribIterator.next
768 lxml.etree._ElementIterator.next
769 lxml.etree.iterparse.next
770 lxml.etree.iterwalk.next" class="py-name" href="#" onclick="return doclink('link-145', 'next', 'link-124');">next</a></tt><tt class="py-op">.</tt><tt class="py-name">split</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt id="link-146" class="py-name"><a title="lxml.doctestcompare.strip" class="py-name" href="#" onclick="return doclink('link-146', 'strip', 'link-15');">strip</a></tt><tt class="py-op">(</tt><tt class="py-string">'&lt;&gt;/'</tt><tt class="py-op">)</tt> </tt>
771 <a name="L424"></a><tt class="py-lineno">424</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt id="link-147" class="py-name"><a title="lxml.etree._Entity.name
772 lxml.etree._ModifyContentOnlyEntityProxy.name
773 lxml.etree._ReadOnlyEntityProxy.name
774 lxml.html.InputMixin.name
775 lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-147', 'name', 'link-90');">name</a></tt> <tt class="py-op">==</tt> <tt class="py-string">'ins'</tt> <tt class="py-keyword">or</tt> <tt id="link-148" class="py-name"><a title="lxml.etree._Entity.name
776 lxml.etree._ModifyContentOnlyEntityProxy.name
777 lxml.etree._ReadOnlyEntityProxy.name
778 lxml.html.InputMixin.name
779 lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-148', 'name', 'link-90');">name</a></tt> <tt class="py-op">==</tt> <tt class="py-string">'del'</tt><tt class="py-op">:</tt> </tt>
780 <a name="L425"></a><tt class="py-lineno">425</tt>  <tt class="py-line">            <tt class="py-comment"># Can't move into an insert or delete</tt> </tt>
781 <a name="L426"></a><tt class="py-lineno">426</tt>  <tt class="py-line">            <tt class="py-keyword">break</tt> </tt>
782 <a name="L427"></a><tt class="py-lineno">427</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt id="link-149" class="py-name"><a title="lxml.etree._Entity.name
783 lxml.etree._ModifyContentOnlyEntityProxy.name
784 lxml.etree._ReadOnlyEntityProxy.name
785 lxml.html.InputMixin.name
786 lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-149', 'name', 'link-90');">name</a></tt> <tt class="py-op">==</tt> <tt class="py-name">finding_name</tt><tt class="py-op">:</tt> </tt>
787 <a name="L428"></a><tt class="py-lineno">428</tt>  <tt class="py-line">            <tt class="py-name">unbalanced_end</tt><tt class="py-op">.</tt><tt id="link-150" class="py-name"><a title="lxml.etree._Attrib.pop" class="py-name" href="#" onclick="return doclink('link-150', 'pop', 'link-99');">pop</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
788 <a name="L429"></a><tt class="py-lineno">429</tt>  <tt class="py-line">            <tt class="py-name">post_delete</tt><tt class="py-op">.</tt><tt id="link-151" class="py-name" targets="Method lxml.etree._Element.insert()=lxml.etree._Element-class.html#insert,Method lxml.etree.__ContentOnlyElement.insert()=lxml.etree.__ContentOnlyElement-class.html#insert"><a title="lxml.etree._Element.insert
789 lxml.etree.__ContentOnlyElement.insert" class="py-name" href="#" onclick="return doclink('link-151', 'insert', 'link-151');">insert</a></tt><tt class="py-op">(</tt><tt class="py-number">0</tt><tt class="py-op">,</tt> <tt class="py-name">pre_delete</tt><tt class="py-op">.</tt><tt id="link-152" class="py-name"><a title="lxml.etree._Attrib.pop" class="py-name" href="#" onclick="return doclink('link-152', 'pop', 'link-99');">pop</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
790 <a name="L430"></a><tt class="py-lineno">430</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
791 <a name="L431"></a><tt class="py-lineno">431</tt>  <tt class="py-line">            <tt class="py-comment"># Found a tag that doesn't match</tt> </tt>
792 <a name="L432"></a><tt class="py-lineno">432</tt>  <tt class="py-line">            <tt class="py-keyword">break</tt> </tt>
793 </div><a name="L433"></a><tt class="py-lineno">433</tt>  <tt class="py-line"> </tt>
794 <a name="token"></a><div id="token-def"><a name="L434"></a><tt class="py-lineno">434</tt> <a class="py-toggle" href="#" id="token-toggle" onclick="return toggle('token');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="lxml.html.diff.token-class.html">token</a><tt class="py-op">(</tt><tt class="py-base-class">_unicode</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
795 </div><div id="token-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="token-expanded"><a name="L435"></a><tt class="py-lineno">435</tt>  <tt class="py-line">    <tt class="py-docstring">""" Represents a diffable token, generally a word that is displayed to</tt> </tt>
796 <a name="L436"></a><tt class="py-lineno">436</tt>  <tt class="py-line"><tt class="py-docstring">    the user.  Opening tags are attached to this token when they are</tt> </tt>
797 <a name="L437"></a><tt class="py-lineno">437</tt>  <tt class="py-line"><tt class="py-docstring">    adjacent (pre_tags) and closing tags that follow the word</tt> </tt>
798 <a name="L438"></a><tt class="py-lineno">438</tt>  <tt class="py-line"><tt class="py-docstring">    (post_tags).  Some exceptions occur when there are empty tags</tt> </tt>
799 <a name="L439"></a><tt class="py-lineno">439</tt>  <tt class="py-line"><tt class="py-docstring">    adjacent to a word, so there may be close tags in pre_tags, or</tt> </tt>
800 <a name="L440"></a><tt class="py-lineno">440</tt>  <tt class="py-line"><tt class="py-docstring">    open tags in post_tags.</tt> </tt>
801 <a name="L441"></a><tt class="py-lineno">441</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
802 <a name="L442"></a><tt class="py-lineno">442</tt>  <tt class="py-line"><tt class="py-docstring">    We also keep track of whether the word was originally followed by</tt> </tt>
803 <a name="L443"></a><tt class="py-lineno">443</tt>  <tt class="py-line"><tt class="py-docstring">    whitespace, even though we do not want to treat the word as</tt> </tt>
804 <a name="L444"></a><tt class="py-lineno">444</tt>  <tt class="py-line"><tt class="py-docstring">    equivalent to a similar word that does not have a trailing</tt> </tt>
805 <a name="L445"></a><tt class="py-lineno">445</tt>  <tt class="py-line"><tt class="py-docstring">    space."""</tt> </tt>
806 <a name="L446"></a><tt class="py-lineno">446</tt>  <tt class="py-line"> </tt>
807 <a name="L447"></a><tt class="py-lineno">447</tt>  <tt class="py-line">    <tt class="py-comment"># When this is true, the token will be eliminated from the</tt> </tt>
808 <a name="L448"></a><tt class="py-lineno">448</tt>  <tt class="py-line">    <tt class="py-comment"># displayed diff if no change has occurred:</tt> </tt>
809 <a name="L449"></a><tt class="py-lineno">449</tt>  <tt class="py-line">    <tt id="link-153" class="py-name"><a title="lxml.html.diff.href_token.hide_when_equal
810 lxml.html.diff.token.hide_when_equal" class="py-name" href="#" onclick="return doclink('link-153', 'hide_when_equal', 'link-60');">hide_when_equal</a></tt> <tt class="py-op">=</tt> <tt class="py-name">False</tt> </tt>
811 <a name="L450"></a><tt class="py-lineno">450</tt>  <tt class="py-line"> </tt>
812 <a name="token.__new__"></a><div id="token.__new__-def"><a name="L451"></a><tt class="py-lineno">451</tt> <a class="py-toggle" href="#" id="token.__new__-toggle" onclick="return toggle('token.__new__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff.token-class.html#__new__">__new__</a><tt class="py-op">(</tt><tt class="py-param">cls</tt><tt class="py-op">,</tt> <tt class="py-param">text</tt><tt class="py-op">,</tt> <tt class="py-param">pre_tags</tt><tt class="py-op">=</tt><tt class="py-name">None</tt><tt class="py-op">,</tt> <tt class="py-param">post_tags</tt><tt class="py-op">=</tt><tt class="py-name">None</tt><tt class="py-op">,</tt> <tt class="py-param">trailing_whitespace</tt><tt class="py-op">=</tt><tt class="py-name">False</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
813 </div><div id="token.__new__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="token.__new__-expanded"><a name="L452"></a><tt class="py-lineno">452</tt>  <tt class="py-line">        <tt class="py-name">obj</tt> <tt class="py-op">=</tt> <tt class="py-name">_unicode</tt><tt class="py-op">.</tt><tt id="link-154" class="py-name" targets="Static Method lxml.cssselect._UniToken.__new__()=lxml.cssselect._UniToken-class.html#__new__,Method lxml.etree.AncestorsIterator.__new__()=lxml.etree.AncestorsIterator-class.html#__new__,Method lxml.etree.AttributeBasedElementClassLookup.__new__()=lxml.etree.AttributeBasedElementClassLookup-class.html#__new__,Method lxml.etree.CDATA.__new__()=lxml.etree.CDATA-class.html#__new__,Method lxml.etree.CommentBase.__new__()=lxml.etree.CommentBase-class.html#__new__,Method lxml.etree.CustomElementClassLookup.__new__()=lxml.etree.CustomElementClassLookup-class.html#__new__,Method lxml.etree.DTD.__new__()=lxml.etree.DTD-class.html#__new__,Method lxml.etree.DocInfo.__new__()=lxml.etree.DocInfo-class.html#__new__,Method lxml.etree.ETCompatXMLParser.__new__()=lxml.etree.ETCompatXMLParser-class.html#__new__,Method lxml.etree.ETXPath.__new__()=lxml.etree.ETXPath-class.html#__new__,Method lxml.etree.ElementBase.__new__()=lxml.etree.ElementBase-class.html#__new__,Method lxml.etree.ElementChildIterator.__new__()=lxml.etree.ElementChildIterator-class.html#__new__,Method lxml.etree.ElementClassLookup.__new__()=lxml.etree.ElementClassLookup-class.html#__new__,Method lxml.etree.ElementDefaultClassLookup.__new__()=lxml.etree.ElementDefaultClassLookup-class.html#__new__,Method lxml.etree.ElementDepthFirstIterator.__new__()=lxml.etree.ElementDepthFirstIterator-class.html#__new__,Method lxml.etree.ElementNamespaceClassLookup.__new__()=lxml.etree.ElementNamespaceClassLookup-class.html#__new__,Method lxml.etree.ElementTextIterator.__new__()=lxml.etree.ElementTextIterator-class.html#__new__,Method lxml.etree.EntityBase.__new__()=lxml.etree.EntityBase-class.html#__new__,Method lxml.etree.FallbackElementClassLookup.__new__()=lxml.etree.FallbackElementClassLookup-class.html#__new__,Method lxml.etree.HTMLParser.__new__()=lxml.etree.HTMLParser-class.html#__new__,Method lxml.etree.PIBase.__new__()=lxml.etree.PIBase-class.html#__new__,Method lxml.etree.ParserBasedElementClassLookup.__new__()=lxml.etree.ParserBasedElementClassLookup-class.html#__new__,Method lxml.etree.PyErrorLog.__new__()=lxml.etree.PyErrorLog-class.html#__new__,Method lxml.etree.PythonElementClassLookup.__new__()=lxml.etree.PythonElementClassLookup-class.html#__new__,Method lxml.etree.QName.__new__()=lxml.etree.QName-class.html#__new__,Method lxml.etree.RelaxNG.__new__()=lxml.etree.RelaxNG-class.html#__new__,Method lxml.etree.Resolver.__new__()=lxml.etree.Resolver-class.html#__new__,Method lxml.etree.Schematron.__new__()=lxml.etree.Schematron-class.html#__new__,Method lxml.etree.SiblingsIterator.__new__()=lxml.etree.SiblingsIterator-class.html#__new__,Method lxml.etree.TreeBuilder.__new__()=lxml.etree.TreeBuilder-class.html#__new__,Method lxml.etree.XInclude.__new__()=lxml.etree.XInclude-class.html#__new__,Method lxml.etree.XMLParser.__new__()=lxml.etree.XMLParser-class.html#__new__,Method lxml.etree.XMLSchema.__new__()=lxml.etree.XMLSchema-class.html#__new__,Method lxml.etree.XPath.__new__()=lxml.etree.XPath-class.html#__new__,Method lxml.etree.XPathDocumentEvaluator.__new__()=lxml.etree.XPathDocumentEvaluator-class.html#__new__,Method lxml.etree.XPathElementEvaluator.__new__()=lxml.etree.XPathElementEvaluator-class.html#__new__,Method lxml.etree.XSLT.__new__()=lxml.etree.XSLT-class.html#__new__,Method lxml.etree.XSLTAccessControl.__new__()=lxml.etree.XSLTAccessControl-class.html#__new__,Method lxml.etree.XSLTExtension.__new__()=lxml.etree.XSLTExtension-class.html#__new__,Method lxml.etree._AppendOnlyElementProxy.__new__()=lxml.etree._AppendOnlyElementProxy-class.html#__new__,Method lxml.etree._Attrib.__new__()=lxml.etree._Attrib-class.html#__new__,Method lxml.etree._AttribIterator.__new__()=lxml.etree._AttribIterator-class.html#__new__,Method lxml.etree._BaseContext.__new__()=lxml.etree._BaseContext-class.html#__new__,Method lxml.etree._BaseErrorLog.__new__()=lxml.etree._BaseErrorLog-class.html#__new__,Method lxml.etree._BaseParser.__new__()=lxml.etree._BaseParser-class.html#__new__,Method lxml.etree._ClassNamespaceRegistry.__new__()=lxml.etree._ClassNamespaceRegistry-class.html#__new__,Method lxml.etree._Comment.__new__()=lxml.etree._Comment-class.html#__new__,Method lxml.etree._Document.__new__()=lxml.etree._Document-class.html#__new__,Method lxml.etree._DomainErrorLog.__new__()=lxml.etree._DomainErrorLog-class.html#__new__,Method lxml.etree._Element.__new__()=lxml.etree._Element-class.html#__new__,Method lxml.etree._ElementIterator.__new__()=lxml.etree._ElementIterator-class.html#__new__,Method lxml.etree._ElementTagMatcher.__new__()=lxml.etree._ElementTagMatcher-class.html#__new__,Method lxml.etree._ElementTree.__new__()=lxml.etree._ElementTree-class.html#__new__,Method lxml.etree._ElementUnicodeResult.__new__()=lxml.etree._ElementUnicodeResult-class.html#__new__,Method lxml.etree._Entity.__new__()=lxml.etree._Entity-class.html#__new__,Method lxml.etree._ErrorLog.__new__()=lxml.etree._ErrorLog-class.html#__new__,Method lxml.etree._ExceptionContext.__new__()=lxml.etree._ExceptionContext-class.html#__new__,Method lxml.etree._ExsltRegExp.__new__()=lxml.etree._ExsltRegExp-class.html#__new__,Method lxml.etree._FeedParser.__new__()=lxml.etree._FeedParser-class.html#__new__,Method lxml.etree._FileReaderContext.__new__()=lxml.etree._FileReaderContext-class.html#__new__,Method lxml.etree._FilelikeWriter.__new__()=lxml.etree._FilelikeWriter-class.html#__new__,Method lxml.etree._FunctionNamespaceRegistry.__new__()=lxml.etree._FunctionNamespaceRegistry-class.html#__new__,Method lxml.etree._IDDict.__new__()=lxml.etree._IDDict-class.html#__new__,Method lxml.etree._InputDocument.__new__()=lxml.etree._InputDocument-class.html#__new__,Method lxml.etree._IterparseContext.__new__()=lxml.etree._IterparseContext-class.html#__new__,Method lxml.etree._ListErrorLog.__new__()=lxml.etree._ListErrorLog-class.html#__new__,Method lxml.etree._LogEntry.__new__()=lxml.etree._LogEntry-class.html#__new__,Method lxml.etree._ModifyContentOnlyEntityProxy.__new__()=lxml.etree._ModifyContentOnlyEntityProxy-class.html#__new__,Method lxml.etree._ModifyContentOnlyPIProxy.__new__()=lxml.etree._ModifyContentOnlyPIProxy-class.html#__new__,Method lxml.etree._ModifyContentOnlyProxy.__new__()=lxml.etree._ModifyContentOnlyProxy-class.html#__new__,Method lxml.etree._NamespaceRegistry.__new__()=lxml.etree._NamespaceRegistry-class.html#__new__,Method lxml.etree._OpaqueDocumentWrapper.__new__()=lxml.etree._OpaqueDocumentWrapper-class.html#__new__,Method lxml.etree._OpaqueNodeWrapper.__new__()=lxml.etree._OpaqueNodeWrapper-class.html#__new__,Method lxml.etree._ParserContext.__new__()=lxml.etree._ParserContext-class.html#__new__,Method lxml.etree._ParserDictionaryContext.__new__()=lxml.etree._ParserDictionaryContext-class.html#__new__,Method lxml.etree._ParserSchemaValidationContext.__new__()=lxml.etree._ParserSchemaValidationContext-class.html#__new__,Method lxml.etree._ProcessingInstruction.__new__()=lxml.etree._ProcessingInstruction-class.html#__new__,Method lxml.etree._PythonSaxParserTarget.__new__()=lxml.etree._PythonSaxParserTarget-class.html#__new__,Method lxml.etree._ReadOnlyElementProxy.__new__()=lxml.etree._ReadOnlyElementProxy-class.html#__new__,Method lxml.etree._ReadOnlyEntityProxy.__new__()=lxml.etree._ReadOnlyEntityProxy-class.html#__new__,Method lxml.etree._ReadOnlyPIProxy.__new__()=lxml.etree._ReadOnlyPIProxy-class.html#__new__,Method lxml.etree._ReadOnlyProxy.__new__()=lxml.etree._ReadOnlyProxy-class.html#__new__,Method lxml.etree._ResolverContext.__new__()=lxml.etree._ResolverContext-class.html#__new__,Method lxml.etree._ResolverRegistry.__new__()=lxml.etree._ResolverRegistry-class.html#__new__,Method lxml.etree._RotatingErrorLog.__new__()=lxml.etree._RotatingErrorLog-class.html#__new__,Method lxml.etree._SaxParserContext.__new__()=lxml.etree._SaxParserContext-class.html#__new__,Method lxml.etree._SaxParserTarget.__new__()=lxml.etree._SaxParserTarget-class.html#__new__,Method lxml.etree._TargetParserContext.__new__()=lxml.etree._TargetParserContext-class.html#__new__,Method lxml.etree._TempStore.__new__()=lxml.etree._TempStore-class.html#__new__,Method lxml.etree._Validator.__new__()=lxml.etree._Validator-class.html#__new__,Method lxml.etree._XPathContext.__new__()=lxml.etree._XPathContext-class.html#__new__,Method lxml.etree._XPathEvaluatorBase.__new__()=lxml.etree._XPathEvaluatorBase-class.html#__new__,Method lxml.etree._XPathFunctionNamespaceRegistry.__new__()=lxml.etree._XPathFunctionNamespaceRegistry-class.html#__new__,Method lxml.etree._XSLTContext.__new__()=lxml.etree._XSLTContext-class.html#__new__,Method lxml.etree._XSLTProcessingInstruction.__new__()=lxml.etree._XSLTProcessingInstruction-class.html#__new__,Method lxml.etree._XSLTQuotedStringParam.__new__()=lxml.etree._XSLTQuotedStringParam-class.html#__new__,Method lxml.etree._XSLTResolverContext.__new__()=lxml.etree._XSLTResolverContext-class.html#__new__,Method lxml.etree._XSLTResultTree.__new__()=lxml.etree._XSLTResultTree-class.html#__new__,Method lxml.etree.__ContentOnlyElement.__new__()=lxml.etree.__ContentOnlyElement-class.html#__new__,Method lxml.etree.iterparse.__new__()=lxml.etree.iterparse-class.html#__new__,Method lxml.etree.iterwalk.__new__()=lxml.etree.iterwalk-class.html#__new__,Static Method lxml.html.diff.tag_token.__new__()=lxml.html.diff.tag_token-class.html#__new__,Static Method lxml.html.diff.token.__new__()=lxml.html.diff.token-class.html#__new__,Method lxml.objectify.BoolElement.__new__()=lxml.objectify.BoolElement-class.html#__new__,Method lxml.objectify.ElementMaker.__new__()=lxml.objectify.ElementMaker-class.html#__new__,Method lxml.objectify.FloatElement.__new__()=lxml.objectify.FloatElement-class.html#__new__,Method lxml.objectify.IntElement.__new__()=lxml.objectify.IntElement-class.html#__new__,Method lxml.objectify.LongElement.__new__()=lxml.objectify.LongElement-class.html#__new__,Method lxml.objectify.NoneElement.__new__()=lxml.objectify.NoneElement-class.html#__new__,Method lxml.objectify.NumberElement.__new__()=lxml.objectify.NumberElement-class.html#__new__,Method lxml.objectify.ObjectPath.__new__()=lxml.objectify.ObjectPath-class.html#__new__,Method lxml.objectify.ObjectifiedDataElement.__new__()=lxml.objectify.ObjectifiedDataElement-class.html#__new__,Method lxml.objectify.ObjectifiedElement.__new__()=lxml.objectify.ObjectifiedElement-class.html#__new__,Method lxml.objectify.ObjectifyElementClassLookup.__new__()=lxml.objectify.ObjectifyElementClassLookup-class.html#__new__,Method lxml.objectify.PyType.__new__()=lxml.objectify.PyType-class.html#__new__,Method lxml.objectify.StringElement.__new__()=lxml.objectify.StringElement-class.html#__new__,Method lxml.objectify._ObjectifyElementMakerCaller.__new__()=lxml.objectify._ObjectifyElementMakerCaller-class.html#__new__"><a title="lxml.cssselect._UniToken.__new__
814 lxml.etree.AncestorsIterator.__new__
815 lxml.etree.AttributeBasedElementClassLookup.__new__
816 lxml.etree.CDATA.__new__
817 lxml.etree.CommentBase.__new__
818 lxml.etree.CustomElementClassLookup.__new__
819 lxml.etree.DTD.__new__
820 lxml.etree.DocInfo.__new__
821 lxml.etree.ETCompatXMLParser.__new__
822 lxml.etree.ETXPath.__new__
823 lxml.etree.ElementBase.__new__
824 lxml.etree.ElementChildIterator.__new__
825 lxml.etree.ElementClassLookup.__new__
826 lxml.etree.ElementDefaultClassLookup.__new__
827 lxml.etree.ElementDepthFirstIterator.__new__
828 lxml.etree.ElementNamespaceClassLookup.__new__
829 lxml.etree.ElementTextIterator.__new__
830 lxml.etree.EntityBase.__new__
831 lxml.etree.FallbackElementClassLookup.__new__
832 lxml.etree.HTMLParser.__new__
833 lxml.etree.PIBase.__new__
834 lxml.etree.ParserBasedElementClassLookup.__new__
835 lxml.etree.PyErrorLog.__new__
836 lxml.etree.PythonElementClassLookup.__new__
837 lxml.etree.QName.__new__
838 lxml.etree.RelaxNG.__new__
839 lxml.etree.Resolver.__new__
840 lxml.etree.Schematron.__new__
841 lxml.etree.SiblingsIterator.__new__
842 lxml.etree.TreeBuilder.__new__
843 lxml.etree.XInclude.__new__
844 lxml.etree.XMLParser.__new__
845 lxml.etree.XMLSchema.__new__
846 lxml.etree.XPath.__new__
847 lxml.etree.XPathDocumentEvaluator.__new__
848 lxml.etree.XPathElementEvaluator.__new__
849 lxml.etree.XSLT.__new__
850 lxml.etree.XSLTAccessControl.__new__
851 lxml.etree.XSLTExtension.__new__
852 lxml.etree._AppendOnlyElementProxy.__new__
853 lxml.etree._Attrib.__new__
854 lxml.etree._AttribIterator.__new__
855 lxml.etree._BaseContext.__new__
856 lxml.etree._BaseErrorLog.__new__
857 lxml.etree._BaseParser.__new__
858 lxml.etree._ClassNamespaceRegistry.__new__
859 lxml.etree._Comment.__new__
860 lxml.etree._Document.__new__
861 lxml.etree._DomainErrorLog.__new__
862 lxml.etree._Element.__new__
863 lxml.etree._ElementIterator.__new__
864 lxml.etree._ElementTagMatcher.__new__
865 lxml.etree._ElementTree.__new__
866 lxml.etree._ElementUnicodeResult.__new__
867 lxml.etree._Entity.__new__
868 lxml.etree._ErrorLog.__new__
869 lxml.etree._ExceptionContext.__new__
870 lxml.etree._ExsltRegExp.__new__
871 lxml.etree._FeedParser.__new__
872 lxml.etree._FileReaderContext.__new__
873 lxml.etree._FilelikeWriter.__new__
874 lxml.etree._FunctionNamespaceRegistry.__new__
875 lxml.etree._IDDict.__new__
876 lxml.etree._InputDocument.__new__
877 lxml.etree._IterparseContext.__new__
878 lxml.etree._ListErrorLog.__new__
879 lxml.etree._LogEntry.__new__
880 lxml.etree._ModifyContentOnlyEntityProxy.__new__
881 lxml.etree._ModifyContentOnlyPIProxy.__new__
882 lxml.etree._ModifyContentOnlyProxy.__new__
883 lxml.etree._NamespaceRegistry.__new__
884 lxml.etree._OpaqueDocumentWrapper.__new__
885 lxml.etree._OpaqueNodeWrapper.__new__
886 lxml.etree._ParserContext.__new__
887 lxml.etree._ParserDictionaryContext.__new__
888 lxml.etree._ParserSchemaValidationContext.__new__
889 lxml.etree._ProcessingInstruction.__new__
890 lxml.etree._PythonSaxParserTarget.__new__
891 lxml.etree._ReadOnlyElementProxy.__new__
892 lxml.etree._ReadOnlyEntityProxy.__new__
893 lxml.etree._ReadOnlyPIProxy.__new__
894 lxml.etree._ReadOnlyProxy.__new__
895 lxml.etree._ResolverContext.__new__
896 lxml.etree._ResolverRegistry.__new__
897 lxml.etree._RotatingErrorLog.__new__
898 lxml.etree._SaxParserContext.__new__
899 lxml.etree._SaxParserTarget.__new__
900 lxml.etree._TargetParserContext.__new__
901 lxml.etree._TempStore.__new__
902 lxml.etree._Validator.__new__
903 lxml.etree._XPathContext.__new__
904 lxml.etree._XPathEvaluatorBase.__new__
905 lxml.etree._XPathFunctionNamespaceRegistry.__new__
906 lxml.etree._XSLTContext.__new__
907 lxml.etree._XSLTProcessingInstruction.__new__
908 lxml.etree._XSLTQuotedStringParam.__new__
909 lxml.etree._XSLTResolverContext.__new__
910 lxml.etree._XSLTResultTree.__new__
911 lxml.etree.__ContentOnlyElement.__new__
912 lxml.etree.iterparse.__new__
913 lxml.etree.iterwalk.__new__
914 lxml.html.diff.tag_token.__new__
915 lxml.html.diff.token.__new__
916 lxml.objectify.BoolElement.__new__
917 lxml.objectify.ElementMaker.__new__
918 lxml.objectify.FloatElement.__new__
919 lxml.objectify.IntElement.__new__
920 lxml.objectify.LongElement.__new__
921 lxml.objectify.NoneElement.__new__
922 lxml.objectify.NumberElement.__new__
923 lxml.objectify.ObjectPath.__new__
924 lxml.objectify.ObjectifiedDataElement.__new__
925 lxml.objectify.ObjectifiedElement.__new__
926 lxml.objectify.ObjectifyElementClassLookup.__new__
927 lxml.objectify.PyType.__new__
928 lxml.objectify.StringElement.__new__
929 lxml.objectify._ObjectifyElementMakerCaller.__new__" class="py-name" href="#" onclick="return doclink('link-154', '__new__', 'link-154');">__new__</a></tt><tt class="py-op">(</tt><tt class="py-name">cls</tt><tt class="py-op">,</tt> <tt id="link-155" class="py-name"><a title="lxml.etree.QName.text
930 lxml.etree._AppendOnlyElementProxy.text
931 lxml.etree._Element.text
932 lxml.etree._Entity.text
933 lxml.etree._ModifyContentOnlyProxy.text
934 lxml.etree._ReadOnlyEntityProxy.text
935 lxml.etree._ReadOnlyProxy.text
936 lxml.etree.__ContentOnlyElement.text
937 lxml.objectify.ObjectifiedElement.text
938 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-155', 'text', 'link-6');">text</a></tt><tt class="py-op">)</tt> </tt>
939 <a name="L453"></a><tt class="py-lineno">453</tt>  <tt class="py-line"> </tt>
940 <a name="L454"></a><tt class="py-lineno">454</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">pre_tags</tt> <tt class="py-keyword">is</tt> <tt class="py-keyword">not</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
941 <a name="L455"></a><tt class="py-lineno">455</tt>  <tt class="py-line">            <tt class="py-name">obj</tt><tt class="py-op">.</tt><tt class="py-name">pre_tags</tt> <tt class="py-op">=</tt> <tt class="py-name">pre_tags</tt> </tt>
942 <a name="L456"></a><tt class="py-lineno">456</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
943 <a name="L457"></a><tt class="py-lineno">457</tt>  <tt class="py-line">            <tt class="py-name">obj</tt><tt class="py-op">.</tt><tt class="py-name">pre_tags</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
944 <a name="L458"></a><tt class="py-lineno">458</tt>  <tt class="py-line"> </tt>
945 <a name="L459"></a><tt class="py-lineno">459</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">post_tags</tt> <tt class="py-keyword">is</tt> <tt class="py-keyword">not</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
946 <a name="L460"></a><tt class="py-lineno">460</tt>  <tt class="py-line">            <tt class="py-name">obj</tt><tt class="py-op">.</tt><tt class="py-name">post_tags</tt> <tt class="py-op">=</tt> <tt class="py-name">post_tags</tt> </tt>
947 <a name="L461"></a><tt class="py-lineno">461</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
948 <a name="L462"></a><tt class="py-lineno">462</tt>  <tt class="py-line">            <tt class="py-name">obj</tt><tt class="py-op">.</tt><tt class="py-name">post_tags</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
949 <a name="L463"></a><tt class="py-lineno">463</tt>  <tt class="py-line"> </tt>
950 <a name="L464"></a><tt class="py-lineno">464</tt>  <tt class="py-line">        <tt class="py-name">obj</tt><tt class="py-op">.</tt><tt class="py-name">trailing_whitespace</tt> <tt class="py-op">=</tt> <tt class="py-name">trailing_whitespace</tt> </tt>
951 <a name="L465"></a><tt class="py-lineno">465</tt>  <tt class="py-line"> </tt>
952 <a name="L466"></a><tt class="py-lineno">466</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">obj</tt> </tt>
953 </div><a name="L467"></a><tt class="py-lineno">467</tt>  <tt class="py-line"> </tt>
954 <a name="token.__repr__"></a><div id="token.__repr__-def"><a name="L468"></a><tt class="py-lineno">468</tt> <a class="py-toggle" href="#" id="token.__repr__-toggle" onclick="return toggle('token.__repr__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff.token-class.html#__repr__">__repr__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
955 </div><div id="token.__repr__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="token.__repr__-expanded"><a name="L469"></a><tt class="py-lineno">469</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-string">'token(%s, %r, %r)'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">_unicode</tt><tt class="py-op">.</tt><tt id="link-156" class="py-name" targets="Method lxml.cssselect.Attrib.__repr__()=lxml.cssselect.Attrib-class.html#__repr__,Method lxml.cssselect.CSSSelector.__repr__()=lxml.cssselect.CSSSelector-class.html#__repr__,Method lxml.cssselect.Class.__repr__()=lxml.cssselect.Class-class.html#__repr__,Method lxml.cssselect.CombinedSelector.__repr__()=lxml.cssselect.CombinedSelector-class.html#__repr__,Method lxml.cssselect.Element.__repr__()=lxml.cssselect.Element-class.html#__repr__,Method lxml.cssselect.Function.__repr__()=lxml.cssselect.Function-class.html#__repr__,Method lxml.cssselect.Hash.__repr__()=lxml.cssselect.Hash-class.html#__repr__,Method lxml.cssselect.Or.__repr__()=lxml.cssselect.Or-class.html#__repr__,Method lxml.cssselect.Pseudo.__repr__()=lxml.cssselect.Pseudo-class.html#__repr__,Method lxml.cssselect.XPathExpr.__repr__()=lxml.cssselect.XPathExpr-class.html#__repr__,Method lxml.cssselect._UniToken.__repr__()=lxml.cssselect._UniToken-class.html#__repr__,Method lxml.etree.XPath.__repr__()=lxml.etree.XPath-class.html#__repr__,Method lxml.etree.XSLTAccessControl.__repr__()=lxml.etree.XSLTAccessControl-class.html#__repr__,Method lxml.etree._Attrib.__repr__()=lxml.etree._Attrib-class.html#__repr__,Method lxml.etree._BaseErrorLog.__repr__()=lxml.etree._BaseErrorLog-class.html#__repr__,Method lxml.etree._ClassNamespaceRegistry.__repr__()=lxml.etree._ClassNamespaceRegistry-class.html#__repr__,Method lxml.etree._Comment.__repr__()=lxml.etree._Comment-class.html#__repr__,Method lxml.etree._Element.__repr__()=lxml.etree._Element-class.html#__repr__,Method lxml.etree._Entity.__repr__()=lxml.etree._Entity-class.html#__repr__,Method lxml.etree._FunctionNamespaceRegistry.__repr__()=lxml.etree._FunctionNamespaceRegistry-class.html#__repr__,Method lxml.etree._IDDict.__repr__()=lxml.etree._IDDict-class.html#__repr__,Method lxml.etree._ListErrorLog.__repr__()=lxml.etree._ListErrorLog-class.html#__repr__,Method lxml.etree._LogEntry.__repr__()=lxml.etree._LogEntry-class.html#__repr__,Method lxml.etree._ProcessingInstruction.__repr__()=lxml.etree._ProcessingInstruction-class.html#__repr__,Method lxml.etree._ReadOnlyProxy.__repr__()=lxml.etree._ReadOnlyProxy-class.html#__repr__,Method lxml.etree._ResolverRegistry.__repr__()=lxml.etree._ResolverRegistry-class.html#__repr__,Method lxml.html.CheckboxGroup.__repr__()=lxml.html.CheckboxGroup-class.html#__repr__,Method lxml.html.CheckboxValues.__repr__()=lxml.html.CheckboxValues-class.html#__repr__,Method lxml.html.FieldsDict.__repr__()=lxml.html.FieldsDict-class.html#__repr__,Method lxml.html.InputGetter.__repr__()=lxml.html.InputGetter-class.html#__repr__,Method lxml.html.InputMixin.__repr__()=lxml.html.InputMixin-class.html#__repr__,Method lxml.html.MultipleSelectOptions.__repr__()=lxml.html.MultipleSelectOptions-class.html#__repr__,Method lxml.html.RadioGroup.__repr__()=lxml.html.RadioGroup-class.html#__repr__,Method lxml.html.diff.tag_token.__repr__()=lxml.html.diff.tag_token-class.html#__repr__,Method lxml.html.diff.token.__repr__()=lxml.html.diff.token-class.html#__repr__,Method lxml.objectify.BoolElement.__repr__()=lxml.objectify.BoolElement-class.html#__repr__,Method lxml.objectify.NoneElement.__repr__()=lxml.objectify.NoneElement-class.html#__repr__,Method lxml.objectify.NumberElement.__repr__()=lxml.objectify.NumberElement-class.html#__repr__,Method lxml.objectify.ObjectifiedDataElement.__repr__()=lxml.objectify.ObjectifiedDataElement-class.html#__repr__,Method lxml.objectify.PyType.__repr__()=lxml.objectify.PyType-class.html#__repr__,Method lxml.objectify.StringElement.__repr__()=lxml.objectify.StringElement-class.html#__repr__"><a title="lxml.cssselect.Attrib.__repr__
956 lxml.cssselect.CSSSelector.__repr__
957 lxml.cssselect.Class.__repr__
958 lxml.cssselect.CombinedSelector.__repr__
959 lxml.cssselect.Element.__repr__
960 lxml.cssselect.Function.__repr__
961 lxml.cssselect.Hash.__repr__
962 lxml.cssselect.Or.__repr__
963 lxml.cssselect.Pseudo.__repr__
964 lxml.cssselect.XPathExpr.__repr__
965 lxml.cssselect._UniToken.__repr__
966 lxml.etree.XPath.__repr__
967 lxml.etree.XSLTAccessControl.__repr__
968 lxml.etree._Attrib.__repr__
969 lxml.etree._BaseErrorLog.__repr__
970 lxml.etree._ClassNamespaceRegistry.__repr__
971 lxml.etree._Comment.__repr__
972 lxml.etree._Element.__repr__
973 lxml.etree._Entity.__repr__
974 lxml.etree._FunctionNamespaceRegistry.__repr__
975 lxml.etree._IDDict.__repr__
976 lxml.etree._ListErrorLog.__repr__
977 lxml.etree._LogEntry.__repr__
978 lxml.etree._ProcessingInstruction.__repr__
979 lxml.etree._ReadOnlyProxy.__repr__
980 lxml.etree._ResolverRegistry.__repr__
981 lxml.html.CheckboxGroup.__repr__
982 lxml.html.CheckboxValues.__repr__
983 lxml.html.FieldsDict.__repr__
984 lxml.html.InputGetter.__repr__
985 lxml.html.InputMixin.__repr__
986 lxml.html.MultipleSelectOptions.__repr__
987 lxml.html.RadioGroup.__repr__
988 lxml.html.diff.tag_token.__repr__
989 lxml.html.diff.token.__repr__
990 lxml.objectify.BoolElement.__repr__
991 lxml.objectify.NoneElement.__repr__
992 lxml.objectify.NumberElement.__repr__
993 lxml.objectify.ObjectifiedDataElement.__repr__
994 lxml.objectify.PyType.__repr__
995 lxml.objectify.StringElement.__repr__" class="py-name" href="#" onclick="return doclink('link-156', '__repr__', 'link-156');">__repr__</a></tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">)</tt><tt class="py-op">,</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">pre_tags</tt><tt class="py-op">,</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">post_tags</tt><tt class="py-op">)</tt> </tt>
996 </div><a name="L470"></a><tt class="py-lineno">470</tt>  <tt class="py-line"> </tt>
997 <a name="token.html"></a><div id="token.html-def"><a name="L471"></a><tt class="py-lineno">471</tt> <a class="py-toggle" href="#" id="token.html-toggle" onclick="return toggle('token.html');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff.token-class.html#html">html</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
998 </div><div id="token.html-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="token.html-expanded"><a name="L472"></a><tt class="py-lineno">472</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">_unicode</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">)</tt> </tt>
999 </div></div><a name="L473"></a><tt class="py-lineno">473</tt>  <tt class="py-line"> </tt>
1000 <a name="tag_token"></a><div id="tag_token-def"><a name="L474"></a><tt class="py-lineno">474</tt> <a class="py-toggle" href="#" id="tag_token-toggle" onclick="return toggle('tag_token');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="lxml.html.diff.tag_token-class.html">tag_token</a><tt class="py-op">(</tt><tt class="py-base-class">token</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1001 </div><div id="tag_token-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="tag_token-expanded"><a name="L475"></a><tt class="py-lineno">475</tt>  <tt class="py-line"> </tt>
1002 <a name="L476"></a><tt class="py-lineno">476</tt>  <tt class="py-line">    <tt class="py-docstring">""" Represents a token that is actually a tag.  Currently this is just</tt> </tt>
1003 <a name="L477"></a><tt class="py-lineno">477</tt>  <tt class="py-line"><tt class="py-docstring">    the &lt;img&gt; tag, which takes up visible space just like a word but</tt> </tt>
1004 <a name="L478"></a><tt class="py-lineno">478</tt>  <tt class="py-line"><tt class="py-docstring">    is only represented in a document by a tag.  """</tt> </tt>
1005 <a name="L479"></a><tt class="py-lineno">479</tt>  <tt class="py-line"> </tt>
1006 <a name="tag_token.__new__"></a><div id="tag_token.__new__-def"><a name="L480"></a><tt class="py-lineno">480</tt> <a class="py-toggle" href="#" id="tag_token.__new__-toggle" onclick="return toggle('tag_token.__new__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff.tag_token-class.html#__new__">__new__</a><tt class="py-op">(</tt><tt class="py-param">cls</tt><tt class="py-op">,</tt> <tt class="py-param">tag</tt><tt class="py-op">,</tt> <tt class="py-param">data</tt><tt class="py-op">,</tt> <tt class="py-param">html_repr</tt><tt class="py-op">,</tt> <tt class="py-param">pre_tags</tt><tt class="py-op">=</tt><tt class="py-name">None</tt><tt class="py-op">,</tt>  </tt>
1007 <a name="L481"></a><tt class="py-lineno">481</tt>  <tt class="py-line">                <tt class="py-param">post_tags</tt><tt class="py-op">=</tt><tt class="py-name">None</tt><tt class="py-op">,</tt> <tt class="py-param">trailing_whitespace</tt><tt class="py-op">=</tt><tt class="py-name">False</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1008 </div><div id="tag_token.__new__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="tag_token.__new__-expanded"><a name="L482"></a><tt class="py-lineno">482</tt>  <tt class="py-line">        <tt class="py-name">obj</tt> <tt class="py-op">=</tt> <tt id="link-157" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-157', 'token', 'link-22');">token</a></tt><tt class="py-op">.</tt><tt id="link-158" class="py-name"><a title="lxml.cssselect._UniToken.__new__
1009 lxml.etree.AncestorsIterator.__new__
1010 lxml.etree.AttributeBasedElementClassLookup.__new__
1011 lxml.etree.CDATA.__new__
1012 lxml.etree.CommentBase.__new__
1013 lxml.etree.CustomElementClassLookup.__new__
1014 lxml.etree.DTD.__new__
1015 lxml.etree.DocInfo.__new__
1016 lxml.etree.ETCompatXMLParser.__new__
1017 lxml.etree.ETXPath.__new__
1018 lxml.etree.ElementBase.__new__
1019 lxml.etree.ElementChildIterator.__new__
1020 lxml.etree.ElementClassLookup.__new__
1021 lxml.etree.ElementDefaultClassLookup.__new__
1022 lxml.etree.ElementDepthFirstIterator.__new__
1023 lxml.etree.ElementNamespaceClassLookup.__new__
1024 lxml.etree.ElementTextIterator.__new__
1025 lxml.etree.EntityBase.__new__
1026 lxml.etree.FallbackElementClassLookup.__new__
1027 lxml.etree.HTMLParser.__new__
1028 lxml.etree.PIBase.__new__
1029 lxml.etree.ParserBasedElementClassLookup.__new__
1030 lxml.etree.PyErrorLog.__new__
1031 lxml.etree.PythonElementClassLookup.__new__
1032 lxml.etree.QName.__new__
1033 lxml.etree.RelaxNG.__new__
1034 lxml.etree.Resolver.__new__
1035 lxml.etree.Schematron.__new__
1036 lxml.etree.SiblingsIterator.__new__
1037 lxml.etree.TreeBuilder.__new__
1038 lxml.etree.XInclude.__new__
1039 lxml.etree.XMLParser.__new__
1040 lxml.etree.XMLSchema.__new__
1041 lxml.etree.XPath.__new__
1042 lxml.etree.XPathDocumentEvaluator.__new__
1043 lxml.etree.XPathElementEvaluator.__new__
1044 lxml.etree.XSLT.__new__
1045 lxml.etree.XSLTAccessControl.__new__
1046 lxml.etree.XSLTExtension.__new__
1047 lxml.etree._AppendOnlyElementProxy.__new__
1048 lxml.etree._Attrib.__new__
1049 lxml.etree._AttribIterator.__new__
1050 lxml.etree._BaseContext.__new__
1051 lxml.etree._BaseErrorLog.__new__
1052 lxml.etree._BaseParser.__new__
1053 lxml.etree._ClassNamespaceRegistry.__new__
1054 lxml.etree._Comment.__new__
1055 lxml.etree._Document.__new__
1056 lxml.etree._DomainErrorLog.__new__
1057 lxml.etree._Element.__new__
1058 lxml.etree._ElementIterator.__new__
1059 lxml.etree._ElementTagMatcher.__new__
1060 lxml.etree._ElementTree.__new__
1061 lxml.etree._ElementUnicodeResult.__new__
1062 lxml.etree._Entity.__new__
1063 lxml.etree._ErrorLog.__new__
1064 lxml.etree._ExceptionContext.__new__
1065 lxml.etree._ExsltRegExp.__new__
1066 lxml.etree._FeedParser.__new__
1067 lxml.etree._FileReaderContext.__new__
1068 lxml.etree._FilelikeWriter.__new__
1069 lxml.etree._FunctionNamespaceRegistry.__new__
1070 lxml.etree._IDDict.__new__
1071 lxml.etree._InputDocument.__new__
1072 lxml.etree._IterparseContext.__new__
1073 lxml.etree._ListErrorLog.__new__
1074 lxml.etree._LogEntry.__new__
1075 lxml.etree._ModifyContentOnlyEntityProxy.__new__
1076 lxml.etree._ModifyContentOnlyPIProxy.__new__
1077 lxml.etree._ModifyContentOnlyProxy.__new__
1078 lxml.etree._NamespaceRegistry.__new__
1079 lxml.etree._OpaqueDocumentWrapper.__new__
1080 lxml.etree._OpaqueNodeWrapper.__new__
1081 lxml.etree._ParserContext.__new__
1082 lxml.etree._ParserDictionaryContext.__new__
1083 lxml.etree._ParserSchemaValidationContext.__new__
1084 lxml.etree._ProcessingInstruction.__new__
1085 lxml.etree._PythonSaxParserTarget.__new__
1086 lxml.etree._ReadOnlyElementProxy.__new__
1087 lxml.etree._ReadOnlyEntityProxy.__new__
1088 lxml.etree._ReadOnlyPIProxy.__new__
1089 lxml.etree._ReadOnlyProxy.__new__
1090 lxml.etree._ResolverContext.__new__
1091 lxml.etree._ResolverRegistry.__new__
1092 lxml.etree._RotatingErrorLog.__new__
1093 lxml.etree._SaxParserContext.__new__
1094 lxml.etree._SaxParserTarget.__new__
1095 lxml.etree._TargetParserContext.__new__
1096 lxml.etree._TempStore.__new__
1097 lxml.etree._Validator.__new__
1098 lxml.etree._XPathContext.__new__
1099 lxml.etree._XPathEvaluatorBase.__new__
1100 lxml.etree._XPathFunctionNamespaceRegistry.__new__
1101 lxml.etree._XSLTContext.__new__
1102 lxml.etree._XSLTProcessingInstruction.__new__
1103 lxml.etree._XSLTQuotedStringParam.__new__
1104 lxml.etree._XSLTResolverContext.__new__
1105 lxml.etree._XSLTResultTree.__new__
1106 lxml.etree.__ContentOnlyElement.__new__
1107 lxml.etree.iterparse.__new__
1108 lxml.etree.iterwalk.__new__
1109 lxml.html.diff.tag_token.__new__
1110 lxml.html.diff.token.__new__
1111 lxml.objectify.BoolElement.__new__
1112 lxml.objectify.ElementMaker.__new__
1113 lxml.objectify.FloatElement.__new__
1114 lxml.objectify.IntElement.__new__
1115 lxml.objectify.LongElement.__new__
1116 lxml.objectify.NoneElement.__new__
1117 lxml.objectify.NumberElement.__new__
1118 lxml.objectify.ObjectPath.__new__
1119 lxml.objectify.ObjectifiedDataElement.__new__
1120 lxml.objectify.ObjectifiedElement.__new__
1121 lxml.objectify.ObjectifyElementClassLookup.__new__
1122 lxml.objectify.PyType.__new__
1123 lxml.objectify.StringElement.__new__
1124 lxml.objectify._ObjectifyElementMakerCaller.__new__" class="py-name" href="#" onclick="return doclink('link-158', '__new__', 'link-154');">__new__</a></tt><tt class="py-op">(</tt><tt class="py-name">cls</tt><tt class="py-op">,</tt> <tt class="py-string">"%s: %s"</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt id="link-159" class="py-name"><a title="lxml.etree._LogEntry.type
1125 lxml.html.InputElement.type" class="py-name" href="#" onclick="return doclink('link-159', 'type', 'link-21');">type</a></tt><tt class="py-op">,</tt> <tt id="link-160" class="py-name" targets="Method lxml.etree.TreeBuilder.data()=lxml.etree.TreeBuilder-class.html#data"><a title="lxml.etree.TreeBuilder.data" class="py-name" href="#" onclick="return doclink('link-160', 'data', 'link-160');">data</a></tt><tt class="py-op">)</tt><tt class="py-op">,</tt>  </tt>
1126 <a name="L483"></a><tt class="py-lineno">483</tt>  <tt class="py-line">                            <tt class="py-name">pre_tags</tt><tt class="py-op">=</tt><tt class="py-name">pre_tags</tt><tt class="py-op">,</tt>  </tt>
1127 <a name="L484"></a><tt class="py-lineno">484</tt>  <tt class="py-line">                            <tt class="py-name">post_tags</tt><tt class="py-op">=</tt><tt class="py-name">post_tags</tt><tt class="py-op">,</tt>  </tt>
1128 <a name="L485"></a><tt class="py-lineno">485</tt>  <tt class="py-line">                            <tt class="py-name">trailing_whitespace</tt><tt class="py-op">=</tt><tt class="py-name">trailing_whitespace</tt><tt class="py-op">)</tt> </tt>
1129 <a name="L486"></a><tt class="py-lineno">486</tt>  <tt class="py-line">        <tt class="py-name">obj</tt><tt class="py-op">.</tt><tt id="link-161" class="py-name"><a title="lxml.etree._Comment.tag
1130 lxml.etree._Element.tag
1131 lxml.etree._Entity.tag
1132 lxml.etree._ProcessingInstruction.tag
1133 lxml.etree._ReadOnlyProxy.tag
1134 lxml.tests.test_xpathevaluator.tag
1135 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-161', 'tag', 'link-98');">tag</a></tt> <tt class="py-op">=</tt> <tt id="link-162" class="py-name"><a title="lxml.etree._Comment.tag
1136 lxml.etree._Element.tag
1137 lxml.etree._Entity.tag
1138 lxml.etree._ProcessingInstruction.tag
1139 lxml.etree._ReadOnlyProxy.tag
1140 lxml.tests.test_xpathevaluator.tag
1141 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-162', 'tag', 'link-98');">tag</a></tt> </tt>
1142 <a name="L487"></a><tt class="py-lineno">487</tt>  <tt class="py-line">        <tt class="py-name">obj</tt><tt class="py-op">.</tt><tt id="link-163" class="py-name"><a title="lxml.etree.TreeBuilder.data" class="py-name" href="#" onclick="return doclink('link-163', 'data', 'link-160');">data</a></tt> <tt class="py-op">=</tt> <tt id="link-164" class="py-name"><a title="lxml.etree.TreeBuilder.data" class="py-name" href="#" onclick="return doclink('link-164', 'data', 'link-160');">data</a></tt> </tt>
1143 <a name="L488"></a><tt class="py-lineno">488</tt>  <tt class="py-line">        <tt class="py-name">obj</tt><tt class="py-op">.</tt><tt class="py-name">html_repr</tt> <tt class="py-op">=</tt> <tt class="py-name">html_repr</tt> </tt>
1144 <a name="L489"></a><tt class="py-lineno">489</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">obj</tt> </tt>
1145 </div><a name="L490"></a><tt class="py-lineno">490</tt>  <tt class="py-line"> </tt>
1146 <a name="tag_token.__repr__"></a><div id="tag_token.__repr__-def"><a name="L491"></a><tt class="py-lineno">491</tt> <a class="py-toggle" href="#" id="tag_token.__repr__-toggle" onclick="return toggle('tag_token.__repr__');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff.tag_token-class.html#__repr__">__repr__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1147 </div><div id="tag_token.__repr__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="tag_token.__repr__-expanded"><a name="L492"></a><tt class="py-lineno">492</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-string">'tag_token(%s, %s, html_repr=%s, post_tags=%r, pre_tags=%r, trailing_whitespace=%s)'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt> </tt>
1148 <a name="L493"></a><tt class="py-lineno">493</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-165" class="py-name"><a title="lxml.etree._Comment.tag
1149 lxml.etree._Element.tag
1150 lxml.etree._Entity.tag
1151 lxml.etree._ProcessingInstruction.tag
1152 lxml.etree._ReadOnlyProxy.tag
1153 lxml.tests.test_xpathevaluator.tag
1154 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-165', 'tag', 'link-98');">tag</a></tt><tt class="py-op">,</tt>  </tt>
1155 <a name="L494"></a><tt class="py-lineno">494</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-166" class="py-name"><a title="lxml.etree.TreeBuilder.data" class="py-name" href="#" onclick="return doclink('link-166', 'data', 'link-160');">data</a></tt><tt class="py-op">,</tt>  </tt>
1156 <a name="L495"></a><tt class="py-lineno">495</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">html_repr</tt><tt class="py-op">,</tt>  </tt>
1157 <a name="L496"></a><tt class="py-lineno">496</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">pre_tags</tt><tt class="py-op">,</tt>  </tt>
1158 <a name="L497"></a><tt class="py-lineno">497</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">post_tags</tt><tt class="py-op">,</tt>  </tt>
1159 <a name="L498"></a><tt class="py-lineno">498</tt>  <tt class="py-line">            <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">trailing_whitespace</tt><tt class="py-op">)</tt> </tt>
1160 </div><a name="tag_token.html"></a><div id="tag_token.html-def"><a name="L499"></a><tt class="py-lineno">499</tt> <a class="py-toggle" href="#" id="tag_token.html-toggle" onclick="return toggle('tag_token.html');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff.tag_token-class.html#html">html</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1161 </div><div id="tag_token.html-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="tag_token.html-expanded"><a name="L500"></a><tt class="py-lineno">500</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">html_repr</tt> </tt>
1162 </div></div><a name="L501"></a><tt class="py-lineno">501</tt>  <tt class="py-line"> </tt>
1163 <a name="href_token"></a><div id="href_token-def"><a name="L502"></a><tt class="py-lineno">502</tt> <a class="py-toggle" href="#" id="href_token-toggle" onclick="return toggle('href_token');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="lxml.html.diff.href_token-class.html">href_token</a><tt class="py-op">(</tt><tt class="py-base-class">token</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1164 </div><div id="href_token-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="href_token-expanded"><a name="L503"></a><tt class="py-lineno">503</tt>  <tt class="py-line"> </tt>
1165 <a name="L504"></a><tt class="py-lineno">504</tt>  <tt class="py-line">    <tt class="py-docstring">""" Represents the href in an anchor tag.  Unlike other words, we only</tt> </tt>
1166 <a name="L505"></a><tt class="py-lineno">505</tt>  <tt class="py-line"><tt class="py-docstring">    show the href when it changes.  """</tt> </tt>
1167 <a name="L506"></a><tt class="py-lineno">506</tt>  <tt class="py-line"> </tt>
1168 <a name="L507"></a><tt class="py-lineno">507</tt>  <tt class="py-line">    <tt id="link-167" class="py-name"><a title="lxml.html.diff.href_token.hide_when_equal
1169 lxml.html.diff.token.hide_when_equal" class="py-name" href="#" onclick="return doclink('link-167', 'hide_when_equal', 'link-60');">hide_when_equal</a></tt> <tt class="py-op">=</tt> <tt class="py-name">True</tt> </tt>
1170 <a name="L508"></a><tt class="py-lineno">508</tt>  <tt class="py-line"> </tt>
1171 <a name="href_token.html"></a><div id="href_token.html-def"><a name="L509"></a><tt class="py-lineno">509</tt> <a class="py-toggle" href="#" id="href_token.html-toggle" onclick="return toggle('href_token.html');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff.href_token-class.html#html">html</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1172 </div><div id="href_token.html-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="href_token.html-expanded"><a name="L510"></a><tt class="py-lineno">510</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-string">' Link: %s'</tt> <tt class="py-op">%</tt> <tt class="py-name">self</tt> </tt>
1173 </div></div><a name="L511"></a><tt class="py-lineno">511</tt>  <tt class="py-line"> </tt>
1174 <a name="tokenize"></a><div id="tokenize-def"><a name="L512"></a><tt class="py-lineno">512</tt> <a class="py-toggle" href="#" id="tokenize-toggle" onclick="return toggle('tokenize');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#tokenize">tokenize</a><tt class="py-op">(</tt><tt class="py-param">html</tt><tt class="py-op">,</tt> <tt class="py-param">include_hrefs</tt><tt class="py-op">=</tt><tt class="py-name">True</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1175 </div><div id="tokenize-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="tokenize-expanded"><a name="L513"></a><tt class="py-lineno">513</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
1176 <a name="L514"></a><tt class="py-lineno">514</tt>  <tt class="py-line"><tt class="py-docstring">    Parse the given HTML and returns token objects (words with attached tags).</tt> </tt>
1177 <a name="L515"></a><tt class="py-lineno">515</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
1178 <a name="L516"></a><tt class="py-lineno">516</tt>  <tt class="py-line"><tt class="py-docstring">    This parses only the content of a page; anything in the head is</tt> </tt>
1179 <a name="L517"></a><tt class="py-lineno">517</tt>  <tt class="py-line"><tt class="py-docstring">    ignored, and the &lt;head&gt; and &lt;body&gt; elements are themselves</tt> </tt>
1180 <a name="L518"></a><tt class="py-lineno">518</tt>  <tt class="py-line"><tt class="py-docstring">    optional.  The content is then parsed by lxml, which ensures the</tt> </tt>
1181 <a name="L519"></a><tt class="py-lineno">519</tt>  <tt class="py-line"><tt class="py-docstring">    validity of the resulting parsed document (though lxml may make</tt> </tt>
1182 <a name="L520"></a><tt class="py-lineno">520</tt>  <tt class="py-line"><tt class="py-docstring">    incorrect guesses when the markup is particular bad).</tt> </tt>
1183 <a name="L521"></a><tt class="py-lineno">521</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
1184 <a name="L522"></a><tt class="py-lineno">522</tt>  <tt class="py-line"><tt class="py-docstring">    &lt;ins&gt; and &lt;del&gt; tags are also eliminated from the document, as</tt> </tt>
1185 <a name="L523"></a><tt class="py-lineno">523</tt>  <tt class="py-line"><tt class="py-docstring">    that gets confusing.</tt> </tt>
1186 <a name="L524"></a><tt class="py-lineno">524</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
1187 <a name="L525"></a><tt class="py-lineno">525</tt>  <tt class="py-line"><tt class="py-docstring">    If include_hrefs is true, then the href attribute of &lt;a&gt; tags is</tt> </tt>
1188 <a name="L526"></a><tt class="py-lineno">526</tt>  <tt class="py-line"><tt class="py-docstring">    included as a special kind of diffable token."""</tt> </tt>
1189 <a name="L527"></a><tt class="py-lineno">527</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt id="link-168" class="py-name"><a title="lxml.etree
1190 lxml.sax.ElementTreeContentHandler.etree
1191 lxml.tests.test_elementtree.CElementTreeTestCase.etree
1192 lxml.tests.test_elementtree.ETreeTestCaseBase.etree
1193 lxml.tests.test_io.IOTestCaseBase.etree" class="py-name" href="#" onclick="return doclink('link-168', 'etree', 'link-1');">etree</a></tt><tt class="py-op">.</tt><tt id="link-169" class="py-name" targets="Function lxml.etree.iselement()=lxml.etree-module.html#iselement"><a title="lxml.etree.iselement" class="py-name" href="#" onclick="return doclink('link-169', 'iselement', 'link-169');">iselement</a></tt><tt class="py-op">(</tt><tt id="link-170" class="py-name"><a title="lxml.html
1194 lxml.html.diff.href_token.html
1195 lxml.html.diff.tag_token.html
1196 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-170', 'html', 'link-3');">html</a></tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1197 <a name="L528"></a><tt class="py-lineno">528</tt>  <tt class="py-line">        <tt class="py-name">body_el</tt> <tt class="py-op">=</tt> <tt id="link-171" class="py-name"><a title="lxml.html
1198 lxml.html.diff.href_token.html
1199 lxml.html.diff.tag_token.html
1200 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-171', 'html', 'link-3');">html</a></tt> </tt>
1201 <a name="L529"></a><tt class="py-lineno">529</tt>  <tt class="py-line">    <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
1202 <a name="L530"></a><tt class="py-lineno">530</tt>  <tt class="py-line">        <tt class="py-name">body_el</tt> <tt class="py-op">=</tt> <tt id="link-172" class="py-name" targets="Function lxml.html.diff.parse_html()=lxml.html.diff-module.html#parse_html"><a title="lxml.html.diff.parse_html" class="py-name" href="#" onclick="return doclink('link-172', 'parse_html', 'link-172');">parse_html</a></tt><tt class="py-op">(</tt><tt id="link-173" class="py-name"><a title="lxml.html
1203 lxml.html.diff.href_token.html
1204 lxml.html.diff.tag_token.html
1205 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-173', 'html', 'link-3');">html</a></tt><tt class="py-op">,</tt> <tt class="py-name">cleanup</tt><tt class="py-op">=</tt><tt class="py-name">True</tt><tt class="py-op">)</tt> </tt>
1206 <a name="L531"></a><tt class="py-lineno">531</tt>  <tt class="py-line">    <tt class="py-comment"># Then we split the document into text chunks for each tag, word, and end tag:</tt> </tt>
1207 <a name="L532"></a><tt class="py-lineno">532</tt>  <tt class="py-line">    <tt class="py-name">chunks</tt> <tt class="py-op">=</tt> <tt id="link-174" class="py-name" targets="Function lxml.html.diff.flatten_el()=lxml.html.diff-module.html#flatten_el"><a title="lxml.html.diff.flatten_el" class="py-name" href="#" onclick="return doclink('link-174', 'flatten_el', 'link-174');">flatten_el</a></tt><tt class="py-op">(</tt><tt class="py-name">body_el</tt><tt class="py-op">,</tt> <tt class="py-name">skip_tag</tt><tt class="py-op">=</tt><tt class="py-name">True</tt><tt class="py-op">,</tt> <tt class="py-name">include_hrefs</tt><tt class="py-op">=</tt><tt class="py-name">include_hrefs</tt><tt class="py-op">)</tt> </tt>
1208 <a name="L533"></a><tt class="py-lineno">533</tt>  <tt class="py-line">    <tt class="py-comment"># Finally re-joining them into token objects:</tt> </tt>
1209 <a name="L534"></a><tt class="py-lineno">534</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt id="link-175" class="py-name" targets="Function lxml.html.diff.fixup_chunks()=lxml.html.diff-module.html#fixup_chunks"><a title="lxml.html.diff.fixup_chunks" class="py-name" href="#" onclick="return doclink('link-175', 'fixup_chunks', 'link-175');">fixup_chunks</a></tt><tt class="py-op">(</tt><tt class="py-name">chunks</tt><tt class="py-op">)</tt> </tt>
1210 </div><a name="L535"></a><tt class="py-lineno">535</tt>  <tt class="py-line"> </tt>
1211 <a name="parse_html"></a><div id="parse_html-def"><a name="L536"></a><tt class="py-lineno">536</tt> <a class="py-toggle" href="#" id="parse_html-toggle" onclick="return toggle('parse_html');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#parse_html">parse_html</a><tt class="py-op">(</tt><tt class="py-param">html</tt><tt class="py-op">,</tt> <tt class="py-param">cleanup</tt><tt class="py-op">=</tt><tt class="py-name">True</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1212 </div><div id="parse_html-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="parse_html-expanded"><a name="L537"></a><tt class="py-lineno">537</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
1213 <a name="L538"></a><tt class="py-lineno">538</tt>  <tt class="py-line"><tt class="py-docstring">    Parses an HTML fragment, returning an lxml element.  Note that the HTML will be</tt> </tt>
1214 <a name="L539"></a><tt class="py-lineno">539</tt>  <tt class="py-line"><tt class="py-docstring">    wrapped in a &lt;div&gt; tag that was not in the original document.</tt> </tt>
1215 <a name="L540"></a><tt class="py-lineno">540</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
1216 <a name="L541"></a><tt class="py-lineno">541</tt>  <tt class="py-line"><tt class="py-docstring">    If cleanup is true, make sure there's no &lt;head&gt; or &lt;body&gt;, and get</tt> </tt>
1217 <a name="L542"></a><tt class="py-lineno">542</tt>  <tt class="py-line"><tt class="py-docstring">    rid of any &lt;ins&gt; and &lt;del&gt; tags.</tt> </tt>
1218 <a name="L543"></a><tt class="py-lineno">543</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
1219 <a name="L544"></a><tt class="py-lineno">544</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">cleanup</tt><tt class="py-op">:</tt> </tt>
1220 <a name="L545"></a><tt class="py-lineno">545</tt>  <tt class="py-line">        <tt class="py-comment"># This removes any extra markup or structure like &lt;head&gt;:</tt> </tt>
1221 <a name="L546"></a><tt class="py-lineno">546</tt>  <tt class="py-line">        <tt id="link-176" class="py-name"><a title="lxml.html
1222 lxml.html.diff.href_token.html
1223 lxml.html.diff.tag_token.html
1224 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-176', 'html', 'link-3');">html</a></tt> <tt class="py-op">=</tt> <tt id="link-177" class="py-name" targets="Function lxml.html.diff.cleanup_html()=lxml.html.diff-module.html#cleanup_html"><a title="lxml.html.diff.cleanup_html" class="py-name" href="#" onclick="return doclink('link-177', 'cleanup_html', 'link-177');">cleanup_html</a></tt><tt class="py-op">(</tt><tt id="link-178" class="py-name"><a title="lxml.html
1225 lxml.html.diff.href_token.html
1226 lxml.html.diff.tag_token.html
1227 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-178', 'html', 'link-3');">html</a></tt><tt class="py-op">)</tt> </tt>
1228 <a name="L547"></a><tt class="py-lineno">547</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt id="link-179" class="py-name"><a title="lxml.html.fragment_fromstring
1229 lxml.html.html5parser.fragment_fromstring" class="py-name" href="#" onclick="return doclink('link-179', 'fragment_fromstring', 'link-4');">fragment_fromstring</a></tt><tt class="py-op">(</tt><tt id="link-180" class="py-name"><a title="lxml.html
1230 lxml.html.diff.href_token.html
1231 lxml.html.diff.tag_token.html
1232 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-180', 'html', 'link-3');">html</a></tt><tt class="py-op">,</tt> <tt class="py-name">create_parent</tt><tt class="py-op">=</tt><tt class="py-name">True</tt><tt class="py-op">)</tt> </tt>
1233 </div><a name="L548"></a><tt class="py-lineno">548</tt>  <tt class="py-line"> </tt>
1234 <a name="L549"></a><tt class="py-lineno">549</tt>  <tt class="py-line"><tt id="link-181" class="py-name" targets="Variable lxml.html.diff._body_re=lxml.html.diff-module.html#_body_re"><a title="lxml.html.diff._body_re" class="py-name" href="#" onclick="return doclink('link-181', '_body_re', 'link-181');">_body_re</a></tt> <tt class="py-op">=</tt> <tt class="py-name">re</tt><tt class="py-op">.</tt><tt class="py-name">compile</tt><tt class="py-op">(</tt><tt class="py-string">r'&lt;body.*?&gt;'</tt><tt class="py-op">,</tt> <tt class="py-name">re</tt><tt class="py-op">.</tt><tt id="link-182" class="py-name" targets="Variable lxml.html.builder.I=lxml.html.builder-module.html#I"><a title="lxml.html.builder.I" class="py-name" href="#" onclick="return doclink('link-182', 'I', 'link-182');">I</a></tt><tt class="py-op">|</tt><tt class="py-name">re</tt><tt class="py-op">.</tt><tt id="link-183" class="py-name" targets="Variable lxml.html.builder.S=lxml.html.builder-module.html#S"><a title="lxml.html.builder.S" class="py-name" href="#" onclick="return doclink('link-183', 'S', 'link-183');">S</a></tt><tt class="py-op">)</tt> </tt>
1235 <a name="L550"></a><tt class="py-lineno">550</tt>  <tt class="py-line"><tt id="link-184" class="py-name" targets="Variable lxml.html.diff._end_body_re=lxml.html.diff-module.html#_end_body_re"><a title="lxml.html.diff._end_body_re" class="py-name" href="#" onclick="return doclink('link-184', '_end_body_re', 'link-184');">_end_body_re</a></tt> <tt class="py-op">=</tt> <tt class="py-name">re</tt><tt class="py-op">.</tt><tt class="py-name">compile</tt><tt class="py-op">(</tt><tt class="py-string">r'&lt;/body.*?&gt;'</tt><tt class="py-op">,</tt> <tt class="py-name">re</tt><tt class="py-op">.</tt><tt id="link-185" class="py-name"><a title="lxml.html.builder.I" class="py-name" href="#" onclick="return doclink('link-185', 'I', 'link-182');">I</a></tt><tt class="py-op">|</tt><tt class="py-name">re</tt><tt class="py-op">.</tt><tt id="link-186" class="py-name"><a title="lxml.html.builder.S" class="py-name" href="#" onclick="return doclink('link-186', 'S', 'link-183');">S</a></tt><tt class="py-op">)</tt> </tt>
1236 <a name="L551"></a><tt class="py-lineno">551</tt>  <tt class="py-line"><tt id="link-187" class="py-name" targets="Variable lxml.html.diff._ins_del_re=lxml.html.diff-module.html#_ins_del_re"><a title="lxml.html.diff._ins_del_re" class="py-name" href="#" onclick="return doclink('link-187', '_ins_del_re', 'link-187');">_ins_del_re</a></tt> <tt class="py-op">=</tt> <tt class="py-name">re</tt><tt class="py-op">.</tt><tt class="py-name">compile</tt><tt class="py-op">(</tt><tt class="py-string">r'&lt;/?(ins|del).*?&gt;'</tt><tt class="py-op">,</tt> <tt class="py-name">re</tt><tt class="py-op">.</tt><tt id="link-188" class="py-name"><a title="lxml.html.builder.I" class="py-name" href="#" onclick="return doclink('link-188', 'I', 'link-182');">I</a></tt><tt class="py-op">|</tt><tt class="py-name">re</tt><tt class="py-op">.</tt><tt id="link-189" class="py-name"><a title="lxml.html.builder.S" class="py-name" href="#" onclick="return doclink('link-189', 'S', 'link-183');">S</a></tt><tt class="py-op">)</tt> </tt>
1237 <a name="L552"></a><tt class="py-lineno">552</tt>  <tt class="py-line"> </tt>
1238 <a name="cleanup_html"></a><div id="cleanup_html-def"><a name="L553"></a><tt class="py-lineno">553</tt> <a class="py-toggle" href="#" id="cleanup_html-toggle" onclick="return toggle('cleanup_html');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#cleanup_html">cleanup_html</a><tt class="py-op">(</tt><tt class="py-param">html</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1239 </div><div id="cleanup_html-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="cleanup_html-expanded"><a name="L554"></a><tt class="py-lineno">554</tt>  <tt class="py-line">    <tt class="py-docstring">""" This 'cleans' the HTML, meaning that any page structure is removed</tt> </tt>
1240 <a name="L555"></a><tt class="py-lineno">555</tt>  <tt class="py-line"><tt class="py-docstring">    (only the contents of &lt;body&gt; are used, if there is any &lt;body).</tt> </tt>
1241 <a name="L556"></a><tt class="py-lineno">556</tt>  <tt class="py-line"><tt class="py-docstring">    Also &lt;ins&gt; and &lt;del&gt; tags are removed.  """</tt> </tt>
1242 <a name="L557"></a><tt class="py-lineno">557</tt>  <tt class="py-line">    <tt id="link-190" class="py-name" targets="Method lxml.etree._ExsltRegExp.match()=lxml.etree._ExsltRegExp-class.html#match"><a title="lxml.etree._ExsltRegExp.match" class="py-name" href="#" onclick="return doclink('link-190', 'match', 'link-190');">match</a></tt> <tt class="py-op">=</tt> <tt id="link-191" class="py-name"><a title="lxml.html.diff._body_re" class="py-name" href="#" onclick="return doclink('link-191', '_body_re', 'link-181');">_body_re</a></tt><tt class="py-op">.</tt><tt class="py-name">search</tt><tt class="py-op">(</tt><tt id="link-192" class="py-name"><a title="lxml.html
1243 lxml.html.diff.href_token.html
1244 lxml.html.diff.tag_token.html
1245 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-192', 'html', 'link-3');">html</a></tt><tt class="py-op">)</tt> </tt>
1246 <a name="L558"></a><tt class="py-lineno">558</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt id="link-193" class="py-name"><a title="lxml.etree._ExsltRegExp.match" class="py-name" href="#" onclick="return doclink('link-193', 'match', 'link-190');">match</a></tt><tt class="py-op">:</tt> </tt>
1247 <a name="L559"></a><tt class="py-lineno">559</tt>  <tt class="py-line">        <tt id="link-194" class="py-name"><a title="lxml.html
1248 lxml.html.diff.href_token.html
1249 lxml.html.diff.tag_token.html
1250 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-194', 'html', 'link-3');">html</a></tt> <tt class="py-op">=</tt> <tt id="link-195" class="py-name"><a title="lxml.html
1251 lxml.html.diff.href_token.html
1252 lxml.html.diff.tag_token.html
1253 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-195', 'html', 'link-3');">html</a></tt><tt class="py-op">[</tt><tt id="link-196" class="py-name"><a title="lxml.etree._ExsltRegExp.match" class="py-name" href="#" onclick="return doclink('link-196', 'match', 'link-190');">match</a></tt><tt class="py-op">.</tt><tt id="link-197" class="py-name"><a title="lxml.etree.TreeBuilder.end" class="py-name" href="#" onclick="return doclink('link-197', 'end', 'link-88');">end</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">:</tt><tt class="py-op">]</tt> </tt>
1254 <a name="L560"></a><tt class="py-lineno">560</tt>  <tt class="py-line">    <tt id="link-198" class="py-name"><a title="lxml.etree._ExsltRegExp.match" class="py-name" href="#" onclick="return doclink('link-198', 'match', 'link-190');">match</a></tt> <tt class="py-op">=</tt> <tt id="link-199" class="py-name"><a title="lxml.html.diff._end_body_re" class="py-name" href="#" onclick="return doclink('link-199', '_end_body_re', 'link-184');">_end_body_re</a></tt><tt class="py-op">.</tt><tt class="py-name">search</tt><tt class="py-op">(</tt><tt id="link-200" class="py-name"><a title="lxml.html
1255 lxml.html.diff.href_token.html
1256 lxml.html.diff.tag_token.html
1257 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-200', 'html', 'link-3');">html</a></tt><tt class="py-op">)</tt> </tt>
1258 <a name="L561"></a><tt class="py-lineno">561</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt id="link-201" class="py-name"><a title="lxml.etree._ExsltRegExp.match" class="py-name" href="#" onclick="return doclink('link-201', 'match', 'link-190');">match</a></tt><tt class="py-op">:</tt> </tt>
1259 <a name="L562"></a><tt class="py-lineno">562</tt>  <tt class="py-line">        <tt id="link-202" class="py-name"><a title="lxml.html
1260 lxml.html.diff.href_token.html
1261 lxml.html.diff.tag_token.html
1262 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-202', 'html', 'link-3');">html</a></tt> <tt class="py-op">=</tt> <tt id="link-203" class="py-name"><a title="lxml.html
1263 lxml.html.diff.href_token.html
1264 lxml.html.diff.tag_token.html
1265 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-203', 'html', 'link-3');">html</a></tt><tt class="py-op">[</tt><tt class="py-op">:</tt><tt id="link-204" class="py-name"><a title="lxml.etree._ExsltRegExp.match" class="py-name" href="#" onclick="return doclink('link-204', 'match', 'link-190');">match</a></tt><tt class="py-op">.</tt><tt id="link-205" class="py-name"><a title="lxml.etree.TreeBuilder.start" class="py-name" href="#" onclick="return doclink('link-205', 'start', 'link-87');">start</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">]</tt> </tt>
1266 <a name="L563"></a><tt class="py-lineno">563</tt>  <tt class="py-line">    <tt id="link-206" class="py-name"><a title="lxml.html
1267 lxml.html.diff.href_token.html
1268 lxml.html.diff.tag_token.html
1269 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-206', 'html', 'link-3');">html</a></tt> <tt class="py-op">=</tt> <tt id="link-207" class="py-name"><a title="lxml.html.diff._ins_del_re" class="py-name" href="#" onclick="return doclink('link-207', '_ins_del_re', 'link-187');">_ins_del_re</a></tt><tt class="py-op">.</tt><tt class="py-name">sub</tt><tt class="py-op">(</tt><tt class="py-string">''</tt><tt class="py-op">,</tt> <tt id="link-208" class="py-name"><a title="lxml.html
1270 lxml.html.diff.href_token.html
1271 lxml.html.diff.tag_token.html
1272 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-208', 'html', 'link-3');">html</a></tt><tt class="py-op">)</tt> </tt>
1273 <a name="L564"></a><tt class="py-lineno">564</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt id="link-209" class="py-name"><a title="lxml.html
1274 lxml.html.diff.href_token.html
1275 lxml.html.diff.tag_token.html
1276 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-209', 'html', 'link-3');">html</a></tt> </tt>
1277 </div><a name="L565"></a><tt class="py-lineno">565</tt>  <tt class="py-line">     </tt>
1278 <a name="L566"></a><tt class="py-lineno">566</tt>  <tt class="py-line"> </tt>
1279 <a name="L567"></a><tt class="py-lineno">567</tt>  <tt class="py-line"><tt id="link-210" class="py-name" targets="Variable lxml.html.diff.end_whitespace_re=lxml.html.diff-module.html#end_whitespace_re"><a title="lxml.html.diff.end_whitespace_re" class="py-name" href="#" onclick="return doclink('link-210', 'end_whitespace_re', 'link-210');">end_whitespace_re</a></tt> <tt class="py-op">=</tt> <tt class="py-name">re</tt><tt class="py-op">.</tt><tt class="py-name">compile</tt><tt class="py-op">(</tt><tt class="py-string">r'[ \t\n\r]$'</tt><tt class="py-op">)</tt> </tt>
1280 <a name="L568"></a><tt class="py-lineno">568</tt>  <tt class="py-line"> </tt>
1281 <a name="fixup_chunks"></a><div id="fixup_chunks-def"><a name="L569"></a><tt class="py-lineno">569</tt> <a class="py-toggle" href="#" id="fixup_chunks-toggle" onclick="return toggle('fixup_chunks');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#fixup_chunks">fixup_chunks</a><tt class="py-op">(</tt><tt class="py-param">chunks</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1282 </div><div id="fixup_chunks-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="fixup_chunks-expanded"><a name="L570"></a><tt class="py-lineno">570</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
1283 <a name="L571"></a><tt class="py-lineno">571</tt>  <tt class="py-line"><tt class="py-docstring">    This function takes a list of chunks and produces a list of tokens.</tt> </tt>
1284 <a name="L572"></a><tt class="py-lineno">572</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
1285 <a name="L573"></a><tt class="py-lineno">573</tt>  <tt class="py-line">    <tt class="py-name">tag_accum</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
1286 <a name="L574"></a><tt class="py-lineno">574</tt>  <tt class="py-line">    <tt class="py-name">cur_word</tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt> </tt>
1287 <a name="L575"></a><tt class="py-lineno">575</tt>  <tt class="py-line">    <tt class="py-name">result</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
1288 <a name="L576"></a><tt class="py-lineno">576</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt class="py-name">chunk</tt> <tt class="py-keyword">in</tt> <tt class="py-name">chunks</tt><tt class="py-op">:</tt> </tt>
1289 <a name="L577"></a><tt class="py-lineno">577</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">isinstance</tt><tt class="py-op">(</tt><tt class="py-name">chunk</tt><tt class="py-op">,</tt> <tt class="py-name">tuple</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1290 <a name="L578"></a><tt class="py-lineno">578</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">chunk</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt> <tt class="py-op">==</tt> <tt class="py-string">'img'</tt><tt class="py-op">:</tt> </tt>
1291 <a name="L579"></a><tt class="py-lineno">579</tt>  <tt class="py-line">                <tt class="py-name">src</tt> <tt class="py-op">=</tt> <tt class="py-name">chunk</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> </tt>
1292 <a name="L580"></a><tt class="py-lineno">580</tt>  <tt class="py-line">                <tt id="link-211" class="py-name"><a title="lxml.etree._Comment.tag
1293 lxml.etree._Element.tag
1294 lxml.etree._Entity.tag
1295 lxml.etree._ProcessingInstruction.tag
1296 lxml.etree._ReadOnlyProxy.tag
1297 lxml.tests.test_xpathevaluator.tag
1298 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-211', 'tag', 'link-98');">tag</a></tt> <tt class="py-op">=</tt> <tt class="py-name">chunk</tt><tt class="py-op">[</tt><tt class="py-number">2</tt><tt class="py-op">]</tt> </tt>
1299 <a name="L581"></a><tt class="py-lineno">581</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt id="link-212" class="py-name"><a title="lxml.etree._Comment.tag
1300 lxml.etree._Element.tag
1301 lxml.etree._Entity.tag
1302 lxml.etree._ProcessingInstruction.tag
1303 lxml.etree._ReadOnlyProxy.tag
1304 lxml.tests.test_xpathevaluator.tag
1305 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-212', 'tag', 'link-98');">tag</a></tt><tt class="py-op">.</tt><tt class="py-name">endswith</tt><tt class="py-op">(</tt><tt class="py-string">' '</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1306 <a name="L582"></a><tt class="py-lineno">582</tt>  <tt class="py-line">                    <tt id="link-213" class="py-name"><a title="lxml.etree._Comment.tag
1307 lxml.etree._Element.tag
1308 lxml.etree._Entity.tag
1309 lxml.etree._ProcessingInstruction.tag
1310 lxml.etree._ReadOnlyProxy.tag
1311 lxml.tests.test_xpathevaluator.tag
1312 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-213', 'tag', 'link-98');">tag</a></tt> <tt class="py-op">=</tt> <tt id="link-214" class="py-name"><a title="lxml.etree._Comment.tag
1313 lxml.etree._Element.tag
1314 lxml.etree._Entity.tag
1315 lxml.etree._ProcessingInstruction.tag
1316 lxml.etree._ReadOnlyProxy.tag
1317 lxml.tests.test_xpathevaluator.tag
1318 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-214', 'tag', 'link-98');">tag</a></tt><tt class="py-op">[</tt><tt class="py-op">:</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> </tt>
1319 <a name="L583"></a><tt class="py-lineno">583</tt>  <tt class="py-line">                    <tt class="py-name">trailing_whitespace</tt> <tt class="py-op">=</tt> <tt class="py-name">True</tt> </tt>
1320 <a name="L584"></a><tt class="py-lineno">584</tt>  <tt class="py-line">                <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
1321 <a name="L585"></a><tt class="py-lineno">585</tt>  <tt class="py-line">                    <tt class="py-name">trailing_whitespace</tt> <tt class="py-op">=</tt> <tt class="py-name">False</tt> </tt>
1322 <a name="L586"></a><tt class="py-lineno">586</tt>  <tt class="py-line">                <tt class="py-name">cur_word</tt> <tt class="py-op">=</tt> <tt id="link-215" class="py-name" targets="Class lxml.html.diff.tag_token=lxml.html.diff.tag_token-class.html"><a title="lxml.html.diff.tag_token" class="py-name" href="#" onclick="return doclink('link-215', 'tag_token', 'link-215');">tag_token</a></tt><tt class="py-op">(</tt><tt class="py-string">'img'</tt><tt class="py-op">,</tt> <tt class="py-name">src</tt><tt class="py-op">,</tt> <tt class="py-name">html_repr</tt><tt class="py-op">=</tt><tt id="link-216" class="py-name"><a title="lxml.etree._Comment.tag
1323 lxml.etree._Element.tag
1324 lxml.etree._Entity.tag
1325 lxml.etree._ProcessingInstruction.tag
1326 lxml.etree._ReadOnlyProxy.tag
1327 lxml.tests.test_xpathevaluator.tag
1328 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-216', 'tag', 'link-98');">tag</a></tt><tt class="py-op">,</tt> </tt>
1329 <a name="L587"></a><tt class="py-lineno">587</tt>  <tt class="py-line">                                     <tt class="py-name">pre_tags</tt><tt class="py-op">=</tt><tt class="py-name">tag_accum</tt><tt class="py-op">,</tt> </tt>
1330 <a name="L588"></a><tt class="py-lineno">588</tt>  <tt class="py-line">                                     <tt class="py-name">trailing_whitespace</tt><tt class="py-op">=</tt><tt class="py-name">trailing_whitespace</tt><tt class="py-op">)</tt> </tt>
1331 <a name="L589"></a><tt class="py-lineno">589</tt>  <tt class="py-line">                <tt class="py-name">tag_accum</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
1332 <a name="L590"></a><tt class="py-lineno">590</tt>  <tt class="py-line">                <tt class="py-name">result</tt><tt class="py-op">.</tt><tt id="link-217" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.append
1333 lxml.etree._Element.append
1334 lxml.etree._OpaqueDocumentWrapper.append
1335 lxml.etree.__ContentOnlyElement.append" class="py-name" href="#" onclick="return doclink('link-217', 'append', 'link-20');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">cur_word</tt><tt class="py-op">)</tt> </tt>
1336 <a name="L591"></a><tt class="py-lineno">591</tt>  <tt class="py-line">            <tt class="py-keyword">elif</tt> <tt class="py-name">chunk</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt> <tt class="py-op">==</tt> <tt class="py-string">'href'</tt><tt class="py-op">:</tt> </tt>
1337 <a name="L592"></a><tt class="py-lineno">592</tt>  <tt class="py-line">                <tt class="py-name">href</tt> <tt class="py-op">=</tt> <tt class="py-name">chunk</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> </tt>
1338 <a name="L593"></a><tt class="py-lineno">593</tt>  <tt class="py-line">                <tt class="py-name">cur_word</tt> <tt class="py-op">=</tt> <tt id="link-218" class="py-name" targets="Class lxml.html.diff.href_token=lxml.html.diff.href_token-class.html"><a title="lxml.html.diff.href_token" class="py-name" href="#" onclick="return doclink('link-218', 'href_token', 'link-218');">href_token</a></tt><tt class="py-op">(</tt><tt class="py-name">href</tt><tt class="py-op">,</tt> <tt class="py-name">pre_tags</tt><tt class="py-op">=</tt><tt class="py-name">tag_accum</tt><tt class="py-op">,</tt> <tt class="py-name">trailing_whitespace</tt><tt class="py-op">=</tt><tt class="py-name">True</tt><tt class="py-op">)</tt> </tt>
1339 <a name="L594"></a><tt class="py-lineno">594</tt>  <tt class="py-line">                <tt class="py-name">tag_accum</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
1340 <a name="L595"></a><tt class="py-lineno">595</tt>  <tt class="py-line">                <tt class="py-name">result</tt><tt class="py-op">.</tt><tt id="link-219" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.append
1341 lxml.etree._Element.append
1342 lxml.etree._OpaqueDocumentWrapper.append
1343 lxml.etree.__ContentOnlyElement.append" class="py-name" href="#" onclick="return doclink('link-219', 'append', 'link-20');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">cur_word</tt><tt class="py-op">)</tt> </tt>
1344 <a name="L596"></a><tt class="py-lineno">596</tt>  <tt class="py-line">            <tt class="py-keyword">continue</tt> </tt>
1345 <a name="L597"></a><tt class="py-lineno">597</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt id="link-220" class="py-name" targets="Function lxml.html.diff.is_word()=lxml.html.diff-module.html#is_word"><a title="lxml.html.diff.is_word" class="py-name" href="#" onclick="return doclink('link-220', 'is_word', 'link-220');">is_word</a></tt><tt class="py-op">(</tt><tt class="py-name">chunk</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1346 <a name="L598"></a><tt class="py-lineno">598</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">chunk</tt><tt class="py-op">.</tt><tt class="py-name">endswith</tt><tt class="py-op">(</tt><tt class="py-string">' '</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1347 <a name="L599"></a><tt class="py-lineno">599</tt>  <tt class="py-line">                <tt class="py-name">chunk</tt> <tt class="py-op">=</tt> <tt class="py-name">chunk</tt><tt class="py-op">[</tt><tt class="py-op">:</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> </tt>
1348 <a name="L600"></a><tt class="py-lineno">600</tt>  <tt class="py-line">                <tt class="py-name">trailing_whitespace</tt> <tt class="py-op">=</tt> <tt class="py-name">True</tt> </tt>
1349 <a name="L601"></a><tt class="py-lineno">601</tt>  <tt class="py-line">            <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
1350 <a name="L602"></a><tt class="py-lineno">602</tt>  <tt class="py-line">                <tt class="py-name">trailing_whitespace</tt> <tt class="py-op">=</tt> <tt class="py-name">False</tt> </tt>
1351 <a name="L603"></a><tt class="py-lineno">603</tt>  <tt class="py-line">            <tt class="py-name">cur_word</tt> <tt class="py-op">=</tt> <tt id="link-221" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-221', 'token', 'link-22');">token</a></tt><tt class="py-op">(</tt><tt class="py-name">chunk</tt><tt class="py-op">,</tt> <tt class="py-name">pre_tags</tt><tt class="py-op">=</tt><tt class="py-name">tag_accum</tt><tt class="py-op">,</tt> <tt class="py-name">trailing_whitespace</tt><tt class="py-op">=</tt><tt class="py-name">trailing_whitespace</tt><tt class="py-op">)</tt> </tt>
1352 <a name="L604"></a><tt class="py-lineno">604</tt>  <tt class="py-line">            <tt class="py-name">tag_accum</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
1353 <a name="L605"></a><tt class="py-lineno">605</tt>  <tt class="py-line">            <tt class="py-name">result</tt><tt class="py-op">.</tt><tt id="link-222" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.append
1354 lxml.etree._Element.append
1355 lxml.etree._OpaqueDocumentWrapper.append
1356 lxml.etree.__ContentOnlyElement.append" class="py-name" href="#" onclick="return doclink('link-222', 'append', 'link-20');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">cur_word</tt><tt class="py-op">)</tt> </tt>
1357 <a name="L606"></a><tt class="py-lineno">606</tt>  <tt class="py-line">        <tt class="py-keyword">elif</tt> <tt id="link-223" class="py-name" targets="Function lxml.html.diff.is_start_tag()=lxml.html.diff-module.html#is_start_tag"><a title="lxml.html.diff.is_start_tag" class="py-name" href="#" onclick="return doclink('link-223', 'is_start_tag', 'link-223');">is_start_tag</a></tt><tt class="py-op">(</tt><tt class="py-name">chunk</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1358 <a name="L607"></a><tt class="py-lineno">607</tt>  <tt class="py-line">            <tt class="py-name">tag_accum</tt><tt class="py-op">.</tt><tt id="link-224" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.append
1359 lxml.etree._Element.append
1360 lxml.etree._OpaqueDocumentWrapper.append
1361 lxml.etree.__ContentOnlyElement.append" class="py-name" href="#" onclick="return doclink('link-224', 'append', 'link-20');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">chunk</tt><tt class="py-op">)</tt> </tt>
1362 <a name="L608"></a><tt class="py-lineno">608</tt>  <tt class="py-line">        <tt class="py-keyword">elif</tt> <tt id="link-225" class="py-name" targets="Function lxml.html.diff.is_end_tag()=lxml.html.diff-module.html#is_end_tag"><a title="lxml.html.diff.is_end_tag" class="py-name" href="#" onclick="return doclink('link-225', 'is_end_tag', 'link-225');">is_end_tag</a></tt><tt class="py-op">(</tt><tt class="py-name">chunk</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1363 <a name="L609"></a><tt class="py-lineno">609</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">tag_accum</tt><tt class="py-op">:</tt> </tt>
1364 <a name="L610"></a><tt class="py-lineno">610</tt>  <tt class="py-line">                <tt class="py-name">tag_accum</tt><tt class="py-op">.</tt><tt id="link-226" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.append
1365 lxml.etree._Element.append
1366 lxml.etree._OpaqueDocumentWrapper.append
1367 lxml.etree.__ContentOnlyElement.append" class="py-name" href="#" onclick="return doclink('link-226', 'append', 'link-20');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">chunk</tt><tt class="py-op">)</tt> </tt>
1368 <a name="L611"></a><tt class="py-lineno">611</tt>  <tt class="py-line">            <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
1369 <a name="L612"></a><tt class="py-lineno">612</tt>  <tt class="py-line">                <tt class="py-keyword">assert</tt> <tt class="py-name">cur_word</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt> </tt>
1370 <a name="L613"></a><tt class="py-lineno">613</tt>  <tt class="py-line">                    <tt class="py-string">"Weird state, cur_word=%r, result=%r, chunks=%r of %r"</tt> </tt>
1371 <a name="L614"></a><tt class="py-lineno">614</tt>  <tt class="py-line">                    <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">cur_word</tt><tt class="py-op">,</tt> <tt class="py-name">result</tt><tt class="py-op">,</tt> <tt class="py-name">chunk</tt><tt class="py-op">,</tt> <tt class="py-name">chunks</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
1372 <a name="L615"></a><tt class="py-lineno">615</tt>  <tt class="py-line">                <tt class="py-name">cur_word</tt><tt class="py-op">.</tt><tt class="py-name">post_tags</tt><tt class="py-op">.</tt><tt id="link-227" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.append
1373 lxml.etree._Element.append
1374 lxml.etree._OpaqueDocumentWrapper.append
1375 lxml.etree.__ContentOnlyElement.append" class="py-name" href="#" onclick="return doclink('link-227', 'append', 'link-20');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">chunk</tt><tt class="py-op">)</tt> </tt>
1376 <a name="L616"></a><tt class="py-lineno">616</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
1377 <a name="L617"></a><tt class="py-lineno">617</tt>  <tt class="py-line">            <tt class="py-keyword">assert</tt><tt class="py-op">(</tt><tt class="py-number">0</tt><tt class="py-op">)</tt> </tt>
1378 <a name="L618"></a><tt class="py-lineno">618</tt>  <tt class="py-line"> </tt>
1379 <a name="L619"></a><tt class="py-lineno">619</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">result</tt><tt class="py-op">:</tt> </tt>
1380 <a name="L620"></a><tt class="py-lineno">620</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-op">[</tt><tt id="link-228" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-228', 'token', 'link-22');">token</a></tt><tt class="py-op">(</tt><tt class="py-string">''</tt><tt class="py-op">,</tt> <tt class="py-name">pre_tags</tt><tt class="py-op">=</tt><tt class="py-name">tag_accum</tt><tt class="py-op">)</tt><tt class="py-op">]</tt> </tt>
1381 <a name="L621"></a><tt class="py-lineno">621</tt>  <tt class="py-line">    <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
1382 <a name="L622"></a><tt class="py-lineno">622</tt>  <tt class="py-line">        <tt class="py-name">result</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt class="py-name">post_tags</tt><tt class="py-op">.</tt><tt id="link-229" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.extend
1383 lxml.etree._Element.extend
1384 lxml.etree._OpaqueDocumentWrapper.extend" class="py-name" href="#" onclick="return doclink('link-229', 'extend', 'link-50');">extend</a></tt><tt class="py-op">(</tt><tt class="py-name">tag_accum</tt><tt class="py-op">)</tt> </tt>
1385 <a name="L623"></a><tt class="py-lineno">623</tt>  <tt class="py-line"> </tt>
1386 <a name="L624"></a><tt class="py-lineno">624</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">result</tt> </tt>
1387 </div><a name="L625"></a><tt class="py-lineno">625</tt>  <tt class="py-line"> </tt>
1388 <a name="L626"></a><tt class="py-lineno">626</tt>  <tt class="py-line"> </tt>
1389 <a name="L627"></a><tt class="py-lineno">627</tt>  <tt class="py-line"><tt class="py-comment"># All the tags in HTML that don't require end tags:</tt> </tt>
1390 <a name="L628"></a><tt class="py-lineno">628</tt>  <tt class="py-line"><tt id="link-230" class="py-name"><a title="lxml.doctestcompare.LXMLOutputChecker.empty_tags
1391 lxml.html.defs.empty_tags
1392 lxml.html.diff.empty_tags" class="py-name" href="#" onclick="return doclink('link-230', 'empty_tags', 'link-93');">empty_tags</a></tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt> </tt>
1393 <a name="L629"></a><tt class="py-lineno">629</tt>  <tt class="py-line">    <tt class="py-string">'param'</tt><tt class="py-op">,</tt> <tt class="py-string">'img'</tt><tt class="py-op">,</tt> <tt class="py-string">'area'</tt><tt class="py-op">,</tt> <tt class="py-string">'br'</tt><tt class="py-op">,</tt> <tt class="py-string">'basefont'</tt><tt class="py-op">,</tt> <tt class="py-string">'input'</tt><tt class="py-op">,</tt> </tt>
1394 <a name="L630"></a><tt class="py-lineno">630</tt>  <tt class="py-line">    <tt class="py-string">'base'</tt><tt class="py-op">,</tt> <tt class="py-string">'meta'</tt><tt class="py-op">,</tt> <tt class="py-string">'link'</tt><tt class="py-op">,</tt> <tt class="py-string">'col'</tt><tt class="py-op">)</tt> </tt>
1395 <a name="L631"></a><tt class="py-lineno">631</tt>  <tt class="py-line"> </tt>
1396 <a name="L632"></a><tt class="py-lineno">632</tt>  <tt class="py-line"><tt id="link-231" class="py-name" targets="Variable lxml.html.diff.block_level_tags=lxml.html.diff-module.html#block_level_tags"><a title="lxml.html.diff.block_level_tags" class="py-name" href="#" onclick="return doclink('link-231', 'block_level_tags', 'link-231');">block_level_tags</a></tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt> </tt>
1397 <a name="L633"></a><tt class="py-lineno">633</tt>  <tt class="py-line">    <tt class="py-string">'address'</tt><tt class="py-op">,</tt> </tt>
1398 <a name="L634"></a><tt class="py-lineno">634</tt>  <tt class="py-line">    <tt class="py-string">'blockquote'</tt><tt class="py-op">,</tt> </tt>
1399 <a name="L635"></a><tt class="py-lineno">635</tt>  <tt class="py-line">    <tt class="py-string">'center'</tt><tt class="py-op">,</tt> </tt>
1400 <a name="L636"></a><tt class="py-lineno">636</tt>  <tt class="py-line">    <tt class="py-string">'dir'</tt><tt class="py-op">,</tt> </tt>
1401 <a name="L637"></a><tt class="py-lineno">637</tt>  <tt class="py-line">    <tt class="py-string">'div'</tt><tt class="py-op">,</tt> </tt>
1402 <a name="L638"></a><tt class="py-lineno">638</tt>  <tt class="py-line">    <tt class="py-string">'dl'</tt><tt class="py-op">,</tt> </tt>
1403 <a name="L639"></a><tt class="py-lineno">639</tt>  <tt class="py-line">    <tt class="py-string">'fieldset'</tt><tt class="py-op">,</tt> </tt>
1404 <a name="L640"></a><tt class="py-lineno">640</tt>  <tt class="py-line">    <tt class="py-string">'form'</tt><tt class="py-op">,</tt> </tt>
1405 <a name="L641"></a><tt class="py-lineno">641</tt>  <tt class="py-line">    <tt class="py-string">'h1'</tt><tt class="py-op">,</tt> </tt>
1406 <a name="L642"></a><tt class="py-lineno">642</tt>  <tt class="py-line">    <tt class="py-string">'h2'</tt><tt class="py-op">,</tt> </tt>
1407 <a name="L643"></a><tt class="py-lineno">643</tt>  <tt class="py-line">    <tt class="py-string">'h3'</tt><tt class="py-op">,</tt> </tt>
1408 <a name="L644"></a><tt class="py-lineno">644</tt>  <tt class="py-line">    <tt class="py-string">'h4'</tt><tt class="py-op">,</tt> </tt>
1409 <a name="L645"></a><tt class="py-lineno">645</tt>  <tt class="py-line">    <tt class="py-string">'h5'</tt><tt class="py-op">,</tt> </tt>
1410 <a name="L646"></a><tt class="py-lineno">646</tt>  <tt class="py-line">    <tt class="py-string">'h6'</tt><tt class="py-op">,</tt> </tt>
1411 <a name="L647"></a><tt class="py-lineno">647</tt>  <tt class="py-line">    <tt class="py-string">'hr'</tt><tt class="py-op">,</tt> </tt>
1412 <a name="L648"></a><tt class="py-lineno">648</tt>  <tt class="py-line">    <tt class="py-string">'isindex'</tt><tt class="py-op">,</tt> </tt>
1413 <a name="L649"></a><tt class="py-lineno">649</tt>  <tt class="py-line">    <tt class="py-string">'menu'</tt><tt class="py-op">,</tt> </tt>
1414 <a name="L650"></a><tt class="py-lineno">650</tt>  <tt class="py-line">    <tt class="py-string">'noframes'</tt><tt class="py-op">,</tt> </tt>
1415 <a name="L651"></a><tt class="py-lineno">651</tt>  <tt class="py-line">    <tt class="py-string">'noscript'</tt><tt class="py-op">,</tt> </tt>
1416 <a name="L652"></a><tt class="py-lineno">652</tt>  <tt class="py-line">    <tt class="py-string">'ol'</tt><tt class="py-op">,</tt> </tt>
1417 <a name="L653"></a><tt class="py-lineno">653</tt>  <tt class="py-line">    <tt class="py-string">'p'</tt><tt class="py-op">,</tt> </tt>
1418 <a name="L654"></a><tt class="py-lineno">654</tt>  <tt class="py-line">    <tt class="py-string">'pre'</tt><tt class="py-op">,</tt> </tt>
1419 <a name="L655"></a><tt class="py-lineno">655</tt>  <tt class="py-line">    <tt class="py-string">'table'</tt><tt class="py-op">,</tt> </tt>
1420 <a name="L656"></a><tt class="py-lineno">656</tt>  <tt class="py-line">    <tt class="py-string">'ul'</tt><tt class="py-op">,</tt> </tt>
1421 <a name="L657"></a><tt class="py-lineno">657</tt>  <tt class="py-line">    <tt class="py-op">)</tt> </tt>
1422 <a name="L658"></a><tt class="py-lineno">658</tt>  <tt class="py-line"> </tt>
1423 <a name="L659"></a><tt class="py-lineno">659</tt>  <tt class="py-line"><tt id="link-232" class="py-name" targets="Variable lxml.html.diff.block_level_container_tags=lxml.html.diff-module.html#block_level_container_tags"><a title="lxml.html.diff.block_level_container_tags" class="py-name" href="#" onclick="return doclink('link-232', 'block_level_container_tags', 'link-232');">block_level_container_tags</a></tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt> </tt>
1424 <a name="L660"></a><tt class="py-lineno">660</tt>  <tt class="py-line">    <tt class="py-string">'dd'</tt><tt class="py-op">,</tt> </tt>
1425 <a name="L661"></a><tt class="py-lineno">661</tt>  <tt class="py-line">    <tt class="py-string">'dt'</tt><tt class="py-op">,</tt> </tt>
1426 <a name="L662"></a><tt class="py-lineno">662</tt>  <tt class="py-line">    <tt class="py-string">'frameset'</tt><tt class="py-op">,</tt> </tt>
1427 <a name="L663"></a><tt class="py-lineno">663</tt>  <tt class="py-line">    <tt class="py-string">'li'</tt><tt class="py-op">,</tt> </tt>
1428 <a name="L664"></a><tt class="py-lineno">664</tt>  <tt class="py-line">    <tt class="py-string">'tbody'</tt><tt class="py-op">,</tt> </tt>
1429 <a name="L665"></a><tt class="py-lineno">665</tt>  <tt class="py-line">    <tt class="py-string">'td'</tt><tt class="py-op">,</tt> </tt>
1430 <a name="L666"></a><tt class="py-lineno">666</tt>  <tt class="py-line">    <tt class="py-string">'tfoot'</tt><tt class="py-op">,</tt> </tt>
1431 <a name="L667"></a><tt class="py-lineno">667</tt>  <tt class="py-line">    <tt class="py-string">'th'</tt><tt class="py-op">,</tt> </tt>
1432 <a name="L668"></a><tt class="py-lineno">668</tt>  <tt class="py-line">    <tt class="py-string">'thead'</tt><tt class="py-op">,</tt> </tt>
1433 <a name="L669"></a><tt class="py-lineno">669</tt>  <tt class="py-line">    <tt class="py-string">'tr'</tt><tt class="py-op">,</tt> </tt>
1434 <a name="L670"></a><tt class="py-lineno">670</tt>  <tt class="py-line">    <tt class="py-op">)</tt> </tt>
1435 <a name="L671"></a><tt class="py-lineno">671</tt>  <tt class="py-line"> </tt>
1436 <a name="L672"></a><tt class="py-lineno">672</tt>  <tt class="py-line"> </tt>
1437 <a name="flatten_el"></a><div id="flatten_el-def"><a name="L673"></a><tt class="py-lineno">673</tt> <a class="py-toggle" href="#" id="flatten_el-toggle" onclick="return toggle('flatten_el');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#flatten_el">flatten_el</a><tt class="py-op">(</tt><tt class="py-param">el</tt><tt class="py-op">,</tt> <tt class="py-param">include_hrefs</tt><tt class="py-op">,</tt> <tt class="py-param">skip_tag</tt><tt class="py-op">=</tt><tt class="py-name">False</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1438 </div><div id="flatten_el-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="flatten_el-expanded"><a name="L674"></a><tt class="py-lineno">674</tt>  <tt class="py-line">    <tt class="py-docstring">""" Takes an lxml element el, and generates all the text chunks for</tt> </tt>
1439 <a name="L675"></a><tt class="py-lineno">675</tt>  <tt class="py-line"><tt class="py-docstring">    that tag.  Each start tag is a chunk, each word is a chunk, and each</tt> </tt>
1440 <a name="L676"></a><tt class="py-lineno">676</tt>  <tt class="py-line"><tt class="py-docstring">    end tag is a chunk.</tt> </tt>
1441 <a name="L677"></a><tt class="py-lineno">677</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
1442 <a name="L678"></a><tt class="py-lineno">678</tt>  <tt class="py-line"><tt class="py-docstring">    If skip_tag is true, then the outermost container tag is</tt> </tt>
1443 <a name="L679"></a><tt class="py-lineno">679</tt>  <tt class="py-line"><tt class="py-docstring">    not returned (just its contents)."""</tt> </tt>
1444 <a name="L680"></a><tt class="py-lineno">680</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">skip_tag</tt><tt class="py-op">:</tt> </tt>
1445 <a name="L681"></a><tt class="py-lineno">681</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-233" class="py-name"><a title="lxml.etree._Comment.tag
1446 lxml.etree._Element.tag
1447 lxml.etree._Entity.tag
1448 lxml.etree._ProcessingInstruction.tag
1449 lxml.etree._ReadOnlyProxy.tag
1450 lxml.tests.test_xpathevaluator.tag
1451 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-233', 'tag', 'link-98');">tag</a></tt> <tt class="py-op">==</tt> <tt class="py-string">'img'</tt><tt class="py-op">:</tt> </tt>
1452 <a name="L682"></a><tt class="py-lineno">682</tt>  <tt class="py-line">            <tt class="py-keyword">yield</tt> <tt class="py-op">(</tt><tt class="py-string">'img'</tt><tt class="py-op">,</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-234" class="py-name" targets="Method lxml.etree._Attrib.get()=lxml.etree._Attrib-class.html#get,Method lxml.etree._Element.get()=lxml.etree._Element-class.html#get,Method lxml.etree._IDDict.get()=lxml.etree._IDDict-class.html#get,Method lxml.etree._ProcessingInstruction.get()=lxml.etree._ProcessingInstruction-class.html#get,Method lxml.etree._ReadOnlyElementProxy.get()=lxml.etree._ReadOnlyElementProxy-class.html#get,Method lxml.etree.__ContentOnlyElement.get()=lxml.etree.__ContentOnlyElement-class.html#get"><a title="lxml.etree._Attrib.get
1453 lxml.etree._Element.get
1454 lxml.etree._IDDict.get
1455 lxml.etree._ProcessingInstruction.get
1456 lxml.etree._ReadOnlyElementProxy.get
1457 lxml.etree.__ContentOnlyElement.get" class="py-name" href="#" onclick="return doclink('link-234', 'get', 'link-234');">get</a></tt><tt class="py-op">(</tt><tt class="py-string">'src'</tt><tt class="py-op">)</tt><tt class="py-op">,</tt> <tt id="link-235" class="py-name" targets="Function lxml.html.diff.start_tag()=lxml.html.diff-module.html#start_tag"><a title="lxml.html.diff.start_tag" class="py-name" href="#" onclick="return doclink('link-235', 'start_tag', 'link-235');">start_tag</a></tt><tt class="py-op">(</tt><tt class="py-name">el</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
1458 <a name="L683"></a><tt class="py-lineno">683</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
1459 <a name="L684"></a><tt class="py-lineno">684</tt>  <tt class="py-line">            <tt class="py-keyword">yield</tt> <tt id="link-236" class="py-name"><a title="lxml.html.diff.start_tag" class="py-name" href="#" onclick="return doclink('link-236', 'start_tag', 'link-235');">start_tag</a></tt><tt class="py-op">(</tt><tt class="py-name">el</tt><tt class="py-op">)</tt> </tt>
1460 <a name="L685"></a><tt class="py-lineno">685</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-237" class="py-name"><a title="lxml.etree._Comment.tag
1461 lxml.etree._Element.tag
1462 lxml.etree._Entity.tag
1463 lxml.etree._ProcessingInstruction.tag
1464 lxml.etree._ReadOnlyProxy.tag
1465 lxml.tests.test_xpathevaluator.tag
1466 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-237', 'tag', 'link-98');">tag</a></tt> <tt class="py-keyword">in</tt> <tt id="link-238" class="py-name"><a title="lxml.doctestcompare.LXMLOutputChecker.empty_tags
1467 lxml.html.defs.empty_tags
1468 lxml.html.diff.empty_tags" class="py-name" href="#" onclick="return doclink('link-238', 'empty_tags', 'link-93');">empty_tags</a></tt> <tt class="py-keyword">and</tt> <tt class="py-keyword">not</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-239" class="py-name"><a title="lxml.etree.QName.text
1469 lxml.etree._AppendOnlyElementProxy.text
1470 lxml.etree._Element.text
1471 lxml.etree._Entity.text
1472 lxml.etree._ModifyContentOnlyProxy.text
1473 lxml.etree._ReadOnlyEntityProxy.text
1474 lxml.etree._ReadOnlyProxy.text
1475 lxml.etree.__ContentOnlyElement.text
1476 lxml.objectify.ObjectifiedElement.text
1477 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-239', 'text', 'link-6');">text</a></tt> <tt class="py-keyword">and</tt> <tt class="py-keyword">not</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">el</tt><tt class="py-op">)</tt> <tt class="py-keyword">and</tt> <tt class="py-keyword">not</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-240" class="py-name" targets="Variable lxml.etree._Element.tail=lxml.etree._Element-class.html#tail,Variable lxml.etree._ReadOnlyProxy.tail=lxml.etree._ReadOnlyProxy-class.html#tail,Variable xml.etree.ElementTree.Element.tail=xml.etree.ElementTree.Element-class.html#tail"><a title="lxml.etree._Element.tail
1478 lxml.etree._ReadOnlyProxy.tail
1479 xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-240', 'tail', 'link-240');">tail</a></tt><tt class="py-op">:</tt> </tt>
1480 <a name="L686"></a><tt class="py-lineno">686</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> </tt>
1481 <a name="L687"></a><tt class="py-lineno">687</tt>  <tt class="py-line">    <tt class="py-name">start_words</tt> <tt class="py-op">=</tt> <tt id="link-241" class="py-name" targets="Function lxml.html.diff.split_words()=lxml.html.diff-module.html#split_words"><a title="lxml.html.diff.split_words" class="py-name" href="#" onclick="return doclink('link-241', 'split_words', 'link-241');">split_words</a></tt><tt class="py-op">(</tt><tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-242" class="py-name"><a title="lxml.etree.QName.text
1482 lxml.etree._AppendOnlyElementProxy.text
1483 lxml.etree._Element.text
1484 lxml.etree._Entity.text
1485 lxml.etree._ModifyContentOnlyProxy.text
1486 lxml.etree._ReadOnlyEntityProxy.text
1487 lxml.etree._ReadOnlyProxy.text
1488 lxml.etree.__ContentOnlyElement.text
1489 lxml.objectify.ObjectifiedElement.text
1490 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-242', 'text', 'link-6');">text</a></tt><tt class="py-op">)</tt> </tt>
1491 <a name="L688"></a><tt class="py-lineno">688</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt class="py-name">word</tt> <tt class="py-keyword">in</tt> <tt class="py-name">start_words</tt><tt class="py-op">:</tt> </tt>
1492 <a name="L689"></a><tt class="py-lineno">689</tt>  <tt class="py-line">        <tt class="py-keyword">yield</tt> <tt class="py-name">cgi</tt><tt class="py-op">.</tt><tt class="py-name">escape</tt><tt class="py-op">(</tt><tt class="py-name">word</tt><tt class="py-op">)</tt> </tt>
1493 <a name="L690"></a><tt class="py-lineno">690</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt class="py-name">child</tt> <tt class="py-keyword">in</tt> <tt class="py-name">el</tt><tt class="py-op">:</tt> </tt>
1494 <a name="L691"></a><tt class="py-lineno">691</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt class="py-name">item</tt> <tt class="py-keyword">in</tt> <tt id="link-243" class="py-name"><a title="lxml.html.diff.flatten_el" class="py-name" href="#" onclick="return doclink('link-243', 'flatten_el', 'link-174');">flatten_el</a></tt><tt class="py-op">(</tt><tt class="py-name">child</tt><tt class="py-op">,</tt> <tt class="py-name">include_hrefs</tt><tt class="py-op">=</tt><tt class="py-name">include_hrefs</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1495 <a name="L692"></a><tt class="py-lineno">692</tt>  <tt class="py-line">            <tt class="py-keyword">yield</tt> <tt class="py-name">item</tt> </tt>
1496 <a name="L693"></a><tt class="py-lineno">693</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-244" class="py-name"><a title="lxml.etree._Comment.tag
1497 lxml.etree._Element.tag
1498 lxml.etree._Entity.tag
1499 lxml.etree._ProcessingInstruction.tag
1500 lxml.etree._ReadOnlyProxy.tag
1501 lxml.tests.test_xpathevaluator.tag
1502 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-244', 'tag', 'link-98');">tag</a></tt> <tt class="py-op">==</tt> <tt class="py-string">'a'</tt> <tt class="py-keyword">and</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-245" class="py-name"><a title="lxml.etree._Attrib.get
1503 lxml.etree._Element.get
1504 lxml.etree._IDDict.get
1505 lxml.etree._ProcessingInstruction.get
1506 lxml.etree._ReadOnlyElementProxy.get
1507 lxml.etree.__ContentOnlyElement.get" class="py-name" href="#" onclick="return doclink('link-245', 'get', 'link-234');">get</a></tt><tt class="py-op">(</tt><tt class="py-string">'href'</tt><tt class="py-op">)</tt> <tt class="py-keyword">and</tt> <tt class="py-name">include_hrefs</tt><tt class="py-op">:</tt> </tt>
1508 <a name="L694"></a><tt class="py-lineno">694</tt>  <tt class="py-line">        <tt class="py-keyword">yield</tt> <tt class="py-op">(</tt><tt class="py-string">'href'</tt><tt class="py-op">,</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-246" class="py-name"><a title="lxml.etree._Attrib.get
1509 lxml.etree._Element.get
1510 lxml.etree._IDDict.get
1511 lxml.etree._ProcessingInstruction.get
1512 lxml.etree._ReadOnlyElementProxy.get
1513 lxml.etree.__ContentOnlyElement.get" class="py-name" href="#" onclick="return doclink('link-246', 'get', 'link-234');">get</a></tt><tt class="py-op">(</tt><tt class="py-string">'href'</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
1514 <a name="L695"></a><tt class="py-lineno">695</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">skip_tag</tt><tt class="py-op">:</tt> </tt>
1515 <a name="L696"></a><tt class="py-lineno">696</tt>  <tt class="py-line">        <tt class="py-keyword">yield</tt> <tt id="link-247" class="py-name" targets="Function lxml.html.diff.end_tag()=lxml.html.diff-module.html#end_tag"><a title="lxml.html.diff.end_tag" class="py-name" href="#" onclick="return doclink('link-247', 'end_tag', 'link-247');">end_tag</a></tt><tt class="py-op">(</tt><tt class="py-name">el</tt><tt class="py-op">)</tt> </tt>
1516 <a name="L697"></a><tt class="py-lineno">697</tt>  <tt class="py-line">        <tt class="py-name">end_words</tt> <tt class="py-op">=</tt> <tt id="link-248" class="py-name"><a title="lxml.html.diff.split_words" class="py-name" href="#" onclick="return doclink('link-248', 'split_words', 'link-241');">split_words</a></tt><tt class="py-op">(</tt><tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-249" class="py-name"><a title="lxml.etree._Element.tail
1517 lxml.etree._ReadOnlyProxy.tail
1518 xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-249', 'tail', 'link-240');">tail</a></tt><tt class="py-op">)</tt> </tt>
1519 <a name="L698"></a><tt class="py-lineno">698</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt class="py-name">word</tt> <tt class="py-keyword">in</tt> <tt class="py-name">end_words</tt><tt class="py-op">:</tt> </tt>
1520 <a name="L699"></a><tt class="py-lineno">699</tt>  <tt class="py-line">            <tt class="py-keyword">yield</tt> <tt class="py-name">cgi</tt><tt class="py-op">.</tt><tt class="py-name">escape</tt><tt class="py-op">(</tt><tt class="py-name">word</tt><tt class="py-op">)</tt> </tt>
1521 </div><a name="L700"></a><tt class="py-lineno">700</tt>  <tt class="py-line"> </tt>
1522 <a name="split_words"></a><div id="split_words-def"><a name="L701"></a><tt class="py-lineno">701</tt> <a class="py-toggle" href="#" id="split_words-toggle" onclick="return toggle('split_words');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#split_words">split_words</a><tt class="py-op">(</tt><tt class="py-param">text</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1523 </div><div id="split_words-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="split_words-expanded"><a name="L702"></a><tt class="py-lineno">702</tt>  <tt class="py-line">    <tt class="py-docstring">""" Splits some text into words. Includes trailing whitespace (one</tt> </tt>
1524 <a name="L703"></a><tt class="py-lineno">703</tt>  <tt class="py-line"><tt class="py-docstring">    space) on each word when appropriate.  """</tt> </tt>
1525 <a name="L704"></a><tt class="py-lineno">704</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt id="link-250" class="py-name"><a title="lxml.etree.QName.text
1526 lxml.etree._AppendOnlyElementProxy.text
1527 lxml.etree._Element.text
1528 lxml.etree._Entity.text
1529 lxml.etree._ModifyContentOnlyProxy.text
1530 lxml.etree._ReadOnlyEntityProxy.text
1531 lxml.etree._ReadOnlyProxy.text
1532 lxml.etree.__ContentOnlyElement.text
1533 lxml.objectify.ObjectifiedElement.text
1534 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-250', 'text', 'link-6');">text</a></tt> <tt class="py-keyword">or</tt> <tt class="py-keyword">not</tt> <tt id="link-251" class="py-name"><a title="lxml.etree.QName.text
1535 lxml.etree._AppendOnlyElementProxy.text
1536 lxml.etree._Element.text
1537 lxml.etree._Entity.text
1538 lxml.etree._ModifyContentOnlyProxy.text
1539 lxml.etree._ReadOnlyEntityProxy.text
1540 lxml.etree._ReadOnlyProxy.text
1541 lxml.etree.__ContentOnlyElement.text
1542 lxml.objectify.ObjectifiedElement.text
1543 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-251', 'text', 'link-6');">text</a></tt><tt class="py-op">.</tt><tt id="link-252" class="py-name"><a title="lxml.doctestcompare.strip" class="py-name" href="#" onclick="return doclink('link-252', 'strip', 'link-15');">strip</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1544 <a name="L705"></a><tt class="py-lineno">705</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
1545 <a name="L706"></a><tt class="py-lineno">706</tt>  <tt class="py-line">    <tt class="py-name">words</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-name">w</tt> <tt class="py-op">+</tt> <tt class="py-string">' '</tt> <tt class="py-keyword">for</tt> <tt class="py-name">w</tt> <tt class="py-keyword">in</tt> <tt id="link-253" class="py-name"><a title="lxml.etree.QName.text
1546 lxml.etree._AppendOnlyElementProxy.text
1547 lxml.etree._Element.text
1548 lxml.etree._Entity.text
1549 lxml.etree._ModifyContentOnlyProxy.text
1550 lxml.etree._ReadOnlyEntityProxy.text
1551 lxml.etree._ReadOnlyProxy.text
1552 lxml.etree.__ContentOnlyElement.text
1553 lxml.objectify.ObjectifiedElement.text
1554 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-253', 'text', 'link-6');">text</a></tt><tt class="py-op">.</tt><tt id="link-254" class="py-name"><a title="lxml.doctestcompare.strip" class="py-name" href="#" onclick="return doclink('link-254', 'strip', 'link-15');">strip</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">.</tt><tt class="py-name">split</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">]</tt> </tt>
1555 <a name="L707"></a><tt class="py-lineno">707</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt id="link-255" class="py-name"><a title="lxml.html.diff.end_whitespace_re" class="py-name" href="#" onclick="return doclink('link-255', 'end_whitespace_re', 'link-210');">end_whitespace_re</a></tt><tt class="py-op">.</tt><tt class="py-name">search</tt><tt class="py-op">(</tt><tt id="link-256" class="py-name"><a title="lxml.etree.QName.text
1556 lxml.etree._AppendOnlyElementProxy.text
1557 lxml.etree._Element.text
1558 lxml.etree._Entity.text
1559 lxml.etree._ModifyContentOnlyProxy.text
1560 lxml.etree._ReadOnlyEntityProxy.text
1561 lxml.etree._ReadOnlyProxy.text
1562 lxml.etree.__ContentOnlyElement.text
1563 lxml.objectify.ObjectifiedElement.text
1564 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-256', 'text', 'link-6');">text</a></tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1565 <a name="L708"></a><tt class="py-lineno">708</tt>  <tt class="py-line">        <tt class="py-name">words</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-name">words</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">[</tt><tt class="py-op">:</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> </tt>
1566 <a name="L709"></a><tt class="py-lineno">709</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">words</tt> </tt>
1567 </div><a name="L710"></a><tt class="py-lineno">710</tt>  <tt class="py-line"> </tt>
1568 <a name="L711"></a><tt class="py-lineno">711</tt>  <tt class="py-line"><tt id="link-257" class="py-name" targets="Variable lxml.html.diff.start_whitespace_re=lxml.html.diff-module.html#start_whitespace_re"><a title="lxml.html.diff.start_whitespace_re" class="py-name" href="#" onclick="return doclink('link-257', 'start_whitespace_re', 'link-257');">start_whitespace_re</a></tt> <tt class="py-op">=</tt> <tt class="py-name">re</tt><tt class="py-op">.</tt><tt class="py-name">compile</tt><tt class="py-op">(</tt><tt class="py-string">r'^[ \t\n\r]'</tt><tt class="py-op">)</tt> </tt>
1569 <a name="L712"></a><tt class="py-lineno">712</tt>  <tt class="py-line"> </tt>
1570 <a name="start_tag"></a><div id="start_tag-def"><a name="L713"></a><tt class="py-lineno">713</tt> <a class="py-toggle" href="#" id="start_tag-toggle" onclick="return toggle('start_tag');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#start_tag">start_tag</a><tt class="py-op">(</tt><tt class="py-param">el</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1571 </div><div id="start_tag-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="start_tag-expanded"><a name="L714"></a><tt class="py-lineno">714</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
1572 <a name="L715"></a><tt class="py-lineno">715</tt>  <tt class="py-line"><tt class="py-docstring">    The text representation of the start tag for a tag.</tt> </tt>
1573 <a name="L716"></a><tt class="py-lineno">716</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
1574 <a name="L717"></a><tt class="py-lineno">717</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-string">'&lt;%s%s&gt;'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt> </tt>
1575 <a name="L718"></a><tt class="py-lineno">718</tt>  <tt class="py-line">        <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-258" class="py-name"><a title="lxml.etree._Comment.tag
1576 lxml.etree._Element.tag
1577 lxml.etree._Entity.tag
1578 lxml.etree._ProcessingInstruction.tag
1579 lxml.etree._ReadOnlyProxy.tag
1580 lxml.tests.test_xpathevaluator.tag
1581 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-258', 'tag', 'link-98');">tag</a></tt><tt class="py-op">,</tt> <tt class="py-string">''</tt><tt class="py-op">.</tt><tt id="link-259" class="py-name"><a title="lxml.cssselect.XPathExpr.join" class="py-name" href="#" onclick="return doclink('link-259', 'join', 'link-14');">join</a></tt><tt class="py-op">(</tt><tt class="py-op">[</tt><tt class="py-string">' %s="%s"'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt id="link-260" class="py-name"><a title="lxml.etree._Entity.name
1582 lxml.etree._ModifyContentOnlyEntityProxy.name
1583 lxml.etree._ReadOnlyEntityProxy.name
1584 lxml.html.InputMixin.name
1585 lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-260', 'name', 'link-90');">name</a></tt><tt class="py-op">,</tt> <tt class="py-name">cgi</tt><tt class="py-op">.</tt><tt class="py-name">escape</tt><tt class="py-op">(</tt><tt id="link-261" class="py-name" targets="Variable lxml.html.CheckboxGroup.value=lxml.html.CheckboxGroup-class.html#value,Variable lxml.html.InputElement.value=lxml.html.InputElement-class.html#value,Variable lxml.html.RadioGroup.value=lxml.html.RadioGroup-class.html#value,Variable lxml.html.SelectElement.value=lxml.html.SelectElement-class.html#value,Variable lxml.html.TextareaElement.value=lxml.html.TextareaElement-class.html#value"><a title="lxml.html.CheckboxGroup.value
1586 lxml.html.InputElement.value
1587 lxml.html.RadioGroup.value
1588 lxml.html.SelectElement.value
1589 lxml.html.TextareaElement.value" class="py-name" href="#" onclick="return doclink('link-261', 'value', 'link-261');">value</a></tt><tt class="py-op">,</tt> <tt class="py-name">True</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
1590 <a name="L719"></a><tt class="py-lineno">719</tt>  <tt class="py-line">                         <tt class="py-keyword">for</tt> <tt id="link-262" class="py-name"><a title="lxml.etree._Entity.name
1591 lxml.etree._ModifyContentOnlyEntityProxy.name
1592 lxml.etree._ReadOnlyEntityProxy.name
1593 lxml.html.InputMixin.name
1594 lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-262', 'name', 'link-90');">name</a></tt><tt class="py-op">,</tt> <tt id="link-263" class="py-name"><a title="lxml.html.CheckboxGroup.value
1595 lxml.html.InputElement.value
1596 lxml.html.RadioGroup.value
1597 lxml.html.SelectElement.value
1598 lxml.html.TextareaElement.value" class="py-name" href="#" onclick="return doclink('link-263', 'value', 'link-261');">value</a></tt> <tt class="py-keyword">in</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-264" class="py-name" targets="Variable lxml.etree._Element.attrib=lxml.etree._Element-class.html#attrib,Variable lxml.etree._ProcessingInstruction.attrib=lxml.etree._ProcessingInstruction-class.html#attrib,Variable lxml.etree._ReadOnlyElementProxy.attrib=lxml.etree._ReadOnlyElementProxy-class.html#attrib,Variable lxml.etree.__ContentOnlyElement.attrib=lxml.etree.__ContentOnlyElement-class.html#attrib,Variable xml.etree.ElementTree.Element.attrib=xml.etree.ElementTree.Element-class.html#attrib"><a title="lxml.etree._Element.attrib
1599 lxml.etree._ProcessingInstruction.attrib
1600 lxml.etree._ReadOnlyElementProxy.attrib
1601 lxml.etree.__ContentOnlyElement.attrib
1602 xml.etree.ElementTree.Element.attrib" class="py-name" href="#" onclick="return doclink('link-264', 'attrib', 'link-264');">attrib</a></tt><tt class="py-op">.</tt><tt id="link-265" class="py-name" targets="Method lxml.etree._Attrib.items()=lxml.etree._Attrib-class.html#items,Method lxml.etree._Element.items()=lxml.etree._Element-class.html#items,Method lxml.etree._IDDict.items()=lxml.etree._IDDict-class.html#items,Method lxml.etree._NamespaceRegistry.items()=lxml.etree._NamespaceRegistry-class.html#items,Method lxml.etree._ReadOnlyElementProxy.items()=lxml.etree._ReadOnlyElementProxy-class.html#items,Method lxml.etree.__ContentOnlyElement.items()=lxml.etree.__ContentOnlyElement-class.html#items"><a title="lxml.etree._Attrib.items
1603 lxml.etree._Element.items
1604 lxml.etree._IDDict.items
1605 lxml.etree._NamespaceRegistry.items
1606 lxml.etree._ReadOnlyElementProxy.items
1607 lxml.etree.__ContentOnlyElement.items" class="py-name" href="#" onclick="return doclink('link-265', 'items', 'link-265');">items</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">]</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
1608 </div><a name="L720"></a><tt class="py-lineno">720</tt>  <tt class="py-line"> </tt>
1609 <a name="end_tag"></a><div id="end_tag-def"><a name="L721"></a><tt class="py-lineno">721</tt> <a class="py-toggle" href="#" id="end_tag-toggle" onclick="return toggle('end_tag');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#end_tag">end_tag</a><tt class="py-op">(</tt><tt class="py-param">el</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1610 </div><div id="end_tag-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="end_tag-expanded"><a name="L722"></a><tt class="py-lineno">722</tt>  <tt class="py-line">    <tt class="py-docstring">""" The text representation of an end tag for a tag.  Includes</tt> </tt>
1611 <a name="L723"></a><tt class="py-lineno">723</tt>  <tt class="py-line"><tt class="py-docstring">    trailing whitespace when appropriate.  """</tt> </tt>
1612 <a name="L724"></a><tt class="py-lineno">724</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-266" class="py-name"><a title="lxml.etree._Element.tail
1613 lxml.etree._ReadOnlyProxy.tail
1614 xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-266', 'tail', 'link-240');">tail</a></tt> <tt class="py-keyword">and</tt> <tt id="link-267" class="py-name"><a title="lxml.html.diff.start_whitespace_re" class="py-name" href="#" onclick="return doclink('link-267', 'start_whitespace_re', 'link-257');">start_whitespace_re</a></tt><tt class="py-op">.</tt><tt class="py-name">search</tt><tt class="py-op">(</tt><tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-268" class="py-name"><a title="lxml.etree._Element.tail
1615 lxml.etree._ReadOnlyProxy.tail
1616 xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-268', 'tail', 'link-240');">tail</a></tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1617 <a name="L725"></a><tt class="py-lineno">725</tt>  <tt class="py-line">        <tt class="py-name">extra</tt> <tt class="py-op">=</tt> <tt class="py-string">' '</tt> </tt>
1618 <a name="L726"></a><tt class="py-lineno">726</tt>  <tt class="py-line">    <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
1619 <a name="L727"></a><tt class="py-lineno">727</tt>  <tt class="py-line">        <tt class="py-name">extra</tt> <tt class="py-op">=</tt> <tt class="py-string">''</tt> </tt>
1620 <a name="L728"></a><tt class="py-lineno">728</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-string">'&lt;/%s&gt;%s'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-269" class="py-name"><a title="lxml.etree._Comment.tag
1621 lxml.etree._Element.tag
1622 lxml.etree._Entity.tag
1623 lxml.etree._ProcessingInstruction.tag
1624 lxml.etree._ReadOnlyProxy.tag
1625 lxml.tests.test_xpathevaluator.tag
1626 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-269', 'tag', 'link-98');">tag</a></tt><tt class="py-op">,</tt> <tt class="py-name">extra</tt><tt class="py-op">)</tt> </tt>
1627 </div><a name="L729"></a><tt class="py-lineno">729</tt>  <tt class="py-line"> </tt>
1628 <a name="is_word"></a><div id="is_word-def"><a name="L730"></a><tt class="py-lineno">730</tt> <a class="py-toggle" href="#" id="is_word-toggle" onclick="return toggle('is_word');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#is_word">is_word</a><tt class="py-op">(</tt><tt class="py-param">tok</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1629 </div><div id="is_word-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="is_word-expanded"><a name="L731"></a><tt class="py-lineno">731</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-keyword">not</tt> <tt class="py-name">tok</tt><tt class="py-op">.</tt><tt class="py-name">startswith</tt><tt class="py-op">(</tt><tt class="py-string">'&lt;'</tt><tt class="py-op">)</tt> </tt>
1630 </div><a name="L732"></a><tt class="py-lineno">732</tt>  <tt class="py-line"> </tt>
1631 <a name="is_end_tag"></a><div id="is_end_tag-def"><a name="L733"></a><tt class="py-lineno">733</tt> <a class="py-toggle" href="#" id="is_end_tag-toggle" onclick="return toggle('is_end_tag');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#is_end_tag">is_end_tag</a><tt class="py-op">(</tt><tt class="py-param">tok</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1632 </div><div id="is_end_tag-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="is_end_tag-expanded"><a name="L734"></a><tt class="py-lineno">734</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">tok</tt><tt class="py-op">.</tt><tt class="py-name">startswith</tt><tt class="py-op">(</tt><tt class="py-string">'&lt;/'</tt><tt class="py-op">)</tt> </tt>
1633 </div><a name="L735"></a><tt class="py-lineno">735</tt>  <tt class="py-line"> </tt>
1634 <a name="is_start_tag"></a><div id="is_start_tag-def"><a name="L736"></a><tt class="py-lineno">736</tt> <a class="py-toggle" href="#" id="is_start_tag-toggle" onclick="return toggle('is_start_tag');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#is_start_tag">is_start_tag</a><tt class="py-op">(</tt><tt class="py-param">tok</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1635 </div><div id="is_start_tag-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="is_start_tag-expanded"><a name="L737"></a><tt class="py-lineno">737</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">tok</tt><tt class="py-op">.</tt><tt class="py-name">startswith</tt><tt class="py-op">(</tt><tt class="py-string">'&lt;'</tt><tt class="py-op">)</tt> <tt class="py-keyword">and</tt> <tt class="py-keyword">not</tt> <tt class="py-name">tok</tt><tt class="py-op">.</tt><tt class="py-name">startswith</tt><tt class="py-op">(</tt><tt class="py-string">'&lt;/'</tt><tt class="py-op">)</tt> </tt>
1636 </div><a name="L738"></a><tt class="py-lineno">738</tt>  <tt class="py-line"> </tt>
1637 <a name="fixup_ins_del_tags"></a><div id="fixup_ins_del_tags-def"><a name="L739"></a><tt class="py-lineno">739</tt> <a class="py-toggle" href="#" id="fixup_ins_del_tags-toggle" onclick="return toggle('fixup_ins_del_tags');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#fixup_ins_del_tags">fixup_ins_del_tags</a><tt class="py-op">(</tt><tt class="py-param">html</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1638 </div><div id="fixup_ins_del_tags-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="fixup_ins_del_tags-expanded"><a name="L740"></a><tt class="py-lineno">740</tt>  <tt class="py-line">    <tt class="py-docstring">""" Given an html string, move any &lt;ins&gt; or &lt;del&gt; tags inside of any</tt> </tt>
1639 <a name="L741"></a><tt class="py-lineno">741</tt>  <tt class="py-line"><tt class="py-docstring">    block-level elements, e.g. transform &lt;ins&gt;&lt;p&gt;word&lt;/p&gt;&lt;/ins&gt; to</tt> </tt>
1640 <a name="L742"></a><tt class="py-lineno">742</tt>  <tt class="py-line"><tt class="py-docstring">    &lt;p&gt;&lt;ins&gt;word&lt;/ins&gt;&lt;/p&gt; """</tt> </tt>
1641 <a name="L743"></a><tt class="py-lineno">743</tt>  <tt class="py-line">    <tt class="py-name">doc</tt> <tt class="py-op">=</tt> <tt id="link-270" class="py-name"><a title="lxml.html.diff.parse_html" class="py-name" href="#" onclick="return doclink('link-270', 'parse_html', 'link-172');">parse_html</a></tt><tt class="py-op">(</tt><tt id="link-271" class="py-name"><a title="lxml.html
1642 lxml.html.diff.href_token.html
1643 lxml.html.diff.tag_token.html
1644 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-271', 'html', 'link-3');">html</a></tt><tt class="py-op">,</tt> <tt class="py-name">cleanup</tt><tt class="py-op">=</tt><tt class="py-name">False</tt><tt class="py-op">)</tt> </tt>
1645 <a name="L744"></a><tt class="py-lineno">744</tt>  <tt class="py-line">    <tt id="link-272" class="py-name" targets="Function lxml.html.diff._fixup_ins_del_tags()=lxml.html.diff-module.html#_fixup_ins_del_tags"><a title="lxml.html.diff._fixup_ins_del_tags" class="py-name" href="#" onclick="return doclink('link-272', '_fixup_ins_del_tags', 'link-272');">_fixup_ins_del_tags</a></tt><tt class="py-op">(</tt><tt class="py-name">doc</tt><tt class="py-op">)</tt> </tt>
1646 <a name="L745"></a><tt class="py-lineno">745</tt>  <tt class="py-line">    <tt id="link-273" class="py-name"><a title="lxml.html
1647 lxml.html.diff.href_token.html
1648 lxml.html.diff.tag_token.html
1649 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-273', 'html', 'link-3');">html</a></tt> <tt class="py-op">=</tt> <tt id="link-274" class="py-name" targets="Function lxml.html.diff.serialize_html_fragment()=lxml.html.diff-module.html#serialize_html_fragment"><a title="lxml.html.diff.serialize_html_fragment" class="py-name" href="#" onclick="return doclink('link-274', 'serialize_html_fragment', 'link-274');">serialize_html_fragment</a></tt><tt class="py-op">(</tt><tt class="py-name">doc</tt><tt class="py-op">,</tt> <tt class="py-name">skip_outer</tt><tt class="py-op">=</tt><tt class="py-name">True</tt><tt class="py-op">)</tt> </tt>
1650 <a name="L746"></a><tt class="py-lineno">746</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt id="link-275" class="py-name"><a title="lxml.html
1651 lxml.html.diff.href_token.html
1652 lxml.html.diff.tag_token.html
1653 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-275', 'html', 'link-3');">html</a></tt> </tt>
1654 </div><a name="L747"></a><tt class="py-lineno">747</tt>  <tt class="py-line"> </tt>
1655 <a name="serialize_html_fragment"></a><div id="serialize_html_fragment-def"><a name="L748"></a><tt class="py-lineno">748</tt> <a class="py-toggle" href="#" id="serialize_html_fragment-toggle" onclick="return toggle('serialize_html_fragment');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#serialize_html_fragment">serialize_html_fragment</a><tt class="py-op">(</tt><tt class="py-param">el</tt><tt class="py-op">,</tt> <tt class="py-param">skip_outer</tt><tt class="py-op">=</tt><tt class="py-name">False</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1656 </div><div id="serialize_html_fragment-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="serialize_html_fragment-expanded"><a name="L749"></a><tt class="py-lineno">749</tt>  <tt class="py-line">    <tt class="py-docstring">""" Serialize a single lxml element as HTML.  The serialized form</tt> </tt>
1657 <a name="L750"></a><tt class="py-lineno">750</tt>  <tt class="py-line"><tt class="py-docstring">    includes the elements tail.  </tt> </tt>
1658 <a name="L751"></a><tt class="py-lineno">751</tt>  <tt class="py-line"><tt class="py-docstring"></tt> </tt>
1659 <a name="L752"></a><tt class="py-lineno">752</tt>  <tt class="py-line"><tt class="py-docstring">    If skip_outer is true, then don't serialize the outermost tag</tt> </tt>
1660 <a name="L753"></a><tt class="py-lineno">753</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
1661 <a name="L754"></a><tt class="py-lineno">754</tt>  <tt class="py-line">    <tt class="py-keyword">assert</tt> <tt class="py-keyword">not</tt> <tt class="py-name">isinstance</tt><tt class="py-op">(</tt><tt class="py-name">el</tt><tt class="py-op">,</tt> <tt class="py-name">basestring</tt><tt class="py-op">)</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt> </tt>
1662 <a name="L755"></a><tt class="py-lineno">755</tt>  <tt class="py-line">        <tt class="py-string">"You should pass in an element, not a string like %r"</tt> <tt class="py-op">%</tt> <tt class="py-name">el</tt><tt class="py-op">)</tt> </tt>
1663 <a name="L756"></a><tt class="py-lineno">756</tt>  <tt class="py-line">    <tt id="link-276" class="py-name"><a title="lxml.html
1664 lxml.html.diff.href_token.html
1665 lxml.html.diff.tag_token.html
1666 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-276', 'html', 'link-3');">html</a></tt> <tt class="py-op">=</tt> <tt id="link-277" class="py-name"><a title="lxml.etree
1667 lxml.sax.ElementTreeContentHandler.etree
1668 lxml.tests.test_elementtree.CElementTreeTestCase.etree
1669 lxml.tests.test_elementtree.ETreeTestCaseBase.etree
1670 lxml.tests.test_io.IOTestCaseBase.etree" class="py-name" href="#" onclick="return doclink('link-277', 'etree', 'link-1');">etree</a></tt><tt class="py-op">.</tt><tt id="link-278" class="py-name" targets="Method lxml.etree.XSLT.tostring()=lxml.etree.XSLT-class.html#tostring,Function lxml.etree.tostring()=lxml.etree-module.html#tostring,Function lxml.html.tostring()=lxml.html-module.html#tostring"><a title="lxml.etree.XSLT.tostring
1671 lxml.etree.tostring
1672 lxml.html.tostring" class="py-name" href="#" onclick="return doclink('link-278', 'tostring', 'link-278');">tostring</a></tt><tt class="py-op">(</tt><tt class="py-name">el</tt><tt class="py-op">,</tt> <tt id="link-279" class="py-name" targets="Variable lxml.html.FormElement.method=lxml.html.FormElement-class.html#method"><a title="lxml.html.FormElement.method" class="py-name" href="#" onclick="return doclink('link-279', 'method', 'link-279');">method</a></tt><tt class="py-op">=</tt><tt class="py-string">"html"</tt><tt class="py-op">,</tt> <tt id="link-280" class="py-name" targets="Variable lxml.etree.DocInfo.encoding=lxml.etree.DocInfo-class.html#encoding"><a title="lxml.etree.DocInfo.encoding" class="py-name" href="#" onclick="return doclink('link-280', 'encoding', 'link-280');">encoding</a></tt><tt class="py-op">=</tt><tt class="py-name">_unicode</tt><tt class="py-op">)</tt> </tt>
1673 <a name="L757"></a><tt class="py-lineno">757</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">skip_outer</tt><tt class="py-op">:</tt> </tt>
1674 <a name="L758"></a><tt class="py-lineno">758</tt>  <tt class="py-line">        <tt class="py-comment"># Get rid of the extra starting tag:</tt> </tt>
1675 <a name="L759"></a><tt class="py-lineno">759</tt>  <tt class="py-line">        <tt id="link-281" class="py-name"><a title="lxml.html
1676 lxml.html.diff.href_token.html
1677 lxml.html.diff.tag_token.html
1678 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-281', 'html', 'link-3');">html</a></tt> <tt class="py-op">=</tt> <tt id="link-282" class="py-name"><a title="lxml.html
1679 lxml.html.diff.href_token.html
1680 lxml.html.diff.tag_token.html
1681 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-282', 'html', 'link-3');">html</a></tt><tt class="py-op">[</tt><tt id="link-283" class="py-name"><a title="lxml.html
1682 lxml.html.diff.href_token.html
1683 lxml.html.diff.tag_token.html
1684 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-283', 'html', 'link-3');">html</a></tt><tt class="py-op">.</tt><tt id="link-284" class="py-name" targets="Method lxml.etree._Element.find()=lxml.etree._Element-class.html#find,Method lxml.etree._ElementTree.find()=lxml.etree._ElementTree-class.html#find,Variable lxml.objectify.ObjectPath.find=lxml.objectify.ObjectPath-class.html#find,Method lxml.objectify.ObjectifiedElement.find()=lxml.objectify.ObjectifiedElement-class.html#find"><a title="lxml.etree._Element.find
1685 lxml.etree._ElementTree.find
1686 lxml.objectify.ObjectPath.find
1687 lxml.objectify.ObjectifiedElement.find" class="py-name" href="#" onclick="return doclink('link-284', 'find', 'link-284');">find</a></tt><tt class="py-op">(</tt><tt class="py-string">'&gt;'</tt><tt class="py-op">)</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">:</tt><tt class="py-op">]</tt> </tt>
1688 <a name="L760"></a><tt class="py-lineno">760</tt>  <tt class="py-line">        <tt class="py-comment"># Get rid of the extra end tag:</tt> </tt>
1689 <a name="L761"></a><tt class="py-lineno">761</tt>  <tt class="py-line">        <tt id="link-285" class="py-name"><a title="lxml.html
1690 lxml.html.diff.href_token.html
1691 lxml.html.diff.tag_token.html
1692 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-285', 'html', 'link-3');">html</a></tt> <tt class="py-op">=</tt> <tt id="link-286" class="py-name"><a title="lxml.html
1693 lxml.html.diff.href_token.html
1694 lxml.html.diff.tag_token.html
1695 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-286', 'html', 'link-3');">html</a></tt><tt class="py-op">[</tt><tt class="py-op">:</tt><tt id="link-287" class="py-name"><a title="lxml.html
1696 lxml.html.diff.href_token.html
1697 lxml.html.diff.tag_token.html
1698 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-287', 'html', 'link-3');">html</a></tt><tt class="py-op">.</tt><tt class="py-name">rfind</tt><tt class="py-op">(</tt><tt class="py-string">'&lt;'</tt><tt class="py-op">)</tt><tt class="py-op">]</tt> </tt>
1699 <a name="L762"></a><tt class="py-lineno">762</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt id="link-288" class="py-name"><a title="lxml.html
1700 lxml.html.diff.href_token.html
1701 lxml.html.diff.tag_token.html
1702 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-288', 'html', 'link-3');">html</a></tt><tt class="py-op">.</tt><tt id="link-289" class="py-name"><a title="lxml.doctestcompare.strip" class="py-name" href="#" onclick="return doclink('link-289', 'strip', 'link-15');">strip</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
1703 <a name="L763"></a><tt class="py-lineno">763</tt>  <tt class="py-line">    <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
1704 <a name="L764"></a><tt class="py-lineno">764</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt id="link-290" class="py-name"><a title="lxml.html
1705 lxml.html.diff.href_token.html
1706 lxml.html.diff.tag_token.html
1707 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-290', 'html', 'link-3');">html</a></tt> </tt>
1708 </div><a name="L765"></a><tt class="py-lineno">765</tt>  <tt class="py-line"> </tt>
1709 <a name="_fixup_ins_del_tags"></a><div id="_fixup_ins_del_tags-def"><a name="L766"></a><tt class="py-lineno">766</tt> <a class="py-toggle" href="#" id="_fixup_ins_del_tags-toggle" onclick="return toggle('_fixup_ins_del_tags');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#_fixup_ins_del_tags">_fixup_ins_del_tags</a><tt class="py-op">(</tt><tt class="py-param">doc</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1710 </div><div id="_fixup_ins_del_tags-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="_fixup_ins_del_tags-expanded"><a name="L767"></a><tt class="py-lineno">767</tt>  <tt class="py-line">    <tt class="py-docstring">"""fixup_ins_del_tags that works on an lxml document in-place</tt> </tt>
1711 <a name="L768"></a><tt class="py-lineno">768</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
1712 <a name="L769"></a><tt class="py-lineno">769</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt id="link-291" class="py-name"><a title="lxml.etree._Comment.tag
1713 lxml.etree._Element.tag
1714 lxml.etree._Entity.tag
1715 lxml.etree._ProcessingInstruction.tag
1716 lxml.etree._ReadOnlyProxy.tag
1717 lxml.tests.test_xpathevaluator.tag
1718 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-291', 'tag', 'link-98');">tag</a></tt> <tt class="py-keyword">in</tt> <tt class="py-op">[</tt><tt class="py-string">'ins'</tt><tt class="py-op">,</tt> <tt class="py-string">'del'</tt><tt class="py-op">]</tt><tt class="py-op">:</tt> </tt>
1719 <a name="L770"></a><tt class="py-lineno">770</tt>  <tt class="py-line">        <tt class="py-keyword">for</tt> <tt class="py-name">el</tt> <tt class="py-keyword">in</tt> <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt id="link-292" class="py-name" targets="Method lxml.cssselect.Attrib.xpath()=lxml.cssselect.Attrib-class.html#xpath,Method lxml.cssselect.Class.xpath()=lxml.cssselect.Class-class.html#xpath,Method lxml.cssselect.CombinedSelector.xpath()=lxml.cssselect.CombinedSelector-class.html#xpath,Method lxml.cssselect.Element.xpath()=lxml.cssselect.Element-class.html#xpath,Method lxml.cssselect.Function.xpath()=lxml.cssselect.Function-class.html#xpath,Method lxml.cssselect.Hash.xpath()=lxml.cssselect.Hash-class.html#xpath,Method lxml.cssselect.Or.xpath()=lxml.cssselect.Or-class.html#xpath,Method lxml.cssselect.Pseudo.xpath()=lxml.cssselect.Pseudo-class.html#xpath,Method lxml.etree._Element.xpath()=lxml.etree._Element-class.html#xpath,Method lxml.etree._ElementTree.xpath()=lxml.etree._ElementTree-class.html#xpath,Function lxml.tests.test_xpathevaluator.xpath()=lxml.tests.test_xpathevaluator-module.html#xpath"><a title="lxml.cssselect.Attrib.xpath
1720 lxml.cssselect.Class.xpath
1721 lxml.cssselect.CombinedSelector.xpath
1722 lxml.cssselect.Element.xpath
1723 lxml.cssselect.Function.xpath
1724 lxml.cssselect.Hash.xpath
1725 lxml.cssselect.Or.xpath
1726 lxml.cssselect.Pseudo.xpath
1727 lxml.etree._Element.xpath
1728 lxml.etree._ElementTree.xpath
1729 lxml.tests.test_xpathevaluator.xpath" class="py-name" href="#" onclick="return doclink('link-292', 'xpath', 'link-292');">xpath</a></tt><tt class="py-op">(</tt><tt class="py-string">'descendant-or-self::%s'</tt> <tt class="py-op">%</tt> <tt id="link-293" class="py-name"><a title="lxml.etree._Comment.tag
1730 lxml.etree._Element.tag
1731 lxml.etree._Entity.tag
1732 lxml.etree._ProcessingInstruction.tag
1733 lxml.etree._ReadOnlyProxy.tag
1734 lxml.tests.test_xpathevaluator.tag
1735 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-293', 'tag', 'link-98');">tag</a></tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1736 <a name="L771"></a><tt class="py-lineno">771</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt id="link-294" class="py-name" targets="Function lxml.html._contains_block_level_tag()=lxml.html-module.html#_contains_block_level_tag,Function lxml.html.diff._contains_block_level_tag()=lxml.html.diff-module.html#_contains_block_level_tag"><a title="lxml.html._contains_block_level_tag
1737 lxml.html.diff._contains_block_level_tag" class="py-name" href="#" onclick="return doclink('link-294', '_contains_block_level_tag', 'link-294');">_contains_block_level_tag</a></tt><tt class="py-op">(</tt><tt class="py-name">el</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1738 <a name="L772"></a><tt class="py-lineno">772</tt>  <tt class="py-line">                <tt class="py-keyword">continue</tt> </tt>
1739 <a name="L773"></a><tt class="py-lineno">773</tt>  <tt class="py-line">            <tt id="link-295" class="py-name" targets="Function lxml.html.diff._move_el_inside_block()=lxml.html.diff-module.html#_move_el_inside_block"><a title="lxml.html.diff._move_el_inside_block" class="py-name" href="#" onclick="return doclink('link-295', '_move_el_inside_block', 'link-295');">_move_el_inside_block</a></tt><tt class="py-op">(</tt><tt class="py-name">el</tt><tt class="py-op">,</tt> <tt id="link-296" class="py-name"><a title="lxml.etree._Comment.tag
1740 lxml.etree._Element.tag
1741 lxml.etree._Entity.tag
1742 lxml.etree._ProcessingInstruction.tag
1743 lxml.etree._ReadOnlyProxy.tag
1744 lxml.tests.test_xpathevaluator.tag
1745 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-296', 'tag', 'link-98');">tag</a></tt><tt class="py-op">=</tt><tt id="link-297" class="py-name"><a title="lxml.etree._Comment.tag
1746 lxml.etree._Element.tag
1747 lxml.etree._Entity.tag
1748 lxml.etree._ProcessingInstruction.tag
1749 lxml.etree._ReadOnlyProxy.tag
1750 lxml.tests.test_xpathevaluator.tag
1751 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-297', 'tag', 'link-98');">tag</a></tt><tt class="py-op">)</tt> </tt>
1752 <a name="L774"></a><tt class="py-lineno">774</tt>  <tt class="py-line">            <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-298" class="py-name" targets="Method lxml.html.HtmlMixin.drop_tag()=lxml.html.HtmlMixin-class.html#drop_tag"><a title="lxml.html.HtmlMixin.drop_tag" class="py-name" href="#" onclick="return doclink('link-298', 'drop_tag', 'link-298');">drop_tag</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
1753 </div><a name="L775"></a><tt class="py-lineno">775</tt>  <tt class="py-line">            <tt class="py-comment">#_merge_element_contents(el)</tt> </tt>
1754 <a name="L776"></a><tt class="py-lineno">776</tt>  <tt class="py-line"> </tt>
1755 <a name="_contains_block_level_tag"></a><div id="_contains_block_level_tag-def"><a name="L777"></a><tt class="py-lineno">777</tt> <a class="py-toggle" href="#" id="_contains_block_level_tag-toggle" onclick="return toggle('_contains_block_level_tag');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#_contains_block_level_tag">_contains_block_level_tag</a><tt class="py-op">(</tt><tt class="py-param">el</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1756 </div><div id="_contains_block_level_tag-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="_contains_block_level_tag-expanded"><a name="L778"></a><tt class="py-lineno">778</tt>  <tt class="py-line">    <tt class="py-docstring">"""True if the element contains any block-level elements, like &lt;p&gt;, &lt;td&gt;, etc.</tt> </tt>
1757 <a name="L779"></a><tt class="py-lineno">779</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
1758 <a name="L780"></a><tt class="py-lineno">780</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-299" class="py-name"><a title="lxml.etree._Comment.tag
1759 lxml.etree._Element.tag
1760 lxml.etree._Entity.tag
1761 lxml.etree._ProcessingInstruction.tag
1762 lxml.etree._ReadOnlyProxy.tag
1763 lxml.tests.test_xpathevaluator.tag
1764 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-299', 'tag', 'link-98');">tag</a></tt> <tt class="py-keyword">in</tt> <tt id="link-300" class="py-name"><a title="lxml.html.diff.block_level_tags" class="py-name" href="#" onclick="return doclink('link-300', 'block_level_tags', 'link-231');">block_level_tags</a></tt> <tt class="py-keyword">or</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-301" class="py-name"><a title="lxml.etree._Comment.tag
1765 lxml.etree._Element.tag
1766 lxml.etree._Entity.tag
1767 lxml.etree._ProcessingInstruction.tag
1768 lxml.etree._ReadOnlyProxy.tag
1769 lxml.tests.test_xpathevaluator.tag
1770 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-301', 'tag', 'link-98');">tag</a></tt> <tt class="py-keyword">in</tt> <tt id="link-302" class="py-name"><a title="lxml.html.diff.block_level_container_tags" class="py-name" href="#" onclick="return doclink('link-302', 'block_level_container_tags', 'link-232');">block_level_container_tags</a></tt><tt class="py-op">:</tt> </tt>
1771 <a name="L781"></a><tt class="py-lineno">781</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-name">True</tt> </tt>
1772 <a name="L782"></a><tt class="py-lineno">782</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt class="py-name">child</tt> <tt class="py-keyword">in</tt> <tt class="py-name">el</tt><tt class="py-op">:</tt> </tt>
1773 <a name="L783"></a><tt class="py-lineno">783</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt id="link-303" class="py-name"><a title="lxml.html._contains_block_level_tag
1774 lxml.html.diff._contains_block_level_tag" class="py-name" href="#" onclick="return doclink('link-303', '_contains_block_level_tag', 'link-294');">_contains_block_level_tag</a></tt><tt class="py-op">(</tt><tt class="py-name">child</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1775 <a name="L784"></a><tt class="py-lineno">784</tt>  <tt class="py-line">            <tt class="py-keyword">return</tt> <tt class="py-name">True</tt> </tt>
1776 <a name="L785"></a><tt class="py-lineno">785</tt>  <tt class="py-line">    <tt class="py-keyword">return</tt> <tt class="py-name">False</tt> </tt>
1777 </div><a name="L786"></a><tt class="py-lineno">786</tt>  <tt class="py-line"> </tt>
1778 <a name="_move_el_inside_block"></a><div id="_move_el_inside_block-def"><a name="L787"></a><tt class="py-lineno">787</tt> <a class="py-toggle" href="#" id="_move_el_inside_block-toggle" onclick="return toggle('_move_el_inside_block');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#_move_el_inside_block">_move_el_inside_block</a><tt class="py-op">(</tt><tt class="py-param">el</tt><tt class="py-op">,</tt> <tt class="py-param">tag</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1779 </div><div id="_move_el_inside_block-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="_move_el_inside_block-expanded"><a name="L788"></a><tt class="py-lineno">788</tt>  <tt class="py-line">    <tt class="py-docstring">""" helper for _fixup_ins_del_tags; actually takes the &lt;ins&gt; etc tags</tt> </tt>
1780 <a name="L789"></a><tt class="py-lineno">789</tt>  <tt class="py-line"><tt class="py-docstring">    and moves them inside any block-level tags.  """</tt> </tt>
1781 <a name="L790"></a><tt class="py-lineno">790</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt class="py-name">child</tt> <tt class="py-keyword">in</tt> <tt class="py-name">el</tt><tt class="py-op">:</tt> </tt>
1782 <a name="L791"></a><tt class="py-lineno">791</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt id="link-304" class="py-name"><a title="lxml.html._contains_block_level_tag
1783 lxml.html.diff._contains_block_level_tag" class="py-name" href="#" onclick="return doclink('link-304', '_contains_block_level_tag', 'link-294');">_contains_block_level_tag</a></tt><tt class="py-op">(</tt><tt class="py-name">child</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1784 <a name="L792"></a><tt class="py-lineno">792</tt>  <tt class="py-line">            <tt class="py-keyword">break</tt> </tt>
1785 <a name="L793"></a><tt class="py-lineno">793</tt>  <tt class="py-line">    <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
1786 <a name="L794"></a><tt class="py-lineno">794</tt>  <tt class="py-line">        <tt class="py-keyword">import</tt> <tt class="py-name">sys</tt> </tt>
1787 <a name="L795"></a><tt class="py-lineno">795</tt>  <tt class="py-line">        <tt class="py-comment"># No block-level tags in any child</tt> </tt>
1788 <a name="L796"></a><tt class="py-lineno">796</tt>  <tt class="py-line">        <tt class="py-name">children_tag</tt> <tt class="py-op">=</tt> <tt id="link-305" class="py-name"><a title="lxml.etree
1789 lxml.sax.ElementTreeContentHandler.etree
1790 lxml.tests.test_elementtree.CElementTreeTestCase.etree
1791 lxml.tests.test_elementtree.ETreeTestCaseBase.etree
1792 lxml.tests.test_io.IOTestCaseBase.etree" class="py-name" href="#" onclick="return doclink('link-305', 'etree', 'link-1');">etree</a></tt><tt class="py-op">.</tt><tt id="link-306" class="py-name" targets="Class lxml.cssselect.Element=lxml.cssselect.Element-class.html,Function lxml.etree.Element()=lxml.etree-module.html#Element,Function lxml.html.Element()=lxml.html-module.html#Element,Function lxml.objectify.Element()=lxml.objectify-module.html#Element,Method lxml.tests.test_pyclasslookup.PyClassLookupTestCase.Element()=lxml.tests.test_pyclasslookup.PyClassLookupTestCase-class.html#Element,Class xml.etree.ElementTree.Element=xml.etree.ElementTree.Element-class.html"><a title="lxml.cssselect.Element
1793 lxml.etree.Element
1794 lxml.html.Element
1795 lxml.objectify.Element
1796 lxml.tests.test_pyclasslookup.PyClassLookupTestCase.Element
1797 xml.etree.ElementTree.Element" class="py-name" href="#" onclick="return doclink('link-306', 'Element', 'link-306');">Element</a></tt><tt class="py-op">(</tt><tt id="link-307" class="py-name"><a title="lxml.etree._Comment.tag
1798 lxml.etree._Element.tag
1799 lxml.etree._Entity.tag
1800 lxml.etree._ProcessingInstruction.tag
1801 lxml.etree._ReadOnlyProxy.tag
1802 lxml.tests.test_xpathevaluator.tag
1803 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-307', 'tag', 'link-98');">tag</a></tt><tt class="py-op">)</tt> </tt>
1804 <a name="L797"></a><tt class="py-lineno">797</tt>  <tt class="py-line">        <tt class="py-name">children_tag</tt><tt class="py-op">.</tt><tt id="link-308" class="py-name"><a title="lxml.etree.QName.text
1805 lxml.etree._AppendOnlyElementProxy.text
1806 lxml.etree._Element.text
1807 lxml.etree._Entity.text
1808 lxml.etree._ModifyContentOnlyProxy.text
1809 lxml.etree._ReadOnlyEntityProxy.text
1810 lxml.etree._ReadOnlyProxy.text
1811 lxml.etree.__ContentOnlyElement.text
1812 lxml.objectify.ObjectifiedElement.text
1813 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-308', 'text', 'link-6');">text</a></tt> <tt class="py-op">=</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-309" class="py-name"><a title="lxml.etree.QName.text
1814 lxml.etree._AppendOnlyElementProxy.text
1815 lxml.etree._Element.text
1816 lxml.etree._Entity.text
1817 lxml.etree._ModifyContentOnlyProxy.text
1818 lxml.etree._ReadOnlyEntityProxy.text
1819 lxml.etree._ReadOnlyProxy.text
1820 lxml.etree.__ContentOnlyElement.text
1821 lxml.objectify.ObjectifiedElement.text
1822 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-309', 'text', 'link-6');">text</a></tt> </tt>
1823 <a name="L798"></a><tt class="py-lineno">798</tt>  <tt class="py-line">        <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-310" class="py-name"><a title="lxml.etree.QName.text
1824 lxml.etree._AppendOnlyElementProxy.text
1825 lxml.etree._Element.text
1826 lxml.etree._Entity.text
1827 lxml.etree._ModifyContentOnlyProxy.text
1828 lxml.etree._ReadOnlyEntityProxy.text
1829 lxml.etree._ReadOnlyProxy.text
1830 lxml.etree.__ContentOnlyElement.text
1831 lxml.objectify.ObjectifiedElement.text
1832 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-310', 'text', 'link-6');">text</a></tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt> </tt>
1833 <a name="L799"></a><tt class="py-lineno">799</tt>  <tt class="py-line">        <tt class="py-name">children_tag</tt><tt class="py-op">.</tt><tt id="link-311" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.extend
1834 lxml.etree._Element.extend
1835 lxml.etree._OpaqueDocumentWrapper.extend" class="py-name" href="#" onclick="return doclink('link-311', 'extend', 'link-50');">extend</a></tt><tt class="py-op">(</tt><tt class="py-name">list</tt><tt class="py-op">(</tt><tt class="py-name">el</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
1836 <a name="L800"></a><tt class="py-lineno">800</tt>  <tt class="py-line">        <tt class="py-name">el</tt><tt class="py-op">[</tt><tt class="py-op">:</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-name">children_tag</tt><tt class="py-op">]</tt> </tt>
1837 <a name="L801"></a><tt class="py-lineno">801</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> </tt>
1838 <a name="L802"></a><tt class="py-lineno">802</tt>  <tt class="py-line">    <tt class="py-keyword">for</tt> <tt class="py-name">child</tt> <tt class="py-keyword">in</tt> <tt class="py-name">list</tt><tt class="py-op">(</tt><tt class="py-name">el</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1839 <a name="L803"></a><tt class="py-lineno">803</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt id="link-312" class="py-name"><a title="lxml.html._contains_block_level_tag
1840 lxml.html.diff._contains_block_level_tag" class="py-name" href="#" onclick="return doclink('link-312', '_contains_block_level_tag', 'link-294');">_contains_block_level_tag</a></tt><tt class="py-op">(</tt><tt class="py-name">child</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1841 <a name="L804"></a><tt class="py-lineno">804</tt>  <tt class="py-line">            <tt id="link-313" class="py-name"><a title="lxml.html.diff._move_el_inside_block" class="py-name" href="#" onclick="return doclink('link-313', '_move_el_inside_block', 'link-295');">_move_el_inside_block</a></tt><tt class="py-op">(</tt><tt class="py-name">child</tt><tt class="py-op">,</tt> <tt id="link-314" class="py-name"><a title="lxml.etree._Comment.tag
1842 lxml.etree._Element.tag
1843 lxml.etree._Entity.tag
1844 lxml.etree._ProcessingInstruction.tag
1845 lxml.etree._ReadOnlyProxy.tag
1846 lxml.tests.test_xpathevaluator.tag
1847 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-314', 'tag', 'link-98');">tag</a></tt><tt class="py-op">)</tt> </tt>
1848 <a name="L805"></a><tt class="py-lineno">805</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">child</tt><tt class="py-op">.</tt><tt id="link-315" class="py-name"><a title="lxml.etree._Element.tail
1849 lxml.etree._ReadOnlyProxy.tail
1850 xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-315', 'tail', 'link-240');">tail</a></tt><tt class="py-op">:</tt> </tt>
1851 <a name="L806"></a><tt class="py-lineno">806</tt>  <tt class="py-line">                <tt class="py-name">tail_tag</tt> <tt class="py-op">=</tt> <tt id="link-316" class="py-name"><a title="lxml.etree
1852 lxml.sax.ElementTreeContentHandler.etree
1853 lxml.tests.test_elementtree.CElementTreeTestCase.etree
1854 lxml.tests.test_elementtree.ETreeTestCaseBase.etree
1855 lxml.tests.test_io.IOTestCaseBase.etree" class="py-name" href="#" onclick="return doclink('link-316', 'etree', 'link-1');">etree</a></tt><tt class="py-op">.</tt><tt id="link-317" class="py-name"><a title="lxml.cssselect.Element
1856 lxml.etree.Element
1857 lxml.html.Element
1858 lxml.objectify.Element
1859 lxml.tests.test_pyclasslookup.PyClassLookupTestCase.Element
1860 xml.etree.ElementTree.Element" class="py-name" href="#" onclick="return doclink('link-317', 'Element', 'link-306');">Element</a></tt><tt class="py-op">(</tt><tt id="link-318" class="py-name"><a title="lxml.etree._Comment.tag
1861 lxml.etree._Element.tag
1862 lxml.etree._Entity.tag
1863 lxml.etree._ProcessingInstruction.tag
1864 lxml.etree._ReadOnlyProxy.tag
1865 lxml.tests.test_xpathevaluator.tag
1866 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-318', 'tag', 'link-98');">tag</a></tt><tt class="py-op">)</tt> </tt>
1867 <a name="L807"></a><tt class="py-lineno">807</tt>  <tt class="py-line">                <tt class="py-name">tail_tag</tt><tt class="py-op">.</tt><tt id="link-319" class="py-name"><a title="lxml.etree.QName.text
1868 lxml.etree._AppendOnlyElementProxy.text
1869 lxml.etree._Element.text
1870 lxml.etree._Entity.text
1871 lxml.etree._ModifyContentOnlyProxy.text
1872 lxml.etree._ReadOnlyEntityProxy.text
1873 lxml.etree._ReadOnlyProxy.text
1874 lxml.etree.__ContentOnlyElement.text
1875 lxml.objectify.ObjectifiedElement.text
1876 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-319', 'text', 'link-6');">text</a></tt> <tt class="py-op">=</tt> <tt class="py-name">child</tt><tt class="py-op">.</tt><tt id="link-320" class="py-name"><a title="lxml.etree._Element.tail
1877 lxml.etree._ReadOnlyProxy.tail
1878 xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-320', 'tail', 'link-240');">tail</a></tt> </tt>
1879 <a name="L808"></a><tt class="py-lineno">808</tt>  <tt class="py-line">                <tt class="py-name">child</tt><tt class="py-op">.</tt><tt id="link-321" class="py-name"><a title="lxml.etree._Element.tail
1880 lxml.etree._ReadOnlyProxy.tail
1881 xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-321', 'tail', 'link-240');">tail</a></tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt> </tt>
1882 <a name="L809"></a><tt class="py-lineno">809</tt>  <tt class="py-line">                <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-322" class="py-name"><a title="lxml.etree._Element.insert
1883 lxml.etree.__ContentOnlyElement.insert" class="py-name" href="#" onclick="return doclink('link-322', 'insert', 'link-151');">insert</a></tt><tt class="py-op">(</tt><tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-323" class="py-name"><a title="lxml.etree._Element.index" class="py-name" href="#" onclick="return doclink('link-323', 'index', 'link-118');">index</a></tt><tt class="py-op">(</tt><tt class="py-name">child</tt><tt class="py-op">)</tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">,</tt> <tt class="py-name">tail_tag</tt><tt class="py-op">)</tt> </tt>
1884 <a name="L810"></a><tt class="py-lineno">810</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
1885 <a name="L811"></a><tt class="py-lineno">811</tt>  <tt class="py-line">            <tt class="py-name">child_tag</tt> <tt class="py-op">=</tt> <tt id="link-324" class="py-name"><a title="lxml.etree
1886 lxml.sax.ElementTreeContentHandler.etree
1887 lxml.tests.test_elementtree.CElementTreeTestCase.etree
1888 lxml.tests.test_elementtree.ETreeTestCaseBase.etree
1889 lxml.tests.test_io.IOTestCaseBase.etree" class="py-name" href="#" onclick="return doclink('link-324', 'etree', 'link-1');">etree</a></tt><tt class="py-op">.</tt><tt id="link-325" class="py-name"><a title="lxml.cssselect.Element
1890 lxml.etree.Element
1891 lxml.html.Element
1892 lxml.objectify.Element
1893 lxml.tests.test_pyclasslookup.PyClassLookupTestCase.Element
1894 xml.etree.ElementTree.Element" class="py-name" href="#" onclick="return doclink('link-325', 'Element', 'link-306');">Element</a></tt><tt class="py-op">(</tt><tt id="link-326" class="py-name"><a title="lxml.etree._Comment.tag
1895 lxml.etree._Element.tag
1896 lxml.etree._Entity.tag
1897 lxml.etree._ProcessingInstruction.tag
1898 lxml.etree._ReadOnlyProxy.tag
1899 lxml.tests.test_xpathevaluator.tag
1900 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-326', 'tag', 'link-98');">tag</a></tt><tt class="py-op">)</tt> </tt>
1901 <a name="L812"></a><tt class="py-lineno">812</tt>  <tt class="py-line">            <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-327" class="py-name" targets="Method lxml.etree._Element.replace()=lxml.etree._Element-class.html#replace,Method lxml.etree._ExsltRegExp.replace()=lxml.etree._ExsltRegExp-class.html#replace"><a title="lxml.etree._Element.replace
1902 lxml.etree._ExsltRegExp.replace" class="py-name" href="#" onclick="return doclink('link-327', 'replace', 'link-327');">replace</a></tt><tt class="py-op">(</tt><tt class="py-name">child</tt><tt class="py-op">,</tt> <tt class="py-name">child_tag</tt><tt class="py-op">)</tt> </tt>
1903 <a name="L813"></a><tt class="py-lineno">813</tt>  <tt class="py-line">            <tt class="py-name">child_tag</tt><tt class="py-op">.</tt><tt id="link-328" class="py-name"><a title="lxml.etree._AppendOnlyElementProxy.append
1904 lxml.etree._Element.append
1905 lxml.etree._OpaqueDocumentWrapper.append
1906 lxml.etree.__ContentOnlyElement.append" class="py-name" href="#" onclick="return doclink('link-328', 'append', 'link-20');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">child</tt><tt class="py-op">)</tt> </tt>
1907 <a name="L814"></a><tt class="py-lineno">814</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-329" class="py-name"><a title="lxml.etree.QName.text
1908 lxml.etree._AppendOnlyElementProxy.text
1909 lxml.etree._Element.text
1910 lxml.etree._Entity.text
1911 lxml.etree._ModifyContentOnlyProxy.text
1912 lxml.etree._ReadOnlyEntityProxy.text
1913 lxml.etree._ReadOnlyProxy.text
1914 lxml.etree.__ContentOnlyElement.text
1915 lxml.objectify.ObjectifiedElement.text
1916 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-329', 'text', 'link-6');">text</a></tt><tt class="py-op">:</tt> </tt>
1917 <a name="L815"></a><tt class="py-lineno">815</tt>  <tt class="py-line">        <tt class="py-name">text_tag</tt> <tt class="py-op">=</tt> <tt id="link-330" class="py-name"><a title="lxml.etree
1918 lxml.sax.ElementTreeContentHandler.etree
1919 lxml.tests.test_elementtree.CElementTreeTestCase.etree
1920 lxml.tests.test_elementtree.ETreeTestCaseBase.etree
1921 lxml.tests.test_io.IOTestCaseBase.etree" class="py-name" href="#" onclick="return doclink('link-330', 'etree', 'link-1');">etree</a></tt><tt class="py-op">.</tt><tt id="link-331" class="py-name"><a title="lxml.cssselect.Element
1922 lxml.etree.Element
1923 lxml.html.Element
1924 lxml.objectify.Element
1925 lxml.tests.test_pyclasslookup.PyClassLookupTestCase.Element
1926 xml.etree.ElementTree.Element" class="py-name" href="#" onclick="return doclink('link-331', 'Element', 'link-306');">Element</a></tt><tt class="py-op">(</tt><tt id="link-332" class="py-name"><a title="lxml.etree._Comment.tag
1927 lxml.etree._Element.tag
1928 lxml.etree._Entity.tag
1929 lxml.etree._ProcessingInstruction.tag
1930 lxml.etree._ReadOnlyProxy.tag
1931 lxml.tests.test_xpathevaluator.tag
1932 xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-332', 'tag', 'link-98');">tag</a></tt><tt class="py-op">)</tt> </tt>
1933 <a name="L816"></a><tt class="py-lineno">816</tt>  <tt class="py-line">        <tt class="py-name">text_tag</tt><tt class="py-op">.</tt><tt id="link-333" class="py-name"><a title="lxml.etree.QName.text
1934 lxml.etree._AppendOnlyElementProxy.text
1935 lxml.etree._Element.text
1936 lxml.etree._Entity.text
1937 lxml.etree._ModifyContentOnlyProxy.text
1938 lxml.etree._ReadOnlyEntityProxy.text
1939 lxml.etree._ReadOnlyProxy.text
1940 lxml.etree.__ContentOnlyElement.text
1941 lxml.objectify.ObjectifiedElement.text
1942 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-333', 'text', 'link-6');">text</a></tt> <tt class="py-op">=</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-334" class="py-name"><a title="lxml.etree.QName.text
1943 lxml.etree._AppendOnlyElementProxy.text
1944 lxml.etree._Element.text
1945 lxml.etree._Entity.text
1946 lxml.etree._ModifyContentOnlyProxy.text
1947 lxml.etree._ReadOnlyEntityProxy.text
1948 lxml.etree._ReadOnlyProxy.text
1949 lxml.etree.__ContentOnlyElement.text
1950 lxml.objectify.ObjectifiedElement.text
1951 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-334', 'text', 'link-6');">text</a></tt> </tt>
1952 <a name="L817"></a><tt class="py-lineno">817</tt>  <tt class="py-line">        <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-335" class="py-name"><a title="lxml.etree.QName.text
1953 lxml.etree._AppendOnlyElementProxy.text
1954 lxml.etree._Element.text
1955 lxml.etree._Entity.text
1956 lxml.etree._ModifyContentOnlyProxy.text
1957 lxml.etree._ReadOnlyEntityProxy.text
1958 lxml.etree._ReadOnlyProxy.text
1959 lxml.etree.__ContentOnlyElement.text
1960 lxml.objectify.ObjectifiedElement.text
1961 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-335', 'text', 'link-6');">text</a></tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt> </tt>
1962 <a name="L818"></a><tt class="py-lineno">818</tt>  <tt class="py-line">        <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-336" class="py-name"><a title="lxml.etree._Element.insert
1963 lxml.etree.__ContentOnlyElement.insert" class="py-name" href="#" onclick="return doclink('link-336', 'insert', 'link-151');">insert</a></tt><tt class="py-op">(</tt><tt class="py-number">0</tt><tt class="py-op">,</tt> <tt class="py-name">text_tag</tt><tt class="py-op">)</tt> </tt>
1964 </div><a name="L819"></a><tt class="py-lineno">819</tt>  <tt class="py-line">             </tt>
1965 <a name="_merge_element_contents"></a><div id="_merge_element_contents-def"><a name="L820"></a><tt class="py-lineno">820</tt> <a class="py-toggle" href="#" id="_merge_element_contents-toggle" onclick="return toggle('_merge_element_contents');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#_merge_element_contents">_merge_element_contents</a><tt class="py-op">(</tt><tt class="py-param">el</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1966 </div><div id="_merge_element_contents-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="_merge_element_contents-expanded"><a name="L821"></a><tt class="py-lineno">821</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
1967 <a name="L822"></a><tt class="py-lineno">822</tt>  <tt class="py-line"><tt class="py-docstring">    Removes an element, but merges its contents into its place, e.g.,</tt> </tt>
1968 <a name="L823"></a><tt class="py-lineno">823</tt>  <tt class="py-line"><tt class="py-docstring">    given &lt;p&gt;Hi &lt;i&gt;there!&lt;/i&gt;&lt;/p&gt;, if you remove the &lt;i&gt; element you get</tt> </tt>
1969 <a name="L824"></a><tt class="py-lineno">824</tt>  <tt class="py-line"><tt class="py-docstring">    &lt;p&gt;Hi there!&lt;/p&gt;</tt> </tt>
1970 <a name="L825"></a><tt class="py-lineno">825</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
1971 <a name="L826"></a><tt class="py-lineno">826</tt>  <tt class="py-line">    <tt class="py-name">parent</tt> <tt class="py-op">=</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-337" class="py-name" targets="Method lxml.etree._Element.getparent()=lxml.etree._Element-class.html#getparent,Method lxml.etree._ElementStringResult.getparent()=lxml.etree._ElementStringResult-class.html#getparent,Method lxml.etree._ElementUnicodeResult.getparent()=lxml.etree._ElementUnicodeResult-class.html#getparent,Method lxml.etree._ReadOnlyProxy.getparent()=lxml.etree._ReadOnlyProxy-class.html#getparent"><a title="lxml.etree._Element.getparent
1972 lxml.etree._ElementStringResult.getparent
1973 lxml.etree._ElementUnicodeResult.getparent
1974 lxml.etree._ReadOnlyProxy.getparent" class="py-name" href="#" onclick="return doclink('link-337', 'getparent', 'link-337');">getparent</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
1975 <a name="L827"></a><tt class="py-lineno">827</tt>  <tt class="py-line">    <tt id="link-338" class="py-name"><a title="lxml.etree.QName.text
1976 lxml.etree._AppendOnlyElementProxy.text
1977 lxml.etree._Element.text
1978 lxml.etree._Entity.text
1979 lxml.etree._ModifyContentOnlyProxy.text
1980 lxml.etree._ReadOnlyEntityProxy.text
1981 lxml.etree._ReadOnlyProxy.text
1982 lxml.etree.__ContentOnlyElement.text
1983 lxml.objectify.ObjectifiedElement.text
1984 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-338', 'text', 'link-6');">text</a></tt> <tt class="py-op">=</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-339" class="py-name"><a title="lxml.etree.QName.text
1985 lxml.etree._AppendOnlyElementProxy.text
1986 lxml.etree._Element.text
1987 lxml.etree._Entity.text
1988 lxml.etree._ModifyContentOnlyProxy.text
1989 lxml.etree._ReadOnlyEntityProxy.text
1990 lxml.etree._ReadOnlyProxy.text
1991 lxml.etree.__ContentOnlyElement.text
1992 lxml.objectify.ObjectifiedElement.text
1993 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-339', 'text', 'link-6');">text</a></tt> <tt class="py-keyword">or</tt> <tt class="py-string">''</tt> </tt>
1994 <a name="L828"></a><tt class="py-lineno">828</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-340" class="py-name"><a title="lxml.etree._Element.tail
1995 lxml.etree._ReadOnlyProxy.tail
1996 xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-340', 'tail', 'link-240');">tail</a></tt><tt class="py-op">:</tt> </tt>
1997 <a name="L829"></a><tt class="py-lineno">829</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">el</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
1998 <a name="L830"></a><tt class="py-lineno">830</tt>  <tt class="py-line">            <tt id="link-341" class="py-name"><a title="lxml.etree.QName.text
1999 lxml.etree._AppendOnlyElementProxy.text
2000 lxml.etree._Element.text
2001 lxml.etree._Entity.text
2002 lxml.etree._ModifyContentOnlyProxy.text
2003 lxml.etree._ReadOnlyEntityProxy.text
2004 lxml.etree._ReadOnlyProxy.text
2005 lxml.etree.__ContentOnlyElement.text
2006 lxml.objectify.ObjectifiedElement.text
2007 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-341', 'text', 'link-6');">text</a></tt> <tt class="py-op">+=</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-342" class="py-name"><a title="lxml.etree._Element.tail
2008 lxml.etree._ReadOnlyProxy.tail
2009 xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-342', 'tail', 'link-240');">tail</a></tt> </tt>
2010 <a name="L831"></a><tt class="py-lineno">831</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
2011 <a name="L832"></a><tt class="py-lineno">832</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">el</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt id="link-343" class="py-name"><a title="lxml.etree._Element.tail
2012 lxml.etree._ReadOnlyProxy.tail
2013 xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-343', 'tail', 'link-240');">tail</a></tt><tt class="py-op">:</tt> </tt>
2014 <a name="L833"></a><tt class="py-lineno">833</tt>  <tt class="py-line">                <tt class="py-name">el</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt id="link-344" class="py-name"><a title="lxml.etree._Element.tail
2015 lxml.etree._ReadOnlyProxy.tail
2016 xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-344', 'tail', 'link-240');">tail</a></tt> <tt class="py-op">+=</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-345" class="py-name"><a title="lxml.etree._Element.tail
2017 lxml.etree._ReadOnlyProxy.tail
2018 xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-345', 'tail', 'link-240');">tail</a></tt> </tt>
2019 <a name="L834"></a><tt class="py-lineno">834</tt>  <tt class="py-line">            <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
2020 <a name="L835"></a><tt class="py-lineno">835</tt>  <tt class="py-line">                <tt class="py-name">el</tt><tt class="py-op">[</tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt><tt class="py-op">.</tt><tt id="link-346" class="py-name"><a title="lxml.etree._Element.tail
2021 lxml.etree._ReadOnlyProxy.tail
2022 xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-346', 'tail', 'link-240');">tail</a></tt> <tt class="py-op">=</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-347" class="py-name"><a title="lxml.etree._Element.tail
2023 lxml.etree._ReadOnlyProxy.tail
2024 xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-347', 'tail', 'link-240');">tail</a></tt> </tt>
2025 <a name="L836"></a><tt class="py-lineno">836</tt>  <tt class="py-line">    <tt id="link-348" class="py-name"><a title="lxml.etree._Element.index" class="py-name" href="#" onclick="return doclink('link-348', 'index', 'link-118');">index</a></tt> <tt class="py-op">=</tt> <tt class="py-name">parent</tt><tt class="py-op">.</tt><tt id="link-349" class="py-name"><a title="lxml.etree._Element.index" class="py-name" href="#" onclick="return doclink('link-349', 'index', 'link-118');">index</a></tt><tt class="py-op">(</tt><tt class="py-name">el</tt><tt class="py-op">)</tt> </tt>
2026 <a name="L837"></a><tt class="py-lineno">837</tt>  <tt class="py-line">    <tt class="py-keyword">if</tt> <tt id="link-350" class="py-name"><a title="lxml.etree.QName.text
2027 lxml.etree._AppendOnlyElementProxy.text
2028 lxml.etree._Element.text
2029 lxml.etree._Entity.text
2030 lxml.etree._ModifyContentOnlyProxy.text
2031 lxml.etree._ReadOnlyEntityProxy.text
2032 lxml.etree._ReadOnlyProxy.text
2033 lxml.etree.__ContentOnlyElement.text
2034 lxml.objectify.ObjectifiedElement.text
2035 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-350', 'text', 'link-6');">text</a></tt><tt class="py-op">:</tt> </tt>
2036 <a name="L838"></a><tt class="py-lineno">838</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt id="link-351" class="py-name"><a title="lxml.etree._Element.index" class="py-name" href="#" onclick="return doclink('link-351', 'index', 'link-118');">index</a></tt> <tt class="py-op">==</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
2037 <a name="L839"></a><tt class="py-lineno">839</tt>  <tt class="py-line">            <tt class="py-name">previous</tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt> </tt>
2038 <a name="L840"></a><tt class="py-lineno">840</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
2039 <a name="L841"></a><tt class="py-lineno">841</tt>  <tt class="py-line">            <tt class="py-name">previous</tt> <tt class="py-op">=</tt> <tt class="py-name">parent</tt><tt class="py-op">[</tt><tt id="link-352" class="py-name"><a title="lxml.etree._Element.index" class="py-name" href="#" onclick="return doclink('link-352', 'index', 'link-118');">index</a></tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> </tt>
2040 <a name="L842"></a><tt class="py-lineno">842</tt>  <tt class="py-line">        <tt class="py-keyword">if</tt> <tt class="py-name">previous</tt> <tt class="py-keyword">is</tt> <tt class="py-name">None</tt><tt class="py-op">:</tt> </tt>
2041 <a name="L843"></a><tt class="py-lineno">843</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">parent</tt><tt class="py-op">.</tt><tt id="link-353" class="py-name"><a title="lxml.etree.QName.text
2042 lxml.etree._AppendOnlyElementProxy.text
2043 lxml.etree._Element.text
2044 lxml.etree._Entity.text
2045 lxml.etree._ModifyContentOnlyProxy.text
2046 lxml.etree._ReadOnlyEntityProxy.text
2047 lxml.etree._ReadOnlyProxy.text
2048 lxml.etree.__ContentOnlyElement.text
2049 lxml.objectify.ObjectifiedElement.text
2050 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-353', 'text', 'link-6');">text</a></tt><tt class="py-op">:</tt> </tt>
2051 <a name="L844"></a><tt class="py-lineno">844</tt>  <tt class="py-line">                <tt class="py-name">parent</tt><tt class="py-op">.</tt><tt id="link-354" class="py-name"><a title="lxml.etree.QName.text
2052 lxml.etree._AppendOnlyElementProxy.text
2053 lxml.etree._Element.text
2054 lxml.etree._Entity.text
2055 lxml.etree._ModifyContentOnlyProxy.text
2056 lxml.etree._ReadOnlyEntityProxy.text
2057 lxml.etree._ReadOnlyProxy.text
2058 lxml.etree.__ContentOnlyElement.text
2059 lxml.objectify.ObjectifiedElement.text
2060 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-354', 'text', 'link-6');">text</a></tt> <tt class="py-op">+=</tt> <tt id="link-355" class="py-name"><a title="lxml.etree.QName.text
2061 lxml.etree._AppendOnlyElementProxy.text
2062 lxml.etree._Element.text
2063 lxml.etree._Entity.text
2064 lxml.etree._ModifyContentOnlyProxy.text
2065 lxml.etree._ReadOnlyEntityProxy.text
2066 lxml.etree._ReadOnlyProxy.text
2067 lxml.etree.__ContentOnlyElement.text
2068 lxml.objectify.ObjectifiedElement.text
2069 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-355', 'text', 'link-6');">text</a></tt> </tt>
2070 <a name="L845"></a><tt class="py-lineno">845</tt>  <tt class="py-line">            <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
2071 <a name="L846"></a><tt class="py-lineno">846</tt>  <tt class="py-line">                <tt class="py-name">parent</tt><tt class="py-op">.</tt><tt id="link-356" class="py-name"><a title="lxml.etree.QName.text
2072 lxml.etree._AppendOnlyElementProxy.text
2073 lxml.etree._Element.text
2074 lxml.etree._Entity.text
2075 lxml.etree._ModifyContentOnlyProxy.text
2076 lxml.etree._ReadOnlyEntityProxy.text
2077 lxml.etree._ReadOnlyProxy.text
2078 lxml.etree.__ContentOnlyElement.text
2079 lxml.objectify.ObjectifiedElement.text
2080 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-356', 'text', 'link-6');">text</a></tt> <tt class="py-op">=</tt> <tt id="link-357" class="py-name"><a title="lxml.etree.QName.text
2081 lxml.etree._AppendOnlyElementProxy.text
2082 lxml.etree._Element.text
2083 lxml.etree._Entity.text
2084 lxml.etree._ModifyContentOnlyProxy.text
2085 lxml.etree._ReadOnlyEntityProxy.text
2086 lxml.etree._ReadOnlyProxy.text
2087 lxml.etree.__ContentOnlyElement.text
2088 lxml.objectify.ObjectifiedElement.text
2089 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-357', 'text', 'link-6');">text</a></tt> </tt>
2090 <a name="L847"></a><tt class="py-lineno">847</tt>  <tt class="py-line">        <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
2091 <a name="L848"></a><tt class="py-lineno">848</tt>  <tt class="py-line">            <tt class="py-keyword">if</tt> <tt class="py-name">previous</tt><tt class="py-op">.</tt><tt id="link-358" class="py-name"><a title="lxml.etree._Element.tail
2092 lxml.etree._ReadOnlyProxy.tail
2093 xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-358', 'tail', 'link-240');">tail</a></tt><tt class="py-op">:</tt> </tt>
2094 <a name="L849"></a><tt class="py-lineno">849</tt>  <tt class="py-line">                <tt class="py-name">previous</tt><tt class="py-op">.</tt><tt id="link-359" class="py-name"><a title="lxml.etree._Element.tail
2095 lxml.etree._ReadOnlyProxy.tail
2096 xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-359', 'tail', 'link-240');">tail</a></tt> <tt class="py-op">+=</tt> <tt id="link-360" class="py-name"><a title="lxml.etree.QName.text
2097 lxml.etree._AppendOnlyElementProxy.text
2098 lxml.etree._Element.text
2099 lxml.etree._Entity.text
2100 lxml.etree._ModifyContentOnlyProxy.text
2101 lxml.etree._ReadOnlyEntityProxy.text
2102 lxml.etree._ReadOnlyProxy.text
2103 lxml.etree.__ContentOnlyElement.text
2104 lxml.objectify.ObjectifiedElement.text
2105 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-360', 'text', 'link-6');">text</a></tt> </tt>
2106 <a name="L850"></a><tt class="py-lineno">850</tt>  <tt class="py-line">            <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
2107 <a name="L851"></a><tt class="py-lineno">851</tt>  <tt class="py-line">                <tt class="py-name">previous</tt><tt class="py-op">.</tt><tt id="link-361" class="py-name"><a title="lxml.etree._Element.tail
2108 lxml.etree._ReadOnlyProxy.tail
2109 xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-361', 'tail', 'link-240');">tail</a></tt> <tt class="py-op">=</tt> <tt id="link-362" class="py-name"><a title="lxml.etree.QName.text
2110 lxml.etree._AppendOnlyElementProxy.text
2111 lxml.etree._Element.text
2112 lxml.etree._Entity.text
2113 lxml.etree._ModifyContentOnlyProxy.text
2114 lxml.etree._ReadOnlyEntityProxy.text
2115 lxml.etree._ReadOnlyProxy.text
2116 lxml.etree.__ContentOnlyElement.text
2117 lxml.objectify.ObjectifiedElement.text
2118 xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-362', 'text', 'link-6');">text</a></tt> </tt>
2119 <a name="L852"></a><tt class="py-lineno">852</tt>  <tt class="py-line">    <tt class="py-name">parent</tt><tt class="py-op">[</tt><tt id="link-363" class="py-name"><a title="lxml.etree._Element.index" class="py-name" href="#" onclick="return doclink('link-363', 'index', 'link-118');">index</a></tt><tt class="py-op">:</tt><tt id="link-364" class="py-name"><a title="lxml.etree._Element.index" class="py-name" href="#" onclick="return doclink('link-364', 'index', 'link-118');">index</a></tt><tt class="py-op">+</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-365" class="py-name" targets="Method lxml.etree._Element.getchildren()=lxml.etree._Element-class.html#getchildren,Method lxml.etree._ReadOnlyProxy.getchildren()=lxml.etree._ReadOnlyProxy-class.html#getchildren,Method lxml.objectify.ObjectifiedElement.getchildren()=lxml.objectify.ObjectifiedElement-class.html#getchildren"><a title="lxml.etree._Element.getchildren
2120 lxml.etree._ReadOnlyProxy.getchildren
2121 lxml.objectify.ObjectifiedElement.getchildren" class="py-name" href="#" onclick="return doclink('link-365', 'getchildren', 'link-365');">getchildren</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
2122 </div><a name="L853"></a><tt class="py-lineno">853</tt>  <tt class="py-line"> </tt>
2123 <a name="InsensitiveSequenceMatcher"></a><div id="InsensitiveSequenceMatcher-def"><a name="L854"></a><tt class="py-lineno">854</tt> <a class="py-toggle" href="#" id="InsensitiveSequenceMatcher-toggle" onclick="return toggle('InsensitiveSequenceMatcher');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="lxml.html.diff.InsensitiveSequenceMatcher-class.html">InsensitiveSequenceMatcher</a><tt class="py-op">(</tt><tt class="py-base-class">difflib</tt><tt class="py-op">.</tt><tt class="py-base-class">SequenceMatcher</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
2124 </div><div id="InsensitiveSequenceMatcher-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="InsensitiveSequenceMatcher-expanded"><a name="L855"></a><tt class="py-lineno">855</tt>  <tt class="py-line">    <tt class="py-docstring">"""</tt> </tt>
2125 <a name="L856"></a><tt class="py-lineno">856</tt>  <tt class="py-line"><tt class="py-docstring">    Acts like SequenceMatcher, but tries not to find very small equal</tt> </tt>
2126 <a name="L857"></a><tt class="py-lineno">857</tt>  <tt class="py-line"><tt class="py-docstring">    blocks amidst large spans of changes</tt> </tt>
2127 <a name="L858"></a><tt class="py-lineno">858</tt>  <tt class="py-line"><tt class="py-docstring">    """</tt> </tt>
2128 <a name="L859"></a><tt class="py-lineno">859</tt>  <tt class="py-line"> </tt>
2129 <a name="L860"></a><tt class="py-lineno">860</tt>  <tt class="py-line">    <tt id="link-366" class="py-name" targets="Variable lxml.html.diff.InsensitiveSequenceMatcher.threshold=lxml.html.diff.InsensitiveSequenceMatcher-class.html#threshold"><a title="lxml.html.diff.InsensitiveSequenceMatcher.threshold" class="py-name" href="#" onclick="return doclink('link-366', 'threshold', 'link-366');">threshold</a></tt> <tt class="py-op">=</tt> <tt class="py-number">2</tt> </tt>
2130 <a name="L861"></a><tt class="py-lineno">861</tt>  <tt class="py-line">     </tt>
2131 <a name="InsensitiveSequenceMatcher.get_matching_blocks"></a><div id="InsensitiveSequenceMatcher.get_matching_blocks-def"><a name="L862"></a><tt class="py-lineno">862</tt> <a class="py-toggle" href="#" id="InsensitiveSequenceMatcher.get_matching_blocks-toggle" onclick="return toggle('InsensitiveSequenceMatcher.get_matching_blocks');">-</a><tt class="py-line">    <tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff.InsensitiveSequenceMatcher-class.html#get_matching_blocks">get_matching_blocks</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
2132 </div><div id="InsensitiveSequenceMatcher.get_matching_blocks-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="InsensitiveSequenceMatcher.get_matching_blocks-expanded"><a name="L863"></a><tt class="py-lineno">863</tt>  <tt class="py-line">        <tt class="py-name">size</tt> <tt class="py-op">=</tt> <tt class="py-name">min</tt><tt class="py-op">(</tt><tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">b</tt><tt class="py-op">)</tt><tt class="py-op">,</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">b</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
2133 <a name="L864"></a><tt class="py-lineno">864</tt>  <tt class="py-line">        <tt id="link-367" class="py-name"><a title="lxml.html.diff.InsensitiveSequenceMatcher.threshold" class="py-name" href="#" onclick="return doclink('link-367', 'threshold', 'link-366');">threshold</a></tt> <tt class="py-op">=</tt> <tt class="py-name">min</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-368" class="py-name"><a title="lxml.html.diff.InsensitiveSequenceMatcher.threshold" class="py-name" href="#" onclick="return doclink('link-368', 'threshold', 'link-366');">threshold</a></tt><tt class="py-op">,</tt> <tt class="py-name">size</tt> <tt class="py-op">/</tt> <tt class="py-number">4</tt><tt class="py-op">)</tt> </tt>
2134 <a name="L865"></a><tt class="py-lineno">865</tt>  <tt class="py-line">        <tt class="py-name">actual</tt> <tt class="py-op">=</tt> <tt class="py-name">difflib</tt><tt class="py-op">.</tt><tt class="py-name">SequenceMatcher</tt><tt class="py-op">.</tt><tt id="link-369" class="py-name" targets="Method lxml.html.diff.InsensitiveSequenceMatcher.get_matching_blocks()=lxml.html.diff.InsensitiveSequenceMatcher-class.html#get_matching_blocks"><a title="lxml.html.diff.InsensitiveSequenceMatcher.get_matching_blocks" class="py-name" href="#" onclick="return doclink('link-369', 'get_matching_blocks', 'link-369');">get_matching_blocks</a></tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">)</tt> </tt>
2135 <a name="L866"></a><tt class="py-lineno">866</tt>  <tt class="py-line">        <tt class="py-keyword">return</tt> <tt class="py-op">[</tt><tt class="py-name">item</tt> <tt class="py-keyword">for</tt> <tt class="py-name">item</tt> <tt class="py-keyword">in</tt> <tt class="py-name">actual</tt> </tt>
2136 <a name="L867"></a><tt class="py-lineno">867</tt>  <tt class="py-line">                <tt class="py-keyword">if</tt> <tt class="py-name">item</tt><tt class="py-op">[</tt><tt class="py-number">2</tt><tt class="py-op">]</tt> <tt class="py-op">&gt;</tt> <tt id="link-370" class="py-name"><a title="lxml.html.diff.InsensitiveSequenceMatcher.threshold" class="py-name" href="#" onclick="return doclink('link-370', 'threshold', 'link-366');">threshold</a></tt> </tt>
2137 <a name="L868"></a><tt class="py-lineno">868</tt>  <tt class="py-line">                <tt class="py-keyword">or</tt> <tt class="py-keyword">not</tt> <tt class="py-name">item</tt><tt class="py-op">[</tt><tt class="py-number">2</tt><tt class="py-op">]</tt><tt class="py-op">]</tt> </tt>
2138 </div></div><a name="L869"></a><tt class="py-lineno">869</tt>  <tt class="py-line"> </tt>
2139 <a name="L870"></a><tt class="py-lineno">870</tt>  <tt class="py-line"><tt class="py-keyword">if</tt> <tt class="py-name">__name__</tt> <tt class="py-op">==</tt> <tt class="py-string">'__main__'</tt><tt class="py-op">:</tt> </tt>
2140 <a name="L871"></a><tt class="py-lineno">871</tt>  <tt class="py-line">    <tt class="py-keyword">from</tt> <tt id="link-371" class="py-name"><a title="lxml" class="py-name" href="#" onclick="return doclink('link-371', 'lxml', 'link-0');">lxml</a></tt><tt class="py-op">.</tt><tt id="link-372" class="py-name"><a title="lxml.html
2141 lxml.html.diff.href_token.html
2142 lxml.html.diff.tag_token.html
2143 lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-372', 'html', 'link-3');">html</a></tt> <tt class="py-keyword">import</tt> <tt class="py-name">_diffcommand</tt> </tt>
2144 <a name="L872"></a><tt class="py-lineno">872</tt>  <tt class="py-line">    <tt class="py-name">_diffcommand</tt><tt class="py-op">.</tt><tt class="py-name">main</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
2145 <a name="L873"></a><tt class="py-lineno">873</tt>  <tt class="py-line"> </tt><script type="text/javascript">
2146 <!--
2147 expandto(location.href);
2148 // -->
2149 </script>
2150 </pre>
2151 <br />
2152 <!-- ==================== NAVIGATION BAR ==================== -->
2153 <table class="navbar" border="0" width="100%" cellpadding="0"
2154        bgcolor="#a0c0ff" cellspacing="0">
2155   <tr valign="middle">
2156   <!-- Home link -->
2157       <th>&nbsp;&nbsp;&nbsp;<a
2158         href="lxml-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
2159
2160   <!-- Tree link -->
2161       <th>&nbsp;&nbsp;&nbsp;<a
2162         href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
2163
2164   <!-- Index link -->
2165       <th>&nbsp;&nbsp;&nbsp;<a
2166         href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
2167
2168   <!-- Help link -->
2169       <th>&nbsp;&nbsp;&nbsp;<a
2170         href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
2171
2172   <!-- Project homepage -->
2173       <th class="navbar" align="right" width="100%">
2174         <table border="0" cellpadding="0" cellspacing="0">
2175           <tr><th class="navbar" align="center"
2176             ><a class="navbar" target="_top" href="/">lxml API</a></th>
2177           </tr></table></th>
2178   </tr>
2179 </table>
2180 <table border="0" cellpadding="0" cellspacing="0" width="100%%">
2181   <tr>
2182     <td align="left" class="footer">
2183     Generated by Epydoc 3.0.1 on Tue Jul 31 10:14:23 2012
2184     </td>
2185     <td align="right" class="footer">
2186       <a target="mainFrame" href="http://epydoc.sourceforge.net"
2187         >http://epydoc.sourceforge.net</a>
2188     </td>
2189   </tr>
2190 </table>
2191
2192 <script type="text/javascript">
2193   <!--
2194   // Private objects are initially displayed (because if
2195   // javascript is turned off then we want them to be
2196   // visible); but by default, we want to hide them.  So hide
2197   // them unless we have a cookie that says to show them.
2198   checkCookie();
2199   // -->
2200 </script>
2201 </body>
2202 </html>