1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764
|
<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>lxml.html.diff</title>
<link rel="stylesheet" href="epydoc.css" type="text/css" />
<script type="text/javascript" src="epydoc.js"></script>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
bgcolor="#a0c0ff" cellspacing="0">
<tr valign="middle">
<!-- Home link -->
<th> <a
href="lxml-module.html">Home</a> </th>
<!-- Tree link -->
<th> <a
href="module-tree.html">Trees</a> </th>
<!-- Index link -->
<th> <a
href="identifier-index.html">Indices</a> </th>
<!-- Help link -->
<th> <a
href="help.html">Help</a> </th>
<!-- Project homepage -->
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center"
><a class="navbar" target="_top" href="/">lxml API</a></th>
</tr></table></th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<span class="breadcrumbs">
<a href="lxml-module.html">Package lxml</a> ::
<a href="lxml.html-module.html">Package html</a> ::
Module diff
</span>
</td>
<td>
<table cellpadding="0" cellspacing="0">
<!-- hide/show private -->
<tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
onclick="toggle_private();">hide private</a>]</span></td></tr>
<tr><td align="right"><span class="options"
>[<a href="frames.html" target="_top">frames</a
>] | <a href="lxml.html.diff-pysrc.html"
target="_top">no frames</a>]</span></td></tr>
</table>
</td>
</tr>
</table>
<h1 class="epydoc">Source Code for <a href="lxml.html.diff-module.html">Module lxml.html.diff</a></h1>
<pre class="py-src">
<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>
<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_elementtree._XMLPullParserTest.etree=lxml.tests.test_elementtree._XMLPullParserTest-class.html#etree,Variable lxml.tests.test_io._IOTestCaseBase.etree=lxml.tests.test_io._IOTestCaseBase-class.html#etree"><a title="lxml.etree
lxml.sax.ElementTreeContentHandler.etree
lxml.tests.test_elementtree.CElementTreeTestCase.etree
lxml.tests.test_elementtree._ETreeTestCaseBase.etree
lxml.tests.test_elementtree._XMLPullParserTest.etree
lxml.tests.test_io._IOTestCaseBase.etree" class="py-name" href="#" onclick="return doclink('link-1', 'etree', 'link-1');">etree</a></tt> </tt>
<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
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
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.html5parser.fragment_fromstring()=lxml.html.html5parser-module.html#fragment_fromstring"><a title="lxml.html.html5parser.fragment_fromstring" class="py-name" href="#" onclick="return doclink('link-4', 'fragment_fromstring', 'link-4');">fragment_fromstring</a></tt> </tt>
<a name="L4"></a><tt class="py-lineno"> 4</tt> <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">re</tt> </tt>
<a name="L5"></a><tt class="py-lineno"> 5</tt> <tt class="py-line"> </tt>
<a name="L6"></a><tt class="py-lineno"> 6</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>
<a name="L7"></a><tt class="py-lineno"> 7</tt> <tt class="py-line"> </tt>
<a name="L8"></a><tt class="py-lineno"> 8</tt> <tt class="py-line"><tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
<a name="L9"></a><tt class="py-lineno"> 9</tt> <tt class="py-line"> <tt class="py-keyword">from</tt> <tt id="link-5" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-5', 'html', 'link-3');">html</a></tt> <tt class="py-keyword">import</tt> <tt class="py-name">escape</tt> <tt class="py-keyword">as</tt> <tt class="py-name">html_escape</tt> </tt>
<a name="L10"></a><tt class="py-lineno"> 10</tt> <tt class="py-line"><tt class="py-keyword">except</tt> <tt class="py-name">ImportError</tt><tt class="py-op">:</tt> </tt>
<a name="L11"></a><tt class="py-lineno"> 11</tt> <tt class="py-line"> <tt class="py-keyword">from</tt> <tt class="py-name">cgi</tt> <tt class="py-keyword">import</tt> <tt class="py-name">escape</tt> <tt class="py-keyword">as</tt> <tt class="py-name">html_escape</tt> </tt>
<a name="L12"></a><tt class="py-lineno"> 12</tt> <tt class="py-line"><tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
<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">unicode</tt> </tt>
<a name="L14"></a><tt class="py-lineno"> 14</tt> <tt class="py-line"><tt class="py-keyword">except</tt> <tt class="py-name">NameError</tt><tt class="py-op">:</tt> </tt>
<a name="L15"></a><tt class="py-lineno"> 15</tt> <tt class="py-line"> <tt class="py-comment"># Python 3</tt> </tt>
<a name="L16"></a><tt class="py-lineno"> 16</tt> <tt class="py-line"> <tt class="py-name">_unicode</tt> <tt class="py-op">=</tt> <tt id="link-6" class="py-name" targets="Class str=str-class.html"><a title="str" class="py-name" href="#" onclick="return doclink('link-6', 'str', 'link-6');">str</a></tt> </tt>
<a name="L17"></a><tt class="py-lineno"> 17</tt> <tt class="py-line"><tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
<a name="L18"></a><tt class="py-lineno"> 18</tt> <tt class="py-line"> <tt id="link-7" class="py-name" targets="Variable lxml.html.clean.basestring=lxml.html.clean-module.html#basestring"><a title="lxml.html.clean.basestring" class="py-name" href="#" onclick="return doclink('link-7', 'basestring', 'link-7');">basestring</a></tt> </tt>
<a name="L19"></a><tt class="py-lineno"> 19</tt> <tt class="py-line"><tt class="py-keyword">except</tt> <tt class="py-name">NameError</tt><tt class="py-op">:</tt> </tt>
<a name="L20"></a><tt class="py-lineno"> 20</tt> <tt class="py-line"> <tt class="py-comment"># Python 3</tt> </tt>
<a name="L21"></a><tt class="py-lineno"> 21</tt> <tt class="py-line"> <tt id="link-8" class="py-name"><a title="lxml.html.clean.basestring" class="py-name" href="#" onclick="return doclink('link-8', 'basestring', 'link-7');">basestring</a></tt> <tt class="py-op">=</tt> <tt id="link-9" class="py-name"><a title="str" class="py-name" href="#" onclick="return doclink('link-9', 'str', 'link-6');">str</a></tt> </tt>
<a name="L22"></a><tt class="py-lineno"> 22</tt> <tt class="py-line"> </tt>
<a name="L23"></a><tt class="py-lineno"> 23</tt> <tt class="py-line"><tt class="py-comment">############################################################</tt> </tt>
<a name="L24"></a><tt class="py-lineno"> 24</tt> <tt class="py-line"><tt class="py-comment">## Annotation</tt> </tt>
<a name="L25"></a><tt class="py-lineno"> 25</tt> <tt class="py-line"><tt class="py-comment">############################################################</tt> </tt>
<a name="L26"></a><tt class="py-lineno"> 26</tt> <tt class="py-line"> </tt>
<a name="default_markup"></a><div id="default_markup-def"><a name="L27"></a><tt class="py-lineno"> 27</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>
</div><div id="default_markup-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="default_markup-expanded"><a name="L28"></a><tt class="py-lineno"> 28</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-string">'<span title="%s">%s</span>'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt> </tt>
<a name="L29"></a><tt class="py-lineno"> 29</tt> <tt class="py-line"> <tt class="py-name">html_escape</tt><tt class="py-op">(</tt><tt class="py-name">_unicode</tt><tt class="py-op">(</tt><tt id="link-10" class="py-name" targets="Variable lxml.etree.iterparse.version=lxml.etree.iterparse-class.html#version"><a title="lxml.etree.iterparse.version" class="py-name" href="#" onclick="return doclink('link-10', 'version', 'link-10');">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-11" class="py-name" targets="Variable lxml.etree.QName.text=lxml.etree.QName-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.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
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-11', 'text', 'link-11');">text</a></tt><tt class="py-op">)</tt> </tt>
</div><a name="L30"></a><tt class="py-lineno"> 30</tt> <tt class="py-line"> </tt>
<a name="html_annotate"></a><div id="html_annotate-def"><a name="L31"></a><tt class="py-lineno"> 31</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-12" 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-12', 'default_markup', 'link-12');">default_markup</a></tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="html_annotate-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="html_annotate-expanded"><a name="L32"></a><tt class="py-lineno"> 32</tt> <tt class="py-line"> <tt class="py-docstring">"""</tt> </tt>
<a name="L33"></a><tt class="py-lineno"> 33</tt> <tt class="py-line"><tt class="py-docstring"> doclist should be ordered from oldest to newest, like::</tt> </tt>
<a name="L34"></a><tt class="py-lineno"> 34</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L35"></a><tt class="py-lineno"> 35</tt> <tt class="py-line"><tt class="py-docstring"> >>> version1 = 'Hello World'</tt> </tt>
<a name="L36"></a><tt class="py-lineno"> 36</tt> <tt class="py-line"><tt class="py-docstring"> >>> version2 = 'Goodbye World'</tt> </tt>
<a name="L37"></a><tt class="py-lineno"> 37</tt> <tt class="py-line"><tt class="py-docstring"> >>> print(html_annotate([(version1, 'version 1'),</tt> </tt>
<a name="L38"></a><tt class="py-lineno"> 38</tt> <tt class="py-line"><tt class="py-docstring"> ... (version2, 'version 2')]))</tt> </tt>
<a name="L39"></a><tt class="py-lineno"> 39</tt> <tt class="py-line"><tt class="py-docstring"> <span title="version 2">Goodbye</span> <span title="version 1">World</span></tt> </tt>
<a name="L40"></a><tt class="py-lineno"> 40</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L41"></a><tt class="py-lineno"> 41</tt> <tt class="py-line"><tt class="py-docstring"> The documents must be *fragments* (str/UTF8 or unicode), not</tt> </tt>
<a name="L42"></a><tt class="py-lineno"> 42</tt> <tt class="py-line"><tt class="py-docstring"> complete documents</tt> </tt>
<a name="L43"></a><tt class="py-lineno"> 43</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L44"></a><tt class="py-lineno"> 44</tt> <tt class="py-line"><tt class="py-docstring"> The markup argument is a function to markup the spans of words.</tt> </tt>
<a name="L45"></a><tt class="py-lineno"> 45</tt> <tt class="py-line"><tt class="py-docstring"> This function is called like markup('Hello', 'version 2'), and</tt> </tt>
<a name="L46"></a><tt class="py-lineno"> 46</tt> <tt class="py-line"><tt class="py-docstring"> returns HTML. The first argument is text and never includes any</tt> </tt>
<a name="L47"></a><tt class="py-lineno"> 47</tt> <tt class="py-line"><tt class="py-docstring"> markup. The default uses a span with a title:</tt> </tt>
<a name="L48"></a><tt class="py-lineno"> 48</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L49"></a><tt class="py-lineno"> 49</tt> <tt class="py-line"><tt class="py-docstring"> >>> print(default_markup('Some Text', 'by Joe'))</tt> </tt>
<a name="L50"></a><tt class="py-lineno"> 50</tt> <tt class="py-line"><tt class="py-docstring"> <span title="by Joe">Some Text</span></tt> </tt>
<a name="L51"></a><tt class="py-lineno"> 51</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
<a name="L52"></a><tt class="py-lineno"> 52</tt> <tt class="py-line"> <tt class="py-comment"># The basic strategy we have is to split the documents up into</tt> </tt>
<a name="L53"></a><tt class="py-lineno"> 53</tt> <tt class="py-line"> <tt class="py-comment"># logical tokens (which are words with attached markup). We then</tt> </tt>
<a name="L54"></a><tt class="py-lineno"> 54</tt> <tt class="py-line"> <tt class="py-comment"># do diffs of each of the versions to track when a token first</tt> </tt>
<a name="L55"></a><tt class="py-lineno"> 55</tt> <tt class="py-line"> <tt class="py-comment"># appeared in the document; the annotation attached to the token</tt> </tt>
<a name="L56"></a><tt class="py-lineno"> 56</tt> <tt class="py-line"> <tt class="py-comment"># is the version where it first appeared.</tt> </tt>
<a name="L57"></a><tt class="py-lineno"> 57</tt> <tt class="py-line"> <tt class="py-name">tokenlist</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt id="link-13" 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-13', 'tokenize_annotated', 'link-13');">tokenize_annotated</a></tt><tt class="py-op">(</tt><tt class="py-name">doc</tt><tt class="py-op">,</tt> <tt id="link-14" class="py-name"><a title="lxml.etree.iterparse.version" class="py-name" href="#" onclick="return doclink('link-14', 'version', 'link-10');">version</a></tt><tt class="py-op">)</tt> </tt>
<a name="L58"></a><tt class="py-lineno"> 58</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-15" class="py-name"><a title="lxml.etree.iterparse.version" class="py-name" href="#" onclick="return doclink('link-15', 'version', 'link-10');">version</a></tt> <tt class="py-keyword">in</tt> <tt class="py-name">doclist</tt><tt class="py-op">]</tt> </tt>
<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">tokenlist</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt> </tt>
<a name="L60"></a><tt class="py-lineno"> 60</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>
<a name="L61"></a><tt class="py-lineno"> 61</tt> <tt class="py-line"> <tt id="link-16" 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-16', 'html_annotate_merge_annotations', 'link-16');">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>
<a name="L62"></a><tt class="py-lineno"> 62</tt> <tt class="py-line"> <tt class="py-name">cur_tokens</tt> <tt class="py-op">=</tt> <tt class="py-name">tokens</tt> </tt>
<a name="L63"></a><tt class="py-lineno"> 63</tt> <tt class="py-line"> </tt>
<a name="L64"></a><tt class="py-lineno"> 64</tt> <tt class="py-line"> <tt class="py-comment"># After we've tracked all the tokens, we can combine spans of text</tt> </tt>
<a name="L65"></a><tt class="py-lineno"> 65</tt> <tt class="py-line"> <tt class="py-comment"># that are adjacent and have the same annotation</tt> </tt>
<a name="L66"></a><tt class="py-lineno"> 66</tt> <tt class="py-line"> <tt class="py-name">cur_tokens</tt> <tt class="py-op">=</tt> <tt id="link-17" 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-17', 'compress_tokens', 'link-17');">compress_tokens</a></tt><tt class="py-op">(</tt><tt class="py-name">cur_tokens</tt><tt class="py-op">)</tt> </tt>
<a name="L67"></a><tt class="py-lineno"> 67</tt> <tt class="py-line"> <tt class="py-comment"># And finally add markup</tt> </tt>
<a name="L68"></a><tt class="py-lineno"> 68</tt> <tt class="py-line"> <tt class="py-name">result</tt> <tt class="py-op">=</tt> <tt id="link-18" 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-18', 'markup_serialize_tokens', 'link-18');">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>
<a name="L69"></a><tt class="py-lineno"> 69</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-string">''</tt><tt class="py-op">.</tt><tt class="py-name">join</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-19" 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-19', 'strip', 'link-19');">strip</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
</div><a name="L70"></a><tt class="py-lineno"> 70</tt> <tt class="py-line"> </tt>
<a name="tokenize_annotated"></a><div id="tokenize_annotated-def"><a name="L71"></a><tt class="py-lineno"> 71</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>
</div><a name="L72"></a><tt class="py-lineno"> 72</tt> <tt class="py-line"> <tt class="py-docstring">"""Tokenize a document and add an annotation attribute to each token</tt> </tt>
<a name="L73"></a><tt class="py-lineno"> 73</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
<a name="L74"></a><tt class="py-lineno"> 74</tt> <tt class="py-line"> <tt class="py-name">tokens</tt> <tt class="py-op">=</tt> <tt id="link-20" class="py-name" targets="Function lxml.html.diff.tokenize()=lxml.html.diff-module.html#tokenize"><a title="lxml.html.diff.tokenize" class="py-name" href="#" onclick="return doclink('link-20', 'tokenize', 'link-20');">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>
<a name="L75"></a><tt class="py-lineno"> 75</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>
<a name="L76"></a><tt class="py-lineno"> 76</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>
<a name="L77"></a><tt class="py-lineno"> 77</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">tokens</tt> </tt>
</div><a name="L78"></a><tt class="py-lineno"> 78</tt> <tt class="py-line"> </tt>
<a name="html_annotate_merge_annotations"></a><div id="html_annotate_merge_annotations-def"><a name="L79"></a><tt class="py-lineno"> 79</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>
</div><a name="L80"></a><tt class="py-lineno"> 80</tt> <tt class="py-line"> <tt class="py-docstring">"""Merge the annotations from tokens_old into tokens_new, when the</tt> </tt>
<a name="L81"></a><tt class="py-lineno"> 81</tt> <tt class="py-line"><tt class="py-docstring"> tokens in the new document already existed in the old document.</tt> </tt>
<a name="L82"></a><tt class="py-lineno"> 82</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
<a name="L83"></a><tt class="py-lineno"> 83</tt> <tt class="py-line"> <tt class="py-name">s</tt> <tt class="py-op">=</tt> <tt id="link-21" 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-21', 'InsensitiveSequenceMatcher', 'link-21');">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>
<a name="L84"></a><tt class="py-lineno"> 84</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>
<a name="L85"></a><tt class="py-lineno"> 85</tt> <tt class="py-line"> </tt>
<a name="L86"></a><tt class="py-lineno"> 86</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>
<a name="L87"></a><tt class="py-lineno"> 87</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>
<a name="L88"></a><tt class="py-lineno"> 88</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>
<a name="L89"></a><tt class="py-lineno"> 89</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>
<a name="L90"></a><tt class="py-lineno"> 90</tt> <tt class="py-line"> <tt id="link-22" 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-22', 'copy_annotations', 'link-22');">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>
</div><a name="L91"></a><tt class="py-lineno"> 91</tt> <tt class="py-line"> </tt>
<a name="copy_annotations"></a><div id="copy_annotations-def"><a name="L92"></a><tt class="py-lineno"> 92</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>
</div><a name="L93"></a><tt class="py-lineno"> 93</tt> <tt class="py-line"> <tt class="py-docstring">"""</tt> </tt>
<a name="L94"></a><tt class="py-lineno"> 94</tt> <tt class="py-line"><tt class="py-docstring"> Copy annotations from the tokens listed in src to the tokens in dest</tt> </tt>
<a name="L95"></a><tt class="py-lineno"> 95</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
<a name="L96"></a><tt class="py-lineno"> 96</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>
<a name="L97"></a><tt class="py-lineno"> 97</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>
<a name="L98"></a><tt class="py-lineno"> 98</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>
</div><a name="L99"></a><tt class="py-lineno"> 99</tt> <tt class="py-line"> </tt>
<a name="compress_tokens"></a><div id="compress_tokens-def"><a name="L100"></a><tt class="py-lineno">100</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>
</div><div id="compress_tokens-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="compress_tokens-expanded"><a name="L101"></a><tt class="py-lineno">101</tt> <tt class="py-line"> <tt class="py-docstring">"""</tt> </tt>
<a name="L102"></a><tt class="py-lineno">102</tt> <tt class="py-line"><tt class="py-docstring"> Combine adjacent tokens when there is no HTML between the tokens, </tt> </tt>
<a name="L103"></a><tt class="py-lineno">103</tt> <tt class="py-line"><tt class="py-docstring"> and they share an annotation</tt> </tt>
<a name="L104"></a><tt class="py-lineno">104</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
<a name="L105"></a><tt class="py-lineno">105</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>
<a name="L106"></a><tt class="py-lineno">106</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>
<a name="L107"></a><tt class="py-lineno">107</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>
<a name="L108"></a><tt class="py-lineno">108</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>
<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 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>
<a name="L110"></a><tt class="py-lineno">110</tt> <tt class="py-line"> <tt id="link-23" 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-23', 'compress_merge_back', 'link-23');">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>
<a name="L111"></a><tt class="py-lineno">111</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L112"></a><tt class="py-lineno">112</tt> <tt class="py-line"> <tt class="py-name">result</tt><tt class="py-op">.</tt><tt id="link-24" class="py-name" targets="Method lxml.etree._Element.append()=lxml.etree._Element-class.html#append"><a title="lxml.etree._Element.append" class="py-name" href="#" onclick="return doclink('link-24', 'append', 'link-24');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">tok</tt><tt class="py-op">)</tt> </tt>
<a name="L113"></a><tt class="py-lineno">113</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">result</tt> </tt>
</div><a name="L114"></a><tt class="py-lineno">114</tt> <tt class="py-line"> </tt>
<a name="compress_merge_back"></a><div id="compress_merge_back-def"><a name="L115"></a><tt class="py-lineno">115</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>
</div><a name="L116"></a><tt class="py-lineno">116</tt> <tt class="py-line"> <tt class="py-docstring">""" Merge tok into the last element of tokens (modifying the list of</tt> </tt>
<a name="L117"></a><tt class="py-lineno">117</tt> <tt class="py-line"><tt class="py-docstring"> tokens in-place). """</tt> </tt>
<a name="L118"></a><tt class="py-lineno">118</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>
<a name="L119"></a><tt class="py-lineno">119</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt id="link-25" 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
lxml.html.InputElement.type" class="py-name" href="#" onclick="return doclink('link-25', 'type', 'link-25');">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-26" 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-26', 'token', 'link-26');">token</a></tt> <tt class="py-keyword">or</tt> <tt id="link-27" class="py-name"><a title="lxml.etree._LogEntry.type
lxml.html.InputElement.type" class="py-name" href="#" onclick="return doclink('link-27', 'type', 'link-25');">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-28" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-28', 'token', 'link-26');">token</a></tt><tt class="py-op">:</tt> </tt>
<a name="L120"></a><tt class="py-lineno">120</tt> <tt class="py-line"> <tt class="py-name">tokens</tt><tt class="py-op">.</tt><tt id="link-29" class="py-name"><a title="lxml.etree._Element.append" class="py-name" href="#" onclick="return doclink('link-29', 'append', 'link-24');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">tok</tt><tt class="py-op">)</tt> </tt>
<a name="L121"></a><tt class="py-lineno">121</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L122"></a><tt class="py-lineno">122</tt> <tt class="py-line"> <tt id="link-30" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-30', 'text', 'link-11');">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>
<a name="L123"></a><tt class="py-lineno">123</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>
<a name="L124"></a><tt class="py-lineno">124</tt> <tt class="py-line"> <tt id="link-31" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-31', 'text', 'link-11');">text</a></tt> <tt class="py-op">+=</tt> <tt class="py-name">last</tt><tt class="py-op">.</tt><tt class="py-name">trailing_whitespace</tt> </tt>
<a name="L125"></a><tt class="py-lineno">125</tt> <tt class="py-line"> <tt id="link-32" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-32', 'text', 'link-11');">text</a></tt> <tt class="py-op">+=</tt> <tt class="py-name">tok</tt> </tt>
<a name="L126"></a><tt class="py-lineno">126</tt> <tt class="py-line"> <tt class="py-name">merged</tt> <tt class="py-op">=</tt> <tt id="link-33" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-33', 'token', 'link-26');">token</a></tt><tt class="py-op">(</tt><tt id="link-34" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-34', 'text', 'link-11');">text</a></tt><tt class="py-op">,</tt> </tt>
<a name="L127"></a><tt class="py-lineno">127</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>
<a name="L128"></a><tt class="py-lineno">128</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>
<a name="L129"></a><tt class="py-lineno">129</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>
<a name="L130"></a><tt class="py-lineno">130</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>
<a name="L131"></a><tt class="py-lineno">131</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>
</div><a name="L132"></a><tt class="py-lineno">132</tt> <tt class="py-line"> </tt>
<a name="markup_serialize_tokens"></a><div id="markup_serialize_tokens-def"><a name="L133"></a><tt class="py-lineno">133</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>
</div><div id="markup_serialize_tokens-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="markup_serialize_tokens-expanded"><a name="L134"></a><tt class="py-lineno">134</tt> <tt class="py-line"> <tt class="py-docstring">"""</tt> </tt>
<a name="L135"></a><tt class="py-lineno">135</tt> <tt class="py-line"><tt class="py-docstring"> Serialize the list of tokens into a list of text chunks, calling</tt> </tt>
<a name="L136"></a><tt class="py-lineno">136</tt> <tt class="py-line"><tt class="py-docstring"> markup_func around text to add annotations.</tt> </tt>
<a name="L137"></a><tt class="py-lineno">137</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
<a name="L138"></a><tt class="py-lineno">138</tt> <tt class="py-line"> <tt class="py-keyword">for</tt> <tt id="link-35" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-35', 'token', 'link-26');">token</a></tt> <tt class="py-keyword">in</tt> <tt class="py-name">tokens</tt><tt class="py-op">:</tt> </tt>
<a name="L139"></a><tt class="py-lineno">139</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-36" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-36', 'token', 'link-26');">token</a></tt><tt class="py-op">.</tt><tt class="py-name">pre_tags</tt><tt class="py-op">:</tt> </tt>
<a name="L140"></a><tt class="py-lineno">140</tt> <tt class="py-line"> <tt class="py-keyword">yield</tt> <tt class="py-name">pre</tt> </tt>
<a name="L141"></a><tt class="py-lineno">141</tt> <tt class="py-line"> <tt id="link-37" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
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-26');">token</a></tt><tt class="py-op">.</tt><tt id="link-39" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-39', 'html', 'link-3');">html</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L142"></a><tt class="py-lineno">142</tt> <tt class="py-line"> <tt id="link-40" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
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-name">markup_func</tt><tt class="py-op">(</tt><tt id="link-41" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-41', 'html', 'link-3');">html</a></tt><tt class="py-op">,</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-26');">token</a></tt><tt class="py-op">.</tt><tt class="py-name">annotation</tt><tt class="py-op">)</tt> </tt>
<a name="L143"></a><tt class="py-lineno">143</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt id="link-43" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-43', 'token', 'link-26');">token</a></tt><tt class="py-op">.</tt><tt class="py-name">trailing_whitespace</tt><tt class="py-op">:</tt> </tt>
<a name="L144"></a><tt class="py-lineno">144</tt> <tt class="py-line"> <tt id="link-44" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-44', 'html', 'link-3');">html</a></tt> <tt class="py-op">+=</tt> <tt id="link-45" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-45', 'token', 'link-26');">token</a></tt><tt class="py-op">.</tt><tt class="py-name">trailing_whitespace</tt> </tt>
<a name="L145"></a><tt class="py-lineno">145</tt> <tt class="py-line"> <tt class="py-keyword">yield</tt> <tt id="link-46" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-46', 'html', 'link-3');">html</a></tt> </tt>
<a name="L146"></a><tt class="py-lineno">146</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-47" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-47', 'token', 'link-26');">token</a></tt><tt class="py-op">.</tt><tt class="py-name">post_tags</tt><tt class="py-op">:</tt> </tt>
<a name="L147"></a><tt class="py-lineno">147</tt> <tt class="py-line"> <tt class="py-keyword">yield</tt> <tt class="py-name">post</tt> </tt>
</div><a name="L148"></a><tt class="py-lineno">148</tt> <tt class="py-line"> </tt>
<a name="L149"></a><tt class="py-lineno">149</tt> <tt class="py-line"> </tt>
<a name="L150"></a><tt class="py-lineno">150</tt> <tt class="py-line"><tt class="py-comment">############################################################</tt> </tt>
<a name="L151"></a><tt class="py-lineno">151</tt> <tt class="py-line"><tt class="py-comment">## HTML Diffs</tt> </tt>
<a name="L152"></a><tt class="py-lineno">152</tt> <tt class="py-line"><tt class="py-comment">############################################################</tt> </tt>
<a name="L153"></a><tt class="py-lineno">153</tt> <tt class="py-line"> </tt>
<a name="htmldiff"></a><div id="htmldiff-def"><a name="L154"></a><tt class="py-lineno">154</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>
</div><div id="htmldiff-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="htmldiff-expanded"><a name="L155"></a><tt class="py-lineno">155</tt> <tt class="py-line"> <tt class="py-comment">## FIXME: this should take parsed documents too, and use their body</tt> </tt>
<a name="L156"></a><tt class="py-lineno">156</tt> <tt class="py-line"> <tt class="py-comment">## or other content.</tt> </tt>
<a name="L157"></a><tt class="py-lineno">157</tt> <tt class="py-line"> <tt class="py-docstring">""" Do a diff of the old and new document. The documents are HTML</tt> </tt>
<a name="L158"></a><tt class="py-lineno">158</tt> <tt class="py-line"><tt class="py-docstring"> *fragments* (str/UTF8 or unicode), they are not complete documents</tt> </tt>
<a name="L159"></a><tt class="py-lineno">159</tt> <tt class="py-line"><tt class="py-docstring"> (i.e., no <html> tag).</tt> </tt>
<a name="L160"></a><tt class="py-lineno">160</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L161"></a><tt class="py-lineno">161</tt> <tt class="py-line"><tt class="py-docstring"> Returns HTML with <ins> and <del> tags added around the</tt> </tt>
<a name="L162"></a><tt class="py-lineno">162</tt> <tt class="py-line"><tt class="py-docstring"> appropriate text. </tt> </tt>
<a name="L163"></a><tt class="py-lineno">163</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L164"></a><tt class="py-lineno">164</tt> <tt class="py-line"><tt class="py-docstring"> Markup is generally ignored, with the markup from new_html</tt> </tt>
<a name="L165"></a><tt class="py-lineno">165</tt> <tt class="py-line"><tt class="py-docstring"> preserved, and possibly some markup from old_html (though it is</tt> </tt>
<a name="L166"></a><tt class="py-lineno">166</tt> <tt class="py-line"><tt class="py-docstring"> considered acceptable to lose some of the old markup). Only the</tt> </tt>
<a name="L167"></a><tt class="py-lineno">167</tt> <tt class="py-line"><tt class="py-docstring"> words in the HTML are diffed. The exception is <img> tags, which</tt> </tt>
<a name="L168"></a><tt class="py-lineno">168</tt> <tt class="py-line"><tt class="py-docstring"> are treated like words, and the href attribute of <a> tags, which</tt> </tt>
<a name="L169"></a><tt class="py-lineno">169</tt> <tt class="py-line"><tt class="py-docstring"> are noted inside the tag itself when there are changes.</tt> </tt>
<a name="L170"></a><tt class="py-lineno">170</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
<a name="L171"></a><tt class="py-lineno">171</tt> <tt class="py-line"> <tt class="py-name">old_html_tokens</tt> <tt class="py-op">=</tt> <tt id="link-48" class="py-name"><a title="lxml.html.diff.tokenize" class="py-name" href="#" onclick="return doclink('link-48', 'tokenize', 'link-20');">tokenize</a></tt><tt class="py-op">(</tt><tt class="py-name">old_html</tt><tt class="py-op">)</tt> </tt>
<a name="L172"></a><tt class="py-lineno">172</tt> <tt class="py-line"> <tt class="py-name">new_html_tokens</tt> <tt class="py-op">=</tt> <tt id="link-49" class="py-name"><a title="lxml.html.diff.tokenize" class="py-name" href="#" onclick="return doclink('link-49', 'tokenize', 'link-20');">tokenize</a></tt><tt class="py-op">(</tt><tt class="py-name">new_html</tt><tt class="py-op">)</tt> </tt>
<a name="L173"></a><tt class="py-lineno">173</tt> <tt class="py-line"> <tt class="py-name">result</tt> <tt class="py-op">=</tt> <tt id="link-50" 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-50', 'htmldiff_tokens', 'link-50');">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>
<a name="L174"></a><tt class="py-lineno">174</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 class="py-name">join</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-51" class="py-name"><a title="lxml.doctestcompare.strip" class="py-name" href="#" onclick="return doclink('link-51', 'strip', 'link-19');">strip</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L175"></a><tt class="py-lineno">175</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt id="link-52" 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-52', 'fixup_ins_del_tags', 'link-52');">fixup_ins_del_tags</a></tt><tt class="py-op">(</tt><tt class="py-name">result</tt><tt class="py-op">)</tt> </tt>
</div><a name="L176"></a><tt class="py-lineno">176</tt> <tt class="py-line"> </tt>
<a name="htmldiff_tokens"></a><div id="htmldiff_tokens-def"><a name="L177"></a><tt class="py-lineno">177</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>
</div><div id="htmldiff_tokens-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="htmldiff_tokens-expanded"><a name="L178"></a><tt class="py-lineno">178</tt> <tt class="py-line"> <tt class="py-docstring">""" Does a diff on the tokens themselves, returning a list of text</tt> </tt>
<a name="L179"></a><tt class="py-lineno">179</tt> <tt class="py-line"><tt class="py-docstring"> chunks (not tokens).</tt> </tt>
<a name="L180"></a><tt class="py-lineno">180</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
<a name="L181"></a><tt class="py-lineno">181</tt> <tt class="py-line"> <tt class="py-comment"># There are several passes as we do the differences. The tokens</tt> </tt>
<a name="L182"></a><tt class="py-lineno">182</tt> <tt class="py-line"> <tt class="py-comment"># isolate the portion of the content we care to diff; difflib does</tt> </tt>
<a name="L183"></a><tt class="py-lineno">183</tt> <tt class="py-line"> <tt class="py-comment"># all the actual hard work at that point. </tt> </tt>
<a name="L184"></a><tt class="py-lineno">184</tt> <tt class="py-line"> <tt class="py-comment">#</tt> </tt>
<a name="L185"></a><tt class="py-lineno">185</tt> <tt class="py-line"> <tt class="py-comment"># Then we must create a valid document from pieces of both the old</tt> </tt>
<a name="L186"></a><tt class="py-lineno">186</tt> <tt class="py-line"> <tt class="py-comment"># document and the new document. We generally prefer to take</tt> </tt>
<a name="L187"></a><tt class="py-lineno">187</tt> <tt class="py-line"> <tt class="py-comment"># markup from the new document, and only do a best effort attempt</tt> </tt>
<a name="L188"></a><tt class="py-lineno">188</tt> <tt class="py-line"> <tt class="py-comment"># to keep markup from the old document; anything that we can't</tt> </tt>
<a name="L189"></a><tt class="py-lineno">189</tt> <tt class="py-line"> <tt class="py-comment"># resolve we throw away. Also we try to put the deletes as close</tt> </tt>
<a name="L190"></a><tt class="py-lineno">190</tt> <tt class="py-line"> <tt class="py-comment"># to the location where we think they would have been -- because</tt> </tt>
<a name="L191"></a><tt class="py-lineno">191</tt> <tt class="py-line"> <tt class="py-comment"># we are only keeping the markup from the new document, it can be</tt> </tt>
<a name="L192"></a><tt class="py-lineno">192</tt> <tt class="py-line"> <tt class="py-comment"># fuzzy where in the new document the old text would have gone.</tt> </tt>
<a name="L193"></a><tt class="py-lineno">193</tt> <tt class="py-line"> <tt class="py-comment"># Again we just do a best effort attempt.</tt> </tt>
<a name="L194"></a><tt class="py-lineno">194</tt> <tt class="py-line"> <tt class="py-name">s</tt> <tt class="py-op">=</tt> <tt id="link-53" class="py-name"><a title="lxml.html.diff.InsensitiveSequenceMatcher" class="py-name" href="#" onclick="return doclink('link-53', 'InsensitiveSequenceMatcher', 'link-21');">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>
<a name="L195"></a><tt class="py-lineno">195</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>
<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 class="py-op">[</tt><tt class="py-op">]</tt> </tt>
<a name="L197"></a><tt class="py-lineno">197</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>
<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">'equal'</tt><tt class="py-op">:</tt> </tt>
<a name="L199"></a><tt class="py-lineno">199</tt> <tt class="py-line"> <tt class="py-name">result</tt><tt class="py-op">.</tt><tt id="link-54" class="py-name" targets="Method lxml.etree._Element.extend()=lxml.etree._Element-class.html#extend"><a title="lxml.etree._Element.extend" class="py-name" href="#" onclick="return doclink('link-54', 'extend', 'link-54');">extend</a></tt><tt class="py-op">(</tt><tt id="link-55" 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-55', 'expand_tokens', 'link-55');">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>
<a name="L200"></a><tt class="py-lineno">200</tt> <tt class="py-line"> <tt class="py-keyword">continue</tt> </tt>
<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">'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>
<a name="L202"></a><tt class="py-lineno">202</tt> <tt class="py-line"> <tt class="py-name">ins_tokens</tt> <tt class="py-op">=</tt> <tt id="link-56" class="py-name"><a title="lxml.html.diff.expand_tokens" class="py-name" href="#" onclick="return doclink('link-56', 'expand_tokens', 'link-55');">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>
<a name="L203"></a><tt class="py-lineno">203</tt> <tt class="py-line"> <tt id="link-57" 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-57', 'merge_insert', 'link-57');">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>
<a name="L204"></a><tt class="py-lineno">204</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>
<a name="L205"></a><tt class="py-lineno">205</tt> <tt class="py-line"> <tt class="py-name">del_tokens</tt> <tt class="py-op">=</tt> <tt id="link-58" class="py-name"><a title="lxml.html.diff.expand_tokens" class="py-name" href="#" onclick="return doclink('link-58', 'expand_tokens', 'link-55');">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>
<a name="L206"></a><tt class="py-lineno">206</tt> <tt class="py-line"> <tt id="link-59" 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-59', 'merge_delete', 'link-59');">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>
<a name="L207"></a><tt class="py-lineno">207</tt> <tt class="py-line"> <tt class="py-comment"># If deletes were inserted directly as <del> then we'd have an</tt> </tt>
<a name="L208"></a><tt class="py-lineno">208</tt> <tt class="py-line"> <tt class="py-comment"># invalid document at this point. Instead we put in special</tt> </tt>
<a name="L209"></a><tt class="py-lineno">209</tt> <tt class="py-line"> <tt class="py-comment"># markers, and when the complete diffed document has been created</tt> </tt>
<a name="L210"></a><tt class="py-lineno">210</tt> <tt class="py-line"> <tt class="py-comment"># we try to move the deletes around and resolve any problems.</tt> </tt>
<a name="L211"></a><tt class="py-lineno">211</tt> <tt class="py-line"> <tt class="py-name">result</tt> <tt class="py-op">=</tt> <tt id="link-60" 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-60', 'cleanup_delete', 'link-60');">cleanup_delete</a></tt><tt class="py-op">(</tt><tt class="py-name">result</tt><tt class="py-op">)</tt> </tt>
<a name="L212"></a><tt class="py-lineno">212</tt> <tt class="py-line"> </tt>
<a name="L213"></a><tt class="py-lineno">213</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">result</tt> </tt>
</div><a name="L214"></a><tt class="py-lineno">214</tt> <tt class="py-line"> </tt>
<a name="expand_tokens"></a><div id="expand_tokens-def"><a name="L215"></a><tt class="py-lineno">215</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>
</div><div id="expand_tokens-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="expand_tokens-expanded"><a name="L216"></a><tt class="py-lineno">216</tt> <tt class="py-line"> <tt class="py-docstring">"""Given a list of tokens, return a generator of the chunks of</tt> </tt>
<a name="L217"></a><tt class="py-lineno">217</tt> <tt class="py-line"><tt class="py-docstring"> text for the data in the tokens.</tt> </tt>
<a name="L218"></a><tt class="py-lineno">218</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
<a name="L219"></a><tt class="py-lineno">219</tt> <tt class="py-line"> <tt class="py-keyword">for</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-26');">token</a></tt> <tt class="py-keyword">in</tt> <tt class="py-name">tokens</tt><tt class="py-op">:</tt> </tt>
<a name="L220"></a><tt class="py-lineno">220</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-62" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-62', 'token', 'link-26');">token</a></tt><tt class="py-op">.</tt><tt class="py-name">pre_tags</tt><tt class="py-op">:</tt> </tt>
<a name="L221"></a><tt class="py-lineno">221</tt> <tt class="py-line"> <tt class="py-keyword">yield</tt> <tt class="py-name">pre</tt> </tt>
<a name="L222"></a><tt class="py-lineno">222</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-63" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-63', 'token', 'link-26');">token</a></tt><tt class="py-op">.</tt><tt id="link-64" 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
lxml.html.diff.token.hide_when_equal" class="py-name" href="#" onclick="return doclink('link-64', 'hide_when_equal', 'link-64');">hide_when_equal</a></tt><tt class="py-op">:</tt> </tt>
<a name="L223"></a><tt class="py-lineno">223</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt id="link-65" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-65', 'token', 'link-26');">token</a></tt><tt class="py-op">.</tt><tt class="py-name">trailing_whitespace</tt><tt class="py-op">:</tt> </tt>
<a name="L224"></a><tt class="py-lineno">224</tt> <tt class="py-line"> <tt class="py-keyword">yield</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-26');">token</a></tt><tt class="py-op">.</tt><tt id="link-67" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-67', 'html', 'link-3');">html</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> <tt class="py-op">+</tt> <tt id="link-68" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-68', 'token', 'link-26');">token</a></tt><tt class="py-op">.</tt><tt class="py-name">trailing_whitespace</tt> </tt>
<a name="L225"></a><tt class="py-lineno">225</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L226"></a><tt class="py-lineno">226</tt> <tt class="py-line"> <tt class="py-keyword">yield</tt> <tt id="link-69" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-69', 'token', 'link-26');">token</a></tt><tt class="py-op">.</tt><tt id="link-70" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-70', 'html', 'link-3');">html</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L227"></a><tt class="py-lineno">227</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-71" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-71', 'token', 'link-26');">token</a></tt><tt class="py-op">.</tt><tt class="py-name">post_tags</tt><tt class="py-op">:</tt> </tt>
<a name="L228"></a><tt class="py-lineno">228</tt> <tt class="py-line"> <tt class="py-keyword">yield</tt> <tt class="py-name">post</tt> </tt>
</div><a name="L229"></a><tt class="py-lineno">229</tt> <tt class="py-line"> </tt>
<a name="merge_insert"></a><div id="merge_insert-def"><a name="L230"></a><tt class="py-lineno">230</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>
</div><div id="merge_insert-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="merge_insert-expanded"><a name="L231"></a><tt class="py-lineno">231</tt> <tt class="py-line"> <tt class="py-docstring">""" doc is the already-handled document (as a list of text chunks);</tt> </tt>
<a name="L232"></a><tt class="py-lineno">232</tt> <tt class="py-line"><tt class="py-docstring"> here we add <ins>ins_chunks</ins> to the end of that. """</tt> </tt>
<a name="L233"></a><tt class="py-lineno">233</tt> <tt class="py-line"> <tt class="py-comment"># Though we don't throw away unbalanced_start or unbalanced_end</tt> </tt>
<a name="L234"></a><tt class="py-lineno">234</tt> <tt class="py-line"> <tt class="py-comment"># (we assume there is accompanying markup later or earlier in the</tt> </tt>
<a name="L235"></a><tt class="py-lineno">235</tt> <tt class="py-line"> <tt class="py-comment"># document), we only put <ins> around the balanced portion.</tt> </tt>
<a name="L236"></a><tt class="py-lineno">236</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-72" 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-72', 'split_unbalanced', 'link-72');">split_unbalanced</a></tt><tt class="py-op">(</tt><tt class="py-name">ins_chunks</tt><tt class="py-op">)</tt> </tt>
<a name="L237"></a><tt class="py-lineno">237</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._Element.extend" class="py-name" href="#" onclick="return doclink('link-73', 'extend', 'link-54');">extend</a></tt><tt class="py-op">(</tt><tt class="py-name">unbalanced_start</tt><tt class="py-op">)</tt> </tt>
<a name="L238"></a><tt class="py-lineno">238</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>
<a name="L239"></a><tt class="py-lineno">239</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>
<a name="L240"></a><tt class="py-lineno">240</tt> <tt class="py-line"> <tt class="py-comment"># a space</tt> </tt>
<a name="L241"></a><tt class="py-lineno">241</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>
<a name="L242"></a><tt class="py-lineno">242</tt> <tt class="py-line"> <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt id="link-74" class="py-name"><a title="lxml.etree._Element.append" class="py-name" href="#" onclick="return doclink('link-74', 'append', 'link-24');">append</a></tt><tt class="py-op">(</tt><tt class="py-string">'<ins>'</tt><tt class="py-op">)</tt> </tt>
<a name="L243"></a><tt class="py-lineno">243</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>
<a name="L244"></a><tt class="py-lineno">244</tt> <tt class="py-line"> <tt class="py-comment"># We move space outside of </ins></tt> </tt>
<a name="L245"></a><tt class="py-lineno">245</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>
<a name="L246"></a><tt class="py-lineno">246</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._Element.extend" class="py-name" href="#" onclick="return doclink('link-75', 'extend', 'link-54');">extend</a></tt><tt class="py-op">(</tt><tt class="py-name">balanced</tt><tt class="py-op">)</tt> </tt>
<a name="L247"></a><tt class="py-lineno">247</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._Element.append" class="py-name" href="#" onclick="return doclink('link-76', 'append', 'link-24');">append</a></tt><tt class="py-op">(</tt><tt class="py-string">'</ins> '</tt><tt class="py-op">)</tt> </tt>
<a name="L248"></a><tt class="py-lineno">248</tt> <tt class="py-line"> <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt id="link-77" class="py-name"><a title="lxml.etree._Element.extend" class="py-name" href="#" onclick="return doclink('link-77', 'extend', 'link-54');">extend</a></tt><tt class="py-op">(</tt><tt class="py-name">unbalanced_end</tt><tt class="py-op">)</tt> </tt>
</div><a name="L249"></a><tt class="py-lineno">249</tt> <tt class="py-line"> </tt>
<a name="L250"></a><tt class="py-lineno">250</tt> <tt class="py-line"><tt class="py-comment"># These are sentinals to represent the start and end of a <del></tt> </tt>
<a name="L251"></a><tt class="py-lineno">251</tt> <tt class="py-line"><tt class="py-comment"># segment, until we do the cleanup phase to turn them into proper</tt> </tt>
<a name="L252"></a><tt class="py-lineno">252</tt> <tt class="py-line"><tt class="py-comment"># markup:</tt> </tt>
<a name="DEL_START"></a><div id="DEL_START-def"><a name="L253"></a><tt class="py-lineno">253</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>
</div><div id="DEL_START-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="DEL_START-expanded"><a name="L254"></a><tt class="py-lineno">254</tt> <tt class="py-line"> <tt class="py-keyword">pass</tt> </tt>
</div><a name="DEL_END"></a><div id="DEL_END-def"><a name="L255"></a><tt class="py-lineno">255</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>
</div><div id="DEL_END-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="DEL_END-expanded"><a name="L256"></a><tt class="py-lineno">256</tt> <tt class="py-line"> <tt class="py-keyword">pass</tt> </tt>
</div><a name="L257"></a><tt class="py-lineno">257</tt> <tt class="py-line"> </tt>
<a name="NoDeletes"></a><div id="NoDeletes-def"><a name="L258"></a><tt class="py-lineno">258</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>
</div><div id="NoDeletes-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="NoDeletes-expanded"><a name="L259"></a><tt class="py-lineno">259</tt> <tt class="py-line"> <tt class="py-docstring">""" Raised when the document no longer contains any pending deletes</tt> </tt>
<a name="L260"></a><tt class="py-lineno">260</tt> <tt class="py-line"><tt class="py-docstring"> (DEL_START/DEL_END) """</tt> </tt>
</div><a name="L261"></a><tt class="py-lineno">261</tt> <tt class="py-line"> </tt>
<a name="merge_delete"></a><div id="merge_delete-def"><a name="L262"></a><tt class="py-lineno">262</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>
</div><div id="merge_delete-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="merge_delete-expanded"><a name="L263"></a><tt class="py-lineno">263</tt> <tt class="py-line"> <tt class="py-docstring">""" Adds the text chunks in del_chunks to the document doc (another</tt> </tt>
<a name="L264"></a><tt class="py-lineno">264</tt> <tt class="py-line"><tt class="py-docstring"> list of text chunks) with marker to show it is a delete.</tt> </tt>
<a name="L265"></a><tt class="py-lineno">265</tt> <tt class="py-line"><tt class="py-docstring"> cleanup_delete later resolves these markers into <del> tags."""</tt> </tt>
<a name="L266"></a><tt class="py-lineno">266</tt> <tt class="py-line"> <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt id="link-78" class="py-name"><a title="lxml.etree._Element.append" class="py-name" href="#" onclick="return doclink('link-78', 'append', 'link-24');">append</a></tt><tt class="py-op">(</tt><tt id="link-79" 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-79', 'DEL_START', 'link-79');">DEL_START</a></tt><tt class="py-op">)</tt> </tt>
<a name="L267"></a><tt class="py-lineno">267</tt> <tt class="py-line"> <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt id="link-80" class="py-name"><a title="lxml.etree._Element.extend" class="py-name" href="#" onclick="return doclink('link-80', 'extend', 'link-54');">extend</a></tt><tt class="py-op">(</tt><tt class="py-name">del_chunks</tt><tt class="py-op">)</tt> </tt>
<a name="L268"></a><tt class="py-lineno">268</tt> <tt class="py-line"> <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt id="link-81" class="py-name"><a title="lxml.etree._Element.append" class="py-name" href="#" onclick="return doclink('link-81', 'append', 'link-24');">append</a></tt><tt class="py-op">(</tt><tt id="link-82" 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-82', 'DEL_END', 'link-82');">DEL_END</a></tt><tt class="py-op">)</tt> </tt>
</div><a name="L269"></a><tt class="py-lineno">269</tt> <tt class="py-line"> </tt>
<a name="cleanup_delete"></a><div id="cleanup_delete-def"><a name="L270"></a><tt class="py-lineno">270</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>
</div><div id="cleanup_delete-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="cleanup_delete-expanded"><a name="L271"></a><tt class="py-lineno">271</tt> <tt class="py-line"> <tt class="py-docstring">""" Cleans up any DEL_START/DEL_END markers in the document, replacing</tt> </tt>
<a name="L272"></a><tt class="py-lineno">272</tt> <tt class="py-line"><tt class="py-docstring"> them with <del></del>. To do this while keeping the document</tt> </tt>
<a name="L273"></a><tt class="py-lineno">273</tt> <tt class="py-line"><tt class="py-docstring"> valid, it may need to drop some tags (either start or end tags).</tt> </tt>
<a name="L274"></a><tt class="py-lineno">274</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L275"></a><tt class="py-lineno">275</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>
<a name="L276"></a><tt class="py-lineno">276</tt> <tt class="py-line"><tt class="py-docstring"> similar location where it was originally located (e.g., moving a</tt> </tt>
<a name="L277"></a><tt class="py-lineno">277</tt> <tt class="py-line"><tt class="py-docstring"> delete into preceding <div> tag, if the del looks like (DEL_START,</tt> </tt>
<a name="L278"></a><tt class="py-lineno">278</tt> <tt class="py-line"><tt class="py-docstring"> 'Text</div>', DEL_END)"""</tt> </tt>
<a name="L279"></a><tt class="py-lineno">279</tt> <tt class="py-line"> <tt class="py-keyword">while</tt> <tt class="py-number">1</tt><tt class="py-op">:</tt> </tt>
<a name="L280"></a><tt class="py-lineno">280</tt> <tt class="py-line"> <tt class="py-comment"># Find a pending DEL_START/DEL_END, splitting the document</tt> </tt>
<a name="L281"></a><tt class="py-lineno">281</tt> <tt class="py-line"> <tt class="py-comment"># into stuff-preceding-DEL_START, stuff-inside, and</tt> </tt>
<a name="L282"></a><tt class="py-lineno">282</tt> <tt class="py-line"> <tt class="py-comment"># stuff-following-DEL_END</tt> </tt>
<a name="L283"></a><tt class="py-lineno">283</tt> <tt class="py-line"> <tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
<a name="L284"></a><tt class="py-lineno">284</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-83" 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-83', 'split_delete', 'link-83');">split_delete</a></tt><tt class="py-op">(</tt><tt class="py-name">chunks</tt><tt class="py-op">)</tt> </tt>
<a name="L285"></a><tt class="py-lineno">285</tt> <tt class="py-line"> <tt class="py-keyword">except</tt> <tt id="link-84" 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-84', 'NoDeletes', 'link-84');">NoDeletes</a></tt><tt class="py-op">:</tt> </tt>
<a name="L286"></a><tt class="py-lineno">286</tt> <tt class="py-line"> <tt class="py-comment"># Nothing found, we've cleaned up the entire doc</tt> </tt>
<a name="L287"></a><tt class="py-lineno">287</tt> <tt class="py-line"> <tt class="py-keyword">break</tt> </tt>
<a name="L288"></a><tt class="py-lineno">288</tt> <tt class="py-line"> <tt class="py-comment"># The stuff-inside-DEL_START/END may not be well balanced</tt> </tt>
<a name="L289"></a><tt class="py-lineno">289</tt> <tt class="py-line"> <tt class="py-comment"># markup. First we figure out what unbalanced portions there are:</tt> </tt>
<a name="L290"></a><tt class="py-lineno">290</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-85" class="py-name"><a title="lxml.html.diff.split_unbalanced" class="py-name" href="#" onclick="return doclink('link-85', 'split_unbalanced', 'link-72');">split_unbalanced</a></tt><tt class="py-op">(</tt><tt class="py-name">delete</tt><tt class="py-op">)</tt> </tt>
<a name="L291"></a><tt class="py-lineno">291</tt> <tt class="py-line"> <tt class="py-comment"># Then we move the span forward and/or backward based on these</tt> </tt>
<a name="L292"></a><tt class="py-lineno">292</tt> <tt class="py-line"> <tt class="py-comment"># unbalanced portions:</tt> </tt>
<a name="L293"></a><tt class="py-lineno">293</tt> <tt class="py-line"> <tt id="link-86" 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-86', 'locate_unbalanced_start', 'link-86');">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>
<a name="L294"></a><tt class="py-lineno">294</tt> <tt class="py-line"> <tt id="link-87" 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-87', 'locate_unbalanced_end', 'link-87');">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>
<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-name">pre_delete</tt> </tt>
<a name="L296"></a><tt class="py-lineno">296</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>
<a name="L297"></a><tt class="py-lineno">297</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>
<a name="L298"></a><tt class="py-lineno">298</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>
<a name="L299"></a><tt class="py-lineno">299</tt> <tt class="py-line"> <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt id="link-88" class="py-name"><a title="lxml.etree._Element.append" class="py-name" href="#" onclick="return doclink('link-88', 'append', 'link-24');">append</a></tt><tt class="py-op">(</tt><tt class="py-string">'<del>'</tt><tt class="py-op">)</tt> </tt>
<a name="L300"></a><tt class="py-lineno">300</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>
<a name="L301"></a><tt class="py-lineno">301</tt> <tt class="py-line"> <tt class="py-comment"># We move space outside of </del></tt> </tt>
<a name="L302"></a><tt class="py-lineno">302</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>
<a name="L303"></a><tt class="py-lineno">303</tt> <tt class="py-line"> <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt id="link-89" class="py-name"><a title="lxml.etree._Element.extend" class="py-name" href="#" onclick="return doclink('link-89', 'extend', 'link-54');">extend</a></tt><tt class="py-op">(</tt><tt class="py-name">balanced</tt><tt class="py-op">)</tt> </tt>
<a name="L304"></a><tt class="py-lineno">304</tt> <tt class="py-line"> <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt id="link-90" class="py-name"><a title="lxml.etree._Element.append" class="py-name" href="#" onclick="return doclink('link-90', 'append', 'link-24');">append</a></tt><tt class="py-op">(</tt><tt class="py-string">'</del> '</tt><tt class="py-op">)</tt> </tt>
<a name="L305"></a><tt class="py-lineno">305</tt> <tt class="py-line"> <tt class="py-name">doc</tt><tt class="py-op">.</tt><tt id="link-91" class="py-name"><a title="lxml.etree._Element.extend" class="py-name" href="#" onclick="return doclink('link-91', 'extend', 'link-54');">extend</a></tt><tt class="py-op">(</tt><tt class="py-name">post_delete</tt><tt class="py-op">)</tt> </tt>
<a name="L306"></a><tt class="py-lineno">306</tt> <tt class="py-line"> <tt class="py-name">chunks</tt> <tt class="py-op">=</tt> <tt class="py-name">doc</tt> </tt>
<a name="L307"></a><tt class="py-lineno">307</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">chunks</tt> </tt>
</div><a name="L308"></a><tt class="py-lineno">308</tt> <tt class="py-line"> </tt>
<a name="split_unbalanced"></a><div id="split_unbalanced-def"><a name="L309"></a><tt class="py-lineno">309</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>
</div><div id="split_unbalanced-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="split_unbalanced-expanded"><a name="L310"></a><tt class="py-lineno">310</tt> <tt class="py-line"> <tt class="py-docstring">"""Return (unbalanced_start, balanced, unbalanced_end), where each is</tt> </tt>
<a name="L311"></a><tt class="py-lineno">311</tt> <tt class="py-line"><tt class="py-docstring"> a list of text and tag chunks.</tt> </tt>
<a name="L312"></a><tt class="py-lineno">312</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L313"></a><tt class="py-lineno">313</tt> <tt class="py-line"><tt class="py-docstring"> unbalanced_start is a list of all the tags that are opened, but</tt> </tt>
<a name="L314"></a><tt class="py-lineno">314</tt> <tt class="py-line"><tt class="py-docstring"> not closed in this span. Similarly, unbalanced_end is a list of</tt> </tt>
<a name="L315"></a><tt class="py-lineno">315</tt> <tt class="py-line"><tt class="py-docstring"> tags that are closed but were not opened. Extracting these might</tt> </tt>
<a name="L316"></a><tt class="py-lineno">316</tt> <tt class="py-line"><tt class="py-docstring"> mean some reordering of the chunks."""</tt> </tt>
<a name="L317"></a><tt class="py-lineno">317</tt> <tt class="py-line"> <tt id="link-92" 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-92', 'start', 'link-92');">start</a></tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
<a name="L318"></a><tt class="py-lineno">318</tt> <tt class="py-line"> <tt id="link-93" 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-93', 'end', 'link-93');">end</a></tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
<a name="L319"></a><tt class="py-lineno">319</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>
<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 class="py-op">[</tt><tt class="py-op">]</tt> </tt>
<a name="L321"></a><tt class="py-lineno">321</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>
<a name="L322"></a><tt class="py-lineno">322</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">'<'</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L323"></a><tt class="py-lineno">323</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._Element.append" class="py-name" href="#" onclick="return doclink('link-94', 'append', 'link-24');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">chunk</tt><tt class="py-op">)</tt> </tt>
<a name="L324"></a><tt class="py-lineno">324</tt> <tt class="py-line"> <tt class="py-keyword">continue</tt> </tt>
<a name="L325"></a><tt class="py-lineno">325</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>
<a name="L326"></a><tt class="py-lineno">326</tt> <tt class="py-line"> <tt id="link-95" class="py-name" targets="Variable lxml.etree.DTD.name=lxml.etree.DTD-class.html#name,Variable lxml.etree._Entity.name=lxml.etree._Entity-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.DTD.name
lxml.etree._Entity.name
lxml.html.InputMixin.name
lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-95', 'name', 'link-95');">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-96" class="py-name"><a title="lxml.doctestcompare.strip" class="py-name" href="#" onclick="return doclink('link-96', 'strip', 'link-19');">strip</a></tt><tt class="py-op">(</tt><tt class="py-string">'<>/'</tt><tt class="py-op">)</tt> </tt>
<a name="L327"></a><tt class="py-lineno">327</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt id="link-97" class="py-name"><a title="lxml.etree.DTD.name
lxml.etree._Entity.name
lxml.html.InputMixin.name
lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-97', 'name', 'link-95');">name</a></tt> <tt class="py-keyword">in</tt> <tt id="link-98" 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
lxml.html.defs.empty_tags
lxml.html.diff.empty_tags" class="py-name" href="#" onclick="return doclink('link-98', 'empty_tags', 'link-98');">empty_tags</a></tt><tt class="py-op">:</tt> </tt>
<a name="L328"></a><tt class="py-lineno">328</tt> <tt class="py-line"> <tt class="py-name">balanced</tt><tt class="py-op">.</tt><tt id="link-99" class="py-name"><a title="lxml.etree._Element.append" class="py-name" href="#" onclick="return doclink('link-99', 'append', 'link-24');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">chunk</tt><tt class="py-op">)</tt> </tt>
<a name="L329"></a><tt class="py-lineno">329</tt> <tt class="py-line"> <tt class="py-keyword">continue</tt> </tt>
<a name="L330"></a><tt class="py-lineno">330</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">endtag</tt><tt class="py-op">:</tt> </tt>
<a name="L331"></a><tt class="py-lineno">331</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-100" class="py-name"><a title="lxml.etree.DTD.name
lxml.etree._Entity.name
lxml.html.InputMixin.name
lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-100', 'name', 'link-95');">name</a></tt><tt class="py-op">:</tt> </tt>
<a name="L332"></a><tt class="py-lineno">332</tt> <tt class="py-line"> <tt class="py-name">balanced</tt><tt class="py-op">.</tt><tt id="link-101" class="py-name"><a title="lxml.etree._Element.append" class="py-name" href="#" onclick="return doclink('link-101', 'append', 'link-24');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">chunk</tt><tt class="py-op">)</tt> </tt>
<a name="L333"></a><tt class="py-lineno">333</tt> <tt class="py-line"> <tt id="link-102" class="py-name"><a title="lxml.etree.DTD.name
lxml.etree._Entity.name
lxml.html.InputMixin.name
lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-102', 'name', 'link-95');">name</a></tt><tt class="py-op">,</tt> <tt class="py-name">pos</tt><tt class="py-op">,</tt> <tt id="link-103" 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,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
lxml.etree._Element.tag
lxml.etree._Entity.tag
lxml.etree._ProcessingInstruction.tag
lxml.tests.test_xpathevaluator.tag
xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-103', 'tag', 'link-103');">tag</a></tt> <tt class="py-op">=</tt> <tt class="py-name">tag_stack</tt><tt class="py-op">.</tt><tt id="link-104" 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-104', 'pop', 'link-104');">pop</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L334"></a><tt class="py-lineno">334</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-105" class="py-name"><a title="lxml.etree._Comment.tag
lxml.etree._Element.tag
lxml.etree._Entity.tag
lxml.etree._ProcessingInstruction.tag
lxml.tests.test_xpathevaluator.tag
xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-105', 'tag', 'link-103');">tag</a></tt> </tt>
<a name="L335"></a><tt class="py-lineno">335</tt> <tt class="py-line"> <tt class="py-keyword">elif</tt> <tt class="py-name">tag_stack</tt><tt class="py-op">:</tt> </tt>
<a name="L336"></a><tt class="py-lineno">336</tt> <tt class="py-line"> <tt id="link-106" class="py-name"><a title="lxml.etree.TreeBuilder.start" class="py-name" href="#" onclick="return doclink('link-106', 'start', 'link-92');">start</a></tt><tt class="py-op">.</tt><tt id="link-107" class="py-name"><a title="lxml.etree._Element.extend" class="py-name" href="#" onclick="return doclink('link-107', 'extend', 'link-54');">extend</a></tt><tt class="py-op">(</tt><tt class="py-op">[</tt><tt id="link-108" class="py-name"><a title="lxml.etree._Comment.tag
lxml.etree._Element.tag
lxml.etree._Entity.tag
lxml.etree._ProcessingInstruction.tag
lxml.tests.test_xpathevaluator.tag
xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-108', 'tag', 'link-103');">tag</a></tt> <tt class="py-keyword">for</tt> <tt id="link-109" class="py-name"><a title="lxml.etree.DTD.name
lxml.etree._Entity.name
lxml.html.InputMixin.name
lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-109', 'name', 'link-95');">name</a></tt><tt class="py-op">,</tt> <tt class="py-name">pos</tt><tt class="py-op">,</tt> <tt id="link-110" class="py-name"><a title="lxml.etree._Comment.tag
lxml.etree._Element.tag
lxml.etree._Entity.tag
lxml.etree._ProcessingInstruction.tag
lxml.tests.test_xpathevaluator.tag
xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-110', 'tag', 'link-103');">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>
<a name="L337"></a><tt class="py-lineno">337</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>
<a name="L338"></a><tt class="py-lineno">338</tt> <tt class="py-line"> <tt id="link-111" class="py-name"><a title="lxml.etree.TreeBuilder.end" class="py-name" href="#" onclick="return doclink('link-111', 'end', 'link-93');">end</a></tt><tt class="py-op">.</tt><tt id="link-112" class="py-name"><a title="lxml.etree._Element.append" class="py-name" href="#" onclick="return doclink('link-112', 'append', 'link-24');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">chunk</tt><tt class="py-op">)</tt> </tt>
<a name="L339"></a><tt class="py-lineno">339</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L340"></a><tt class="py-lineno">340</tt> <tt class="py-line"> <tt id="link-113" class="py-name"><a title="lxml.etree.TreeBuilder.end" class="py-name" href="#" onclick="return doclink('link-113', 'end', 'link-93');">end</a></tt><tt class="py-op">.</tt><tt id="link-114" class="py-name"><a title="lxml.etree._Element.append" class="py-name" href="#" onclick="return doclink('link-114', 'append', 'link-24');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">chunk</tt><tt class="py-op">)</tt> </tt>
<a name="L341"></a><tt class="py-lineno">341</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L342"></a><tt class="py-lineno">342</tt> <tt class="py-line"> <tt class="py-name">tag_stack</tt><tt class="py-op">.</tt><tt id="link-115" class="py-name"><a title="lxml.etree._Element.append" class="py-name" href="#" onclick="return doclink('link-115', 'append', 'link-24');">append</a></tt><tt class="py-op">(</tt><tt class="py-op">(</tt><tt id="link-116" class="py-name"><a title="lxml.etree.DTD.name
lxml.etree._Entity.name
lxml.html.InputMixin.name
lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-116', 'name', 'link-95');">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>
<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 id="link-117" class="py-name"><a title="lxml.etree._Element.append" class="py-name" href="#" onclick="return doclink('link-117', 'append', 'link-24');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">None</tt><tt class="py-op">)</tt> </tt>
<a name="L344"></a><tt class="py-lineno">344</tt> <tt class="py-line"> <tt id="link-118" class="py-name"><a title="lxml.etree.TreeBuilder.start" class="py-name" href="#" onclick="return doclink('link-118', 'start', 'link-92');">start</a></tt><tt class="py-op">.</tt><tt id="link-119" class="py-name"><a title="lxml.etree._Element.extend" class="py-name" href="#" onclick="return doclink('link-119', 'extend', 'link-54');">extend</a></tt><tt class="py-op">(</tt> </tt>
<a name="L345"></a><tt class="py-lineno">345</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-120" class="py-name"><a title="lxml.etree.DTD.name
lxml.etree._Entity.name
lxml.html.InputMixin.name
lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-120', 'name', 'link-95');">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>
<a name="L346"></a><tt class="py-lineno">346</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>
<a name="L347"></a><tt class="py-lineno">347</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt id="link-121" class="py-name"><a title="lxml.etree.TreeBuilder.start" class="py-name" href="#" onclick="return doclink('link-121', 'start', 'link-92');">start</a></tt><tt class="py-op">,</tt> <tt class="py-name">balanced</tt><tt class="py-op">,</tt> <tt id="link-122" class="py-name"><a title="lxml.etree.TreeBuilder.end" class="py-name" href="#" onclick="return doclink('link-122', 'end', 'link-93');">end</a></tt> </tt>
</div><a name="L348"></a><tt class="py-lineno">348</tt> <tt class="py-line"> </tt>
<a name="split_delete"></a><div id="split_delete-def"><a name="L349"></a><tt class="py-lineno">349</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>
</div><div id="split_delete-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="split_delete-expanded"><a name="L350"></a><tt class="py-lineno">350</tt> <tt class="py-line"> <tt class="py-docstring">""" Returns (stuff_before_DEL_START, stuff_inside_DEL_START_END,</tt> </tt>
<a name="L351"></a><tt class="py-lineno">351</tt> <tt class="py-line"><tt class="py-docstring"> stuff_after_DEL_END). Returns the first case found (there may be</tt> </tt>
<a name="L352"></a><tt class="py-lineno">352</tt> <tt class="py-line"><tt class="py-docstring"> more DEL_STARTs in stuff_after_DEL_END). Raises NoDeletes if</tt> </tt>
<a name="L353"></a><tt class="py-lineno">353</tt> <tt class="py-line"><tt class="py-docstring"> there's no DEL_START found. """</tt> </tt>
<a name="L354"></a><tt class="py-lineno">354</tt> <tt class="py-line"> <tt class="py-keyword">try</tt><tt class="py-op">:</tt> </tt>
<a name="L355"></a><tt class="py-lineno">355</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-123" 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-123', 'index', 'link-123');">index</a></tt><tt class="py-op">(</tt><tt id="link-124" class="py-name"><a title="lxml.html.diff.DEL_START" class="py-name" href="#" onclick="return doclink('link-124', 'DEL_START', 'link-79');">DEL_START</a></tt><tt class="py-op">)</tt> </tt>
<a name="L356"></a><tt class="py-lineno">356</tt> <tt class="py-line"> <tt class="py-keyword">except</tt> <tt class="py-name">ValueError</tt><tt class="py-op">:</tt> </tt>
<a name="L357"></a><tt class="py-lineno">357</tt> <tt class="py-line"> <tt class="py-keyword">raise</tt> <tt id="link-125" class="py-name"><a title="lxml.html.diff.NoDeletes" class="py-name" href="#" onclick="return doclink('link-125', 'NoDeletes', 'link-84');">NoDeletes</a></tt> </tt>
<a name="L358"></a><tt class="py-lineno">358</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-126" class="py-name"><a title="lxml.etree._Element.index" class="py-name" href="#" onclick="return doclink('link-126', 'index', 'link-123');">index</a></tt><tt class="py-op">(</tt><tt id="link-127" class="py-name"><a title="lxml.html.diff.DEL_END" class="py-name" href="#" onclick="return doclink('link-127', 'DEL_END', 'link-82');">DEL_END</a></tt><tt class="py-op">)</tt> </tt>
<a name="L359"></a><tt class="py-lineno">359</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>
</div><a name="L360"></a><tt class="py-lineno">360</tt> <tt class="py-line"> </tt>
<a name="locate_unbalanced_start"></a><div id="locate_unbalanced_start-def"><a name="L361"></a><tt class="py-lineno">361</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>
</div><div id="locate_unbalanced_start-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="locate_unbalanced_start-expanded"><a name="L362"></a><tt class="py-lineno">362</tt> <tt class="py-line"> <tt class="py-docstring">""" pre_delete and post_delete implicitly point to a place in the</tt> </tt>
<a name="L363"></a><tt class="py-lineno">363</tt> <tt class="py-line"><tt class="py-docstring"> document (where the two were split). This moves that point (by</tt> </tt>
<a name="L364"></a><tt class="py-lineno">364</tt> <tt class="py-line"><tt class="py-docstring"> popping items from one and pushing them onto the other). It moves</tt> </tt>
<a name="L365"></a><tt class="py-lineno">365</tt> <tt class="py-line"><tt class="py-docstring"> the point to try to find a place where unbalanced_start applies.</tt> </tt>
<a name="L366"></a><tt class="py-lineno">366</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L367"></a><tt class="py-lineno">367</tt> <tt class="py-line"><tt class="py-docstring"> As an example::</tt> </tt>
<a name="L368"></a><tt class="py-lineno">368</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L369"></a><tt class="py-lineno">369</tt> <tt class="py-line"><tt class="py-docstring"> >>> unbalanced_start = ['<div>']</tt> </tt>
<a name="L370"></a><tt class="py-lineno">370</tt> <tt class="py-line"><tt class="py-docstring"> >>> doc = ['<p>', 'Text', '</p>', '<div>', 'More Text', '</div>']</tt> </tt>
<a name="L371"></a><tt class="py-lineno">371</tt> <tt class="py-line"><tt class="py-docstring"> >>> pre, post = doc[:3], doc[3:]</tt> </tt>
<a name="L372"></a><tt class="py-lineno">372</tt> <tt class="py-line"><tt class="py-docstring"> >>> pre, post</tt> </tt>
<a name="L373"></a><tt class="py-lineno">373</tt> <tt class="py-line"><tt class="py-docstring"> (['<p>', 'Text', '</p>'], ['<div>', 'More Text', '</div>'])</tt> </tt>
<a name="L374"></a><tt class="py-lineno">374</tt> <tt class="py-line"><tt class="py-docstring"> >>> locate_unbalanced_start(unbalanced_start, pre, post)</tt> </tt>
<a name="L375"></a><tt class="py-lineno">375</tt> <tt class="py-line"><tt class="py-docstring"> >>> pre, post</tt> </tt>
<a name="L376"></a><tt class="py-lineno">376</tt> <tt class="py-line"><tt class="py-docstring"> (['<p>', 'Text', '</p>', '<div>'], ['More Text', '</div>'])</tt> </tt>
<a name="L377"></a><tt class="py-lineno">377</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L378"></a><tt class="py-lineno">378</tt> <tt class="py-line"><tt class="py-docstring"> As you can see, we moved the point so that the dangling <div> that</tt> </tt>
<a name="L379"></a><tt class="py-lineno">379</tt> <tt class="py-line"><tt class="py-docstring"> we found will be effectively replaced by the div in the original</tt> </tt>
<a name="L380"></a><tt class="py-lineno">380</tt> <tt class="py-line"><tt class="py-docstring"> document. If this doesn't work out, we just throw away</tt> </tt>
<a name="L381"></a><tt class="py-lineno">381</tt> <tt class="py-line"><tt class="py-docstring"> unbalanced_start without doing anything.</tt> </tt>
<a name="L382"></a><tt class="py-lineno">382</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
<a name="L383"></a><tt class="py-lineno">383</tt> <tt class="py-line"> <tt class="py-keyword">while</tt> <tt class="py-number">1</tt><tt class="py-op">:</tt> </tt>
<a name="L384"></a><tt class="py-lineno">384</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>
<a name="L385"></a><tt class="py-lineno">385</tt> <tt class="py-line"> <tt class="py-comment"># We have totally succeded in finding the position</tt> </tt>
<a name="L386"></a><tt class="py-lineno">386</tt> <tt class="py-line"> <tt class="py-keyword">break</tt> </tt>
<a name="L387"></a><tt class="py-lineno">387</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>
<a name="L388"></a><tt class="py-lineno">388</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-128" class="py-name"><a title="lxml.doctestcompare.strip" class="py-name" href="#" onclick="return doclink('link-128', 'strip', 'link-19');">strip</a></tt><tt class="py-op">(</tt><tt class="py-string">'<>'</tt><tt class="py-op">)</tt> </tt>
<a name="L389"></a><tt class="py-lineno">389</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>
<a name="L390"></a><tt class="py-lineno">390</tt> <tt class="py-line"> <tt class="py-keyword">break</tt> </tt>
<a name="L391"></a><tt class="py-lineno">391</tt> <tt class="py-line"> <tt id="link-129" class="py-name" targets="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._ElementIterator.next()=lxml.etree._ElementIterator-class.html#next,Method lxml.etree._ElementMatchIterator.next()=lxml.etree._ElementMatchIterator-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.etree.ElementDepthFirstIterator.next
lxml.etree.ElementTextIterator.next
lxml.etree._ElementIterator.next
lxml.etree._ElementMatchIterator.next
lxml.etree.iterparse.next
lxml.etree.iterwalk.next" class="py-name" href="#" onclick="return doclink('link-129', 'next', 'link-129');">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>
<a name="L392"></a><tt class="py-lineno">392</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt id="link-130" class="py-name"><a title="lxml.etree.ElementDepthFirstIterator.next
lxml.etree.ElementTextIterator.next
lxml.etree._ElementIterator.next
lxml.etree._ElementMatchIterator.next
lxml.etree.iterparse.next
lxml.etree.iterwalk.next" class="py-name" href="#" onclick="return doclink('link-130', 'next', 'link-129');">next</a></tt> <tt class="py-keyword">is</tt> <tt id="link-131" class="py-name"><a title="lxml.html.diff.DEL_START" class="py-name" href="#" onclick="return doclink('link-131', 'DEL_START', 'link-79');">DEL_START</a></tt> <tt class="py-keyword">or</tt> <tt class="py-keyword">not</tt> <tt id="link-132" class="py-name"><a title="lxml.etree.ElementDepthFirstIterator.next
lxml.etree.ElementTextIterator.next
lxml.etree._ElementIterator.next
lxml.etree._ElementMatchIterator.next
lxml.etree.iterparse.next
lxml.etree.iterwalk.next" class="py-name" href="#" onclick="return doclink('link-132', 'next', 'link-129');">next</a></tt><tt class="py-op">.</tt><tt class="py-name">startswith</tt><tt class="py-op">(</tt><tt class="py-string">'<'</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L393"></a><tt class="py-lineno">393</tt> <tt class="py-line"> <tt class="py-comment"># Reached a word, we can't move the delete text forward</tt> </tt>
<a name="L394"></a><tt class="py-lineno">394</tt> <tt class="py-line"> <tt class="py-keyword">break</tt> </tt>
<a name="L395"></a><tt class="py-lineno">395</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt id="link-133" class="py-name"><a title="lxml.etree.ElementDepthFirstIterator.next
lxml.etree.ElementTextIterator.next
lxml.etree._ElementIterator.next
lxml.etree._ElementMatchIterator.next
lxml.etree.iterparse.next
lxml.etree.iterwalk.next" class="py-name" href="#" onclick="return doclink('link-133', 'next', 'link-129');">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>
<a name="L396"></a><tt class="py-lineno">396</tt> <tt class="py-line"> <tt class="py-comment"># Reached a closing tag, can we go further? Maybe not...</tt> </tt>
<a name="L397"></a><tt class="py-lineno">397</tt> <tt class="py-line"> <tt class="py-keyword">break</tt> </tt>
<a name="L398"></a><tt class="py-lineno">398</tt> <tt class="py-line"> <tt id="link-134" class="py-name"><a title="lxml.etree.DTD.name
lxml.etree._Entity.name
lxml.html.InputMixin.name
lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-134', 'name', 'link-95');">name</a></tt> <tt class="py-op">=</tt> <tt id="link-135" class="py-name"><a title="lxml.etree.ElementDepthFirstIterator.next
lxml.etree.ElementTextIterator.next
lxml.etree._ElementIterator.next
lxml.etree._ElementMatchIterator.next
lxml.etree.iterparse.next
lxml.etree.iterwalk.next" class="py-name" href="#" onclick="return doclink('link-135', 'next', 'link-129');">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-136" class="py-name"><a title="lxml.doctestcompare.strip" class="py-name" href="#" onclick="return doclink('link-136', 'strip', 'link-19');">strip</a></tt><tt class="py-op">(</tt><tt class="py-string">'<>'</tt><tt class="py-op">)</tt> </tt>
<a name="L399"></a><tt class="py-lineno">399</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt id="link-137" class="py-name"><a title="lxml.etree.DTD.name
lxml.etree._Entity.name
lxml.html.InputMixin.name
lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-137', 'name', 'link-95');">name</a></tt> <tt class="py-op">==</tt> <tt class="py-string">'ins'</tt><tt class="py-op">:</tt> </tt>
<a name="L400"></a><tt class="py-lineno">400</tt> <tt class="py-line"> <tt class="py-comment"># Can't move into an insert</tt> </tt>
<a name="L401"></a><tt class="py-lineno">401</tt> <tt class="py-line"> <tt class="py-keyword">break</tt> </tt>
<a name="L402"></a><tt class="py-lineno">402</tt> <tt class="py-line"> <tt class="py-keyword">assert</tt> <tt id="link-138" class="py-name"><a title="lxml.etree.DTD.name
lxml.etree._Entity.name
lxml.html.InputMixin.name
lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-138', 'name', 'link-95');">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>
<a name="L403"></a><tt class="py-lineno">403</tt> <tt class="py-line"> <tt class="py-string">"Unexpected delete tag: %r"</tt> <tt class="py-op">%</tt> <tt id="link-139" class="py-name"><a title="lxml.etree.ElementDepthFirstIterator.next
lxml.etree.ElementTextIterator.next
lxml.etree._ElementIterator.next
lxml.etree._ElementMatchIterator.next
lxml.etree.iterparse.next
lxml.etree.iterwalk.next" class="py-name" href="#" onclick="return doclink('link-139', 'next', 'link-129');">next</a></tt><tt class="py-op">)</tt> </tt>
<a name="L404"></a><tt class="py-lineno">404</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt id="link-140" class="py-name"><a title="lxml.etree.DTD.name
lxml.etree._Entity.name
lxml.html.InputMixin.name
lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-140', 'name', 'link-95');">name</a></tt> <tt class="py-op">==</tt> <tt class="py-name">finding_name</tt><tt class="py-op">:</tt> </tt>
<a name="L405"></a><tt class="py-lineno">405</tt> <tt class="py-line"> <tt class="py-name">unbalanced_start</tt><tt class="py-op">.</tt><tt id="link-141" class="py-name"><a title="lxml.etree._Attrib.pop" class="py-name" href="#" onclick="return doclink('link-141', 'pop', 'link-104');">pop</a></tt><tt class="py-op">(</tt><tt class="py-number">0</tt><tt class="py-op">)</tt> </tt>
<a name="L406"></a><tt class="py-lineno">406</tt> <tt class="py-line"> <tt class="py-name">pre_delete</tt><tt class="py-op">.</tt><tt id="link-142" class="py-name"><a title="lxml.etree._Element.append" class="py-name" href="#" onclick="return doclink('link-142', 'append', 'link-24');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">post_delete</tt><tt class="py-op">.</tt><tt id="link-143" class="py-name"><a title="lxml.etree._Attrib.pop" class="py-name" href="#" onclick="return doclink('link-143', 'pop', 'link-104');">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>
<a name="L407"></a><tt class="py-lineno">407</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L408"></a><tt class="py-lineno">408</tt> <tt class="py-line"> <tt class="py-comment"># Found a tag that doesn't match</tt> </tt>
<a name="L409"></a><tt class="py-lineno">409</tt> <tt class="py-line"> <tt class="py-keyword">break</tt> </tt>
</div><a name="L410"></a><tt class="py-lineno">410</tt> <tt class="py-line"> </tt>
<a name="locate_unbalanced_end"></a><div id="locate_unbalanced_end-def"><a name="L411"></a><tt class="py-lineno">411</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>
</div><div id="locate_unbalanced_end-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="locate_unbalanced_end-expanded"><a name="L412"></a><tt class="py-lineno">412</tt> <tt class="py-line"> <tt class="py-docstring">""" like locate_unbalanced_start, except handling end tags and</tt> </tt>
<a name="L413"></a><tt class="py-lineno">413</tt> <tt class="py-line"><tt class="py-docstring"> possibly moving the point earlier in the document. """</tt> </tt>
<a name="L414"></a><tt class="py-lineno">414</tt> <tt class="py-line"> <tt class="py-keyword">while</tt> <tt class="py-number">1</tt><tt class="py-op">:</tt> </tt>
<a name="L415"></a><tt class="py-lineno">415</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>
<a name="L416"></a><tt class="py-lineno">416</tt> <tt class="py-line"> <tt class="py-comment"># Success</tt> </tt>
<a name="L417"></a><tt class="py-lineno">417</tt> <tt class="py-line"> <tt class="py-keyword">break</tt> </tt>
<a name="L418"></a><tt class="py-lineno">418</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>
<a name="L419"></a><tt class="py-lineno">419</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-144" class="py-name"><a title="lxml.doctestcompare.strip" class="py-name" href="#" onclick="return doclink('link-144', 'strip', 'link-19');">strip</a></tt><tt class="py-op">(</tt><tt class="py-string">'<>/'</tt><tt class="py-op">)</tt> </tt>
<a name="L420"></a><tt class="py-lineno">420</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>
<a name="L421"></a><tt class="py-lineno">421</tt> <tt class="py-line"> <tt class="py-keyword">break</tt> </tt>
<a name="L422"></a><tt class="py-lineno">422</tt> <tt class="py-line"> <tt id="link-145" class="py-name"><a title="lxml.etree.ElementDepthFirstIterator.next
lxml.etree.ElementTextIterator.next
lxml.etree._ElementIterator.next
lxml.etree._ElementMatchIterator.next
lxml.etree.iterparse.next
lxml.etree.iterwalk.next" class="py-name" href="#" onclick="return doclink('link-145', 'next', 'link-129');">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>
<a name="L423"></a><tt class="py-lineno">423</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt id="link-146" class="py-name"><a title="lxml.etree.ElementDepthFirstIterator.next
lxml.etree.ElementTextIterator.next
lxml.etree._ElementIterator.next
lxml.etree._ElementMatchIterator.next
lxml.etree.iterparse.next
lxml.etree.iterwalk.next" class="py-name" href="#" onclick="return doclink('link-146', 'next', 'link-129');">next</a></tt> <tt class="py-keyword">is</tt> <tt id="link-147" class="py-name"><a title="lxml.html.diff.DEL_END" class="py-name" href="#" onclick="return doclink('link-147', 'DEL_END', 'link-82');">DEL_END</a></tt> <tt class="py-keyword">or</tt> <tt class="py-keyword">not</tt> <tt id="link-148" class="py-name"><a title="lxml.etree.ElementDepthFirstIterator.next
lxml.etree.ElementTextIterator.next
lxml.etree._ElementIterator.next
lxml.etree._ElementMatchIterator.next
lxml.etree.iterparse.next
lxml.etree.iterwalk.next" class="py-name" href="#" onclick="return doclink('link-148', 'next', 'link-129');">next</a></tt><tt class="py-op">.</tt><tt class="py-name">startswith</tt><tt class="py-op">(</tt><tt class="py-string">'</'</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L424"></a><tt class="py-lineno">424</tt> <tt class="py-line"> <tt class="py-comment"># A word or a start tag</tt> </tt>
<a name="L425"></a><tt class="py-lineno">425</tt> <tt class="py-line"> <tt class="py-keyword">break</tt> </tt>
<a name="L426"></a><tt class="py-lineno">426</tt> <tt class="py-line"> <tt id="link-149" class="py-name"><a title="lxml.etree.DTD.name
lxml.etree._Entity.name
lxml.html.InputMixin.name
lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-149', 'name', 'link-95');">name</a></tt> <tt class="py-op">=</tt> <tt id="link-150" class="py-name"><a title="lxml.etree.ElementDepthFirstIterator.next
lxml.etree.ElementTextIterator.next
lxml.etree._ElementIterator.next
lxml.etree._ElementMatchIterator.next
lxml.etree.iterparse.next
lxml.etree.iterwalk.next" class="py-name" href="#" onclick="return doclink('link-150', 'next', 'link-129');">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-151" class="py-name"><a title="lxml.doctestcompare.strip" class="py-name" href="#" onclick="return doclink('link-151', 'strip', 'link-19');">strip</a></tt><tt class="py-op">(</tt><tt class="py-string">'<>/'</tt><tt class="py-op">)</tt> </tt>
<a name="L427"></a><tt class="py-lineno">427</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt id="link-152" class="py-name"><a title="lxml.etree.DTD.name
lxml.etree._Entity.name
lxml.html.InputMixin.name
lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-152', 'name', 'link-95');">name</a></tt> <tt class="py-op">==</tt> <tt class="py-string">'ins'</tt> <tt class="py-keyword">or</tt> <tt id="link-153" class="py-name"><a title="lxml.etree.DTD.name
lxml.etree._Entity.name
lxml.html.InputMixin.name
lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-153', 'name', 'link-95');">name</a></tt> <tt class="py-op">==</tt> <tt class="py-string">'del'</tt><tt class="py-op">:</tt> </tt>
<a name="L428"></a><tt class="py-lineno">428</tt> <tt class="py-line"> <tt class="py-comment"># Can't move into an insert or delete</tt> </tt>
<a name="L429"></a><tt class="py-lineno">429</tt> <tt class="py-line"> <tt class="py-keyword">break</tt> </tt>
<a name="L430"></a><tt class="py-lineno">430</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt id="link-154" class="py-name"><a title="lxml.etree.DTD.name
lxml.etree._Entity.name
lxml.html.InputMixin.name
lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-154', 'name', 'link-95');">name</a></tt> <tt class="py-op">==</tt> <tt class="py-name">finding_name</tt><tt class="py-op">:</tt> </tt>
<a name="L431"></a><tt class="py-lineno">431</tt> <tt class="py-line"> <tt class="py-name">unbalanced_end</tt><tt class="py-op">.</tt><tt id="link-155" class="py-name"><a title="lxml.etree._Attrib.pop" class="py-name" href="#" onclick="return doclink('link-155', 'pop', 'link-104');">pop</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L432"></a><tt class="py-lineno">432</tt> <tt class="py-line"> <tt class="py-name">post_delete</tt><tt class="py-op">.</tt><tt id="link-156" class="py-name" targets="Method lxml.etree._Element.insert()=lxml.etree._Element-class.html#insert"><a title="lxml.etree._Element.insert" class="py-name" href="#" onclick="return doclink('link-156', 'insert', 'link-156');">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-157" class="py-name"><a title="lxml.etree._Attrib.pop" class="py-name" href="#" onclick="return doclink('link-157', 'pop', 'link-104');">pop</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L433"></a><tt class="py-lineno">433</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L434"></a><tt class="py-lineno">434</tt> <tt class="py-line"> <tt class="py-comment"># Found a tag that doesn't match</tt> </tt>
<a name="L435"></a><tt class="py-lineno">435</tt> <tt class="py-line"> <tt class="py-keyword">break</tt> </tt>
</div><a name="L436"></a><tt class="py-lineno">436</tt> <tt class="py-line"> </tt>
<a name="token"></a><div id="token-def"><a name="L437"></a><tt class="py-lineno">437</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>
</div><div id="token-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="token-expanded"><a name="L438"></a><tt class="py-lineno">438</tt> <tt class="py-line"> <tt class="py-docstring">""" Represents a diffable token, generally a word that is displayed to</tt> </tt>
<a name="L439"></a><tt class="py-lineno">439</tt> <tt class="py-line"><tt class="py-docstring"> the user. Opening tags are attached to this token when they are</tt> </tt>
<a name="L440"></a><tt class="py-lineno">440</tt> <tt class="py-line"><tt class="py-docstring"> adjacent (pre_tags) and closing tags that follow the word</tt> </tt>
<a name="L441"></a><tt class="py-lineno">441</tt> <tt class="py-line"><tt class="py-docstring"> (post_tags). Some exceptions occur when there are empty tags</tt> </tt>
<a name="L442"></a><tt class="py-lineno">442</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>
<a name="L443"></a><tt class="py-lineno">443</tt> <tt class="py-line"><tt class="py-docstring"> open tags in post_tags.</tt> </tt>
<a name="L444"></a><tt class="py-lineno">444</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L445"></a><tt class="py-lineno">445</tt> <tt class="py-line"><tt class="py-docstring"> We also keep track of whether the word was originally followed by</tt> </tt>
<a name="L446"></a><tt class="py-lineno">446</tt> <tt class="py-line"><tt class="py-docstring"> whitespace, even though we do not want to treat the word as</tt> </tt>
<a name="L447"></a><tt class="py-lineno">447</tt> <tt class="py-line"><tt class="py-docstring"> equivalent to a similar word that does not have a trailing</tt> </tt>
<a name="L448"></a><tt class="py-lineno">448</tt> <tt class="py-line"><tt class="py-docstring"> space."""</tt> </tt>
<a name="L449"></a><tt class="py-lineno">449</tt> <tt class="py-line"> </tt>
<a name="L450"></a><tt class="py-lineno">450</tt> <tt class="py-line"> <tt class="py-comment"># When this is true, the token will be eliminated from the</tt> </tt>
<a name="L451"></a><tt class="py-lineno">451</tt> <tt class="py-line"> <tt class="py-comment"># displayed diff if no change has occurred:</tt> </tt>
<a name="L452"></a><tt class="py-lineno">452</tt> <tt class="py-line"> <tt id="link-158" class="py-name"><a title="lxml.html.diff.href_token.hide_when_equal
lxml.html.diff.token.hide_when_equal" class="py-name" href="#" onclick="return doclink('link-158', 'hide_when_equal', 'link-64');">hide_when_equal</a></tt> <tt class="py-op">=</tt> <tt class="py-name">False</tt> </tt>
<a name="L453"></a><tt class="py-lineno">453</tt> <tt class="py-line"> </tt>
<a name="token.__new__"></a><div id="token.__new__-def"><a name="L454"></a><tt class="py-lineno">454</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-string">""</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="token.__new__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="token.__new__-expanded"><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">_unicode</tt><tt class="py-op">.</tt><tt id="link-159" class="py-name" targets="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.HTMLPullParser.__new__()=lxml.etree.HTMLPullParser-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.XMLPullParser.__new__()=lxml.etree.XMLPullParser-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._Attrib.__new__()=lxml.etree._Attrib-class.html#__new__,Method lxml.etree._BaseErrorLog.__new__()=lxml.etree._BaseErrorLog-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._ElementMatchIterator.__new__()=lxml.etree._ElementMatchIterator-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._FeedParser.__new__()=lxml.etree._FeedParser-class.html#__new__,Method lxml.etree._IDDict.__new__()=lxml.etree._IDDict-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._ProcessingInstruction.__new__()=lxml.etree._ProcessingInstruction-class.html#__new__,Method lxml.etree._RotatingErrorLog.__new__()=lxml.etree._RotatingErrorLog-class.html#__new__,Method lxml.etree._SaxParserTarget.__new__()=lxml.etree._SaxParserTarget-class.html#__new__,Method lxml.etree._Validator.__new__()=lxml.etree._Validator-class.html#__new__,Method lxml.etree._XPathEvaluatorBase.__new__()=lxml.etree._XPathEvaluatorBase-class.html#__new__,Method lxml.etree._XSLTProcessingInstruction.__new__()=lxml.etree._XSLTProcessingInstruction-class.html#__new__,Method lxml.etree._XSLTResultTree.__new__()=lxml.etree._XSLTResultTree-class.html#__new__,Method lxml.etree.htmlfile.__new__()=lxml.etree.htmlfile-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__,Method lxml.etree.xmlfile.__new__()=lxml.etree.xmlfile-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__"><a title="lxml.etree.AncestorsIterator.__new__
lxml.etree.AttributeBasedElementClassLookup.__new__
lxml.etree.CDATA.__new__
lxml.etree.CommentBase.__new__
lxml.etree.CustomElementClassLookup.__new__
lxml.etree.DTD.__new__
lxml.etree.DocInfo.__new__
lxml.etree.ETCompatXMLParser.__new__
lxml.etree.ETXPath.__new__
lxml.etree.ElementBase.__new__
lxml.etree.ElementChildIterator.__new__
lxml.etree.ElementClassLookup.__new__
lxml.etree.ElementDefaultClassLookup.__new__
lxml.etree.ElementDepthFirstIterator.__new__
lxml.etree.ElementNamespaceClassLookup.__new__
lxml.etree.ElementTextIterator.__new__
lxml.etree.EntityBase.__new__
lxml.etree.FallbackElementClassLookup.__new__
lxml.etree.HTMLParser.__new__
lxml.etree.HTMLPullParser.__new__
lxml.etree.PIBase.__new__
lxml.etree.ParserBasedElementClassLookup.__new__
lxml.etree.PyErrorLog.__new__
lxml.etree.PythonElementClassLookup.__new__
lxml.etree.QName.__new__
lxml.etree.RelaxNG.__new__
lxml.etree.Resolver.__new__
lxml.etree.Schematron.__new__
lxml.etree.SiblingsIterator.__new__
lxml.etree.TreeBuilder.__new__
lxml.etree.XInclude.__new__
lxml.etree.XMLParser.__new__
lxml.etree.XMLPullParser.__new__
lxml.etree.XMLSchema.__new__
lxml.etree.XPath.__new__
lxml.etree.XPathDocumentEvaluator.__new__
lxml.etree.XPathElementEvaluator.__new__
lxml.etree.XSLT.__new__
lxml.etree.XSLTAccessControl.__new__
lxml.etree.XSLTExtension.__new__
lxml.etree._Attrib.__new__
lxml.etree._BaseErrorLog.__new__
lxml.etree._Comment.__new__
lxml.etree._Document.__new__
lxml.etree._DomainErrorLog.__new__
lxml.etree._Element.__new__
lxml.etree._ElementIterator.__new__
lxml.etree._ElementMatchIterator.__new__
lxml.etree._ElementTagMatcher.__new__
lxml.etree._ElementTree.__new__
lxml.etree._ElementUnicodeResult.__new__
lxml.etree._Entity.__new__
lxml.etree._ErrorLog.__new__
lxml.etree._FeedParser.__new__
lxml.etree._IDDict.__new__
lxml.etree._ListErrorLog.__new__
lxml.etree._LogEntry.__new__
lxml.etree._ProcessingInstruction.__new__
lxml.etree._RotatingErrorLog.__new__
lxml.etree._SaxParserTarget.__new__
lxml.etree._Validator.__new__
lxml.etree._XPathEvaluatorBase.__new__
lxml.etree._XSLTProcessingInstruction.__new__
lxml.etree._XSLTResultTree.__new__
lxml.etree.htmlfile.__new__
lxml.etree.iterparse.__new__
lxml.etree.iterwalk.__new__
lxml.etree.xmlfile.__new__
lxml.html.diff.tag_token.__new__
lxml.html.diff.token.__new__
lxml.objectify.BoolElement.__new__
lxml.objectify.ElementMaker.__new__
lxml.objectify.FloatElement.__new__
lxml.objectify.IntElement.__new__
lxml.objectify.LongElement.__new__
lxml.objectify.NoneElement.__new__
lxml.objectify.NumberElement.__new__
lxml.objectify.ObjectPath.__new__
lxml.objectify.ObjectifiedDataElement.__new__
lxml.objectify.ObjectifiedElement.__new__
lxml.objectify.ObjectifyElementClassLookup.__new__
lxml.objectify.PyType.__new__
lxml.objectify.StringElement.__new__" class="py-name" href="#" onclick="return doclink('link-159', '__new__', 'link-159');">__new__</a></tt><tt class="py-op">(</tt><tt class="py-name">cls</tt><tt class="py-op">,</tt> <tt id="link-160" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-160', 'text', 'link-11');">text</a></tt><tt class="py-op">)</tt> </tt>
<a name="L456"></a><tt class="py-lineno">456</tt> <tt class="py-line"> </tt>
<a name="L457"></a><tt class="py-lineno">457</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>
<a name="L458"></a><tt class="py-lineno">458</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>
<a name="L459"></a><tt class="py-lineno">459</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<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">pre_tags</tt> <tt class="py-op">=</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
<a name="L461"></a><tt class="py-lineno">461</tt> <tt class="py-line"> </tt>
<a name="L462"></a><tt class="py-lineno">462</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>
<a name="L463"></a><tt class="py-lineno">463</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>
<a name="L464"></a><tt class="py-lineno">464</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L465"></a><tt class="py-lineno">465</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>
<a name="L466"></a><tt class="py-lineno">466</tt> <tt class="py-line"> </tt>
<a name="L467"></a><tt class="py-lineno">467</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>
<a name="L468"></a><tt class="py-lineno">468</tt> <tt class="py-line"> </tt>
<a name="L469"></a><tt class="py-lineno">469</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">obj</tt> </tt>
</div><a name="L470"></a><tt class="py-lineno">470</tt> <tt class="py-line"> </tt>
<a name="token.__repr__"></a><div id="token.__repr__-def"><a name="L471"></a><tt class="py-lineno">471</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>
</div><div id="token.__repr__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="token.__repr__-expanded"><a name="L472"></a><tt class="py-lineno">472</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-string">'token(%s, %r, %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-161" class="py-name" targets="Method lxml.cssselect.CSSSelector.__repr__()=lxml.cssselect.CSSSelector-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._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._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.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.CSSSelector.__repr__
lxml.etree.XPath.__repr__
lxml.etree.XSLTAccessControl.__repr__
lxml.etree._Attrib.__repr__
lxml.etree._BaseErrorLog.__repr__
lxml.etree._Comment.__repr__
lxml.etree._Element.__repr__
lxml.etree._Entity.__repr__
lxml.etree._IDDict.__repr__
lxml.etree._ListErrorLog.__repr__
lxml.etree._LogEntry.__repr__
lxml.etree._ProcessingInstruction.__repr__
lxml.html.CheckboxGroup.__repr__
lxml.html.CheckboxValues.__repr__
lxml.html.FieldsDict.__repr__
lxml.html.InputGetter.__repr__
lxml.html.InputMixin.__repr__
lxml.html.MultipleSelectOptions.__repr__
lxml.html.RadioGroup.__repr__
lxml.html.diff.tag_token.__repr__
lxml.html.diff.token.__repr__
lxml.objectify.BoolElement.__repr__
lxml.objectify.NoneElement.__repr__
lxml.objectify.NumberElement.__repr__
lxml.objectify.ObjectifiedDataElement.__repr__
lxml.objectify.PyType.__repr__
lxml.objectify.StringElement.__repr__" class="py-name" href="#" onclick="return doclink('link-161', '__repr__', 'link-161');">__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>
<a name="L473"></a><tt class="py-lineno">473</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 class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">trailing_whitespace</tt><tt class="py-op">)</tt> </tt>
</div><a name="L474"></a><tt class="py-lineno">474</tt> <tt class="py-line"> </tt>
<a name="token.html"></a><div id="token.html-def"><a name="L475"></a><tt class="py-lineno">475</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>
</div><div id="token.html-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="token.html-expanded"><a name="L476"></a><tt class="py-lineno">476</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>
</div></div><a name="L477"></a><tt class="py-lineno">477</tt> <tt class="py-line"> </tt>
<a name="tag_token"></a><div id="tag_token-def"><a name="L478"></a><tt class="py-lineno">478</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>
</div><div id="tag_token-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="tag_token-expanded"><a name="L479"></a><tt class="py-lineno">479</tt> <tt class="py-line"> </tt>
<a name="L480"></a><tt class="py-lineno">480</tt> <tt class="py-line"> <tt class="py-docstring">""" Represents a token that is actually a tag. Currently this is just</tt> </tt>
<a name="L481"></a><tt class="py-lineno">481</tt> <tt class="py-line"><tt class="py-docstring"> the <img> tag, which takes up visible space just like a word but</tt> </tt>
<a name="L482"></a><tt class="py-lineno">482</tt> <tt class="py-line"><tt class="py-docstring"> is only represented in a document by a tag. """</tt> </tt>
<a name="L483"></a><tt class="py-lineno">483</tt> <tt class="py-line"> </tt>
<a name="tag_token.__new__"></a><div id="tag_token.__new__-def"><a name="L484"></a><tt class="py-lineno">484</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>
<a name="L485"></a><tt class="py-lineno">485</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-string">""</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="tag_token.__new__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="tag_token.__new__-expanded"><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-162" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-162', 'token', 'link-26');">token</a></tt><tt class="py-op">.</tt><tt id="link-163" class="py-name"><a title="lxml.etree.AncestorsIterator.__new__
lxml.etree.AttributeBasedElementClassLookup.__new__
lxml.etree.CDATA.__new__
lxml.etree.CommentBase.__new__
lxml.etree.CustomElementClassLookup.__new__
lxml.etree.DTD.__new__
lxml.etree.DocInfo.__new__
lxml.etree.ETCompatXMLParser.__new__
lxml.etree.ETXPath.__new__
lxml.etree.ElementBase.__new__
lxml.etree.ElementChildIterator.__new__
lxml.etree.ElementClassLookup.__new__
lxml.etree.ElementDefaultClassLookup.__new__
lxml.etree.ElementDepthFirstIterator.__new__
lxml.etree.ElementNamespaceClassLookup.__new__
lxml.etree.ElementTextIterator.__new__
lxml.etree.EntityBase.__new__
lxml.etree.FallbackElementClassLookup.__new__
lxml.etree.HTMLParser.__new__
lxml.etree.HTMLPullParser.__new__
lxml.etree.PIBase.__new__
lxml.etree.ParserBasedElementClassLookup.__new__
lxml.etree.PyErrorLog.__new__
lxml.etree.PythonElementClassLookup.__new__
lxml.etree.QName.__new__
lxml.etree.RelaxNG.__new__
lxml.etree.Resolver.__new__
lxml.etree.Schematron.__new__
lxml.etree.SiblingsIterator.__new__
lxml.etree.TreeBuilder.__new__
lxml.etree.XInclude.__new__
lxml.etree.XMLParser.__new__
lxml.etree.XMLPullParser.__new__
lxml.etree.XMLSchema.__new__
lxml.etree.XPath.__new__
lxml.etree.XPathDocumentEvaluator.__new__
lxml.etree.XPathElementEvaluator.__new__
lxml.etree.XSLT.__new__
lxml.etree.XSLTAccessControl.__new__
lxml.etree.XSLTExtension.__new__
lxml.etree._Attrib.__new__
lxml.etree._BaseErrorLog.__new__
lxml.etree._Comment.__new__
lxml.etree._Document.__new__
lxml.etree._DomainErrorLog.__new__
lxml.etree._Element.__new__
lxml.etree._ElementIterator.__new__
lxml.etree._ElementMatchIterator.__new__
lxml.etree._ElementTagMatcher.__new__
lxml.etree._ElementTree.__new__
lxml.etree._ElementUnicodeResult.__new__
lxml.etree._Entity.__new__
lxml.etree._ErrorLog.__new__
lxml.etree._FeedParser.__new__
lxml.etree._IDDict.__new__
lxml.etree._ListErrorLog.__new__
lxml.etree._LogEntry.__new__
lxml.etree._ProcessingInstruction.__new__
lxml.etree._RotatingErrorLog.__new__
lxml.etree._SaxParserTarget.__new__
lxml.etree._Validator.__new__
lxml.etree._XPathEvaluatorBase.__new__
lxml.etree._XSLTProcessingInstruction.__new__
lxml.etree._XSLTResultTree.__new__
lxml.etree.htmlfile.__new__
lxml.etree.iterparse.__new__
lxml.etree.iterwalk.__new__
lxml.etree.xmlfile.__new__
lxml.html.diff.tag_token.__new__
lxml.html.diff.token.__new__
lxml.objectify.BoolElement.__new__
lxml.objectify.ElementMaker.__new__
lxml.objectify.FloatElement.__new__
lxml.objectify.IntElement.__new__
lxml.objectify.LongElement.__new__
lxml.objectify.NoneElement.__new__
lxml.objectify.NumberElement.__new__
lxml.objectify.ObjectPath.__new__
lxml.objectify.ObjectifiedDataElement.__new__
lxml.objectify.ObjectifiedElement.__new__
lxml.objectify.ObjectifyElementClassLookup.__new__
lxml.objectify.PyType.__new__
lxml.objectify.StringElement.__new__" class="py-name" href="#" onclick="return doclink('link-163', '__new__', 'link-159');">__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-164" class="py-name"><a title="lxml.etree._LogEntry.type
lxml.html.InputElement.type" class="py-name" href="#" onclick="return doclink('link-164', 'type', 'link-25');">type</a></tt><tt class="py-op">,</tt> <tt id="link-165" 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-165', 'data', 'link-165');">data</a></tt><tt class="py-op">)</tt><tt class="py-op">,</tt> </tt>
<a name="L487"></a><tt class="py-lineno">487</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>
<a name="L488"></a><tt class="py-lineno">488</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>
<a name="L489"></a><tt class="py-lineno">489</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>
<a name="L490"></a><tt class="py-lineno">490</tt> <tt class="py-line"> <tt class="py-name">obj</tt><tt class="py-op">.</tt><tt id="link-166" class="py-name"><a title="lxml.etree._Comment.tag
lxml.etree._Element.tag
lxml.etree._Entity.tag
lxml.etree._ProcessingInstruction.tag
lxml.tests.test_xpathevaluator.tag
xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-166', 'tag', 'link-103');">tag</a></tt> <tt class="py-op">=</tt> <tt id="link-167" class="py-name"><a title="lxml.etree._Comment.tag
lxml.etree._Element.tag
lxml.etree._Entity.tag
lxml.etree._ProcessingInstruction.tag
lxml.tests.test_xpathevaluator.tag
xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-167', 'tag', 'link-103');">tag</a></tt> </tt>
<a name="L491"></a><tt class="py-lineno">491</tt> <tt class="py-line"> <tt class="py-name">obj</tt><tt class="py-op">.</tt><tt id="link-168" class="py-name"><a title="lxml.etree.TreeBuilder.data" class="py-name" href="#" onclick="return doclink('link-168', 'data', 'link-165');">data</a></tt> <tt class="py-op">=</tt> <tt id="link-169" class="py-name"><a title="lxml.etree.TreeBuilder.data" class="py-name" href="#" onclick="return doclink('link-169', 'data', 'link-165');">data</a></tt> </tt>
<a name="L492"></a><tt class="py-lineno">492</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>
<a name="L493"></a><tt class="py-lineno">493</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">obj</tt> </tt>
</div><a name="L494"></a><tt class="py-lineno">494</tt> <tt class="py-line"> </tt>
<a name="tag_token.__repr__"></a><div id="tag_token.__repr__-def"><a name="L495"></a><tt class="py-lineno">495</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>
</div><div id="tag_token.__repr__-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="tag_token.__repr__-expanded"><a name="L496"></a><tt class="py-lineno">496</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=%r)'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt> </tt>
<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 id="link-170" class="py-name"><a title="lxml.etree._Comment.tag
lxml.etree._Element.tag
lxml.etree._Entity.tag
lxml.etree._ProcessingInstruction.tag
lxml.tests.test_xpathevaluator.tag
xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-170', 'tag', 'link-103');">tag</a></tt><tt class="py-op">,</tt> </tt>
<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 id="link-171" class="py-name"><a title="lxml.etree.TreeBuilder.data" class="py-name" href="#" onclick="return doclink('link-171', 'data', 'link-165');">data</a></tt><tt class="py-op">,</tt> </tt>
<a name="L499"></a><tt class="py-lineno">499</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>
<a name="L500"></a><tt class="py-lineno">500</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>
<a name="L501"></a><tt class="py-lineno">501</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>
<a name="L502"></a><tt class="py-lineno">502</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>
</div><a name="tag_token.html"></a><div id="tag_token.html-def"><a name="L503"></a><tt class="py-lineno">503</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>
</div><div id="tag_token.html-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="tag_token.html-expanded"><a name="L504"></a><tt class="py-lineno">504</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>
</div></div><a name="L505"></a><tt class="py-lineno">505</tt> <tt class="py-line"> </tt>
<a name="href_token"></a><div id="href_token-def"><a name="L506"></a><tt class="py-lineno">506</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>
</div><div id="href_token-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="href_token-expanded"><a name="L507"></a><tt class="py-lineno">507</tt> <tt class="py-line"> </tt>
<a name="L508"></a><tt class="py-lineno">508</tt> <tt class="py-line"> <tt class="py-docstring">""" Represents the href in an anchor tag. Unlike other words, we only</tt> </tt>
<a name="L509"></a><tt class="py-lineno">509</tt> <tt class="py-line"><tt class="py-docstring"> show the href when it changes. """</tt> </tt>
<a name="L510"></a><tt class="py-lineno">510</tt> <tt class="py-line"> </tt>
<a name="L511"></a><tt class="py-lineno">511</tt> <tt class="py-line"> <tt id="link-172" class="py-name"><a title="lxml.html.diff.href_token.hide_when_equal
lxml.html.diff.token.hide_when_equal" class="py-name" href="#" onclick="return doclink('link-172', 'hide_when_equal', 'link-64');">hide_when_equal</a></tt> <tt class="py-op">=</tt> <tt class="py-name">True</tt> </tt>
<a name="L512"></a><tt class="py-lineno">512</tt> <tt class="py-line"> </tt>
<a name="href_token.html"></a><div id="href_token.html-def"><a name="L513"></a><tt class="py-lineno">513</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>
</div><div id="href_token.html-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="href_token.html-expanded"><a name="L514"></a><tt class="py-lineno">514</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>
</div></div><a name="L515"></a><tt class="py-lineno">515</tt> <tt class="py-line"> </tt>
<a name="tokenize"></a><div id="tokenize-def"><a name="L516"></a><tt class="py-lineno">516</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>
</div><div id="tokenize-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="tokenize-expanded"><a name="L517"></a><tt class="py-lineno">517</tt> <tt class="py-line"> <tt class="py-docstring">"""</tt> </tt>
<a name="L518"></a><tt class="py-lineno">518</tt> <tt class="py-line"><tt class="py-docstring"> Parse the given HTML and returns token objects (words with attached tags).</tt> </tt>
<a name="L519"></a><tt class="py-lineno">519</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L520"></a><tt class="py-lineno">520</tt> <tt class="py-line"><tt class="py-docstring"> This parses only the content of a page; anything in the head is</tt> </tt>
<a name="L521"></a><tt class="py-lineno">521</tt> <tt class="py-line"><tt class="py-docstring"> ignored, and the <head> and <body> elements are themselves</tt> </tt>
<a name="L522"></a><tt class="py-lineno">522</tt> <tt class="py-line"><tt class="py-docstring"> optional. The content is then parsed by lxml, which ensures the</tt> </tt>
<a name="L523"></a><tt class="py-lineno">523</tt> <tt class="py-line"><tt class="py-docstring"> validity of the resulting parsed document (though lxml may make</tt> </tt>
<a name="L524"></a><tt class="py-lineno">524</tt> <tt class="py-line"><tt class="py-docstring"> incorrect guesses when the markup is particular bad).</tt> </tt>
<a name="L525"></a><tt class="py-lineno">525</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L526"></a><tt class="py-lineno">526</tt> <tt class="py-line"><tt class="py-docstring"> <ins> and <del> tags are also eliminated from the document, as</tt> </tt>
<a name="L527"></a><tt class="py-lineno">527</tt> <tt class="py-line"><tt class="py-docstring"> that gets confusing.</tt> </tt>
<a name="L528"></a><tt class="py-lineno">528</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L529"></a><tt class="py-lineno">529</tt> <tt class="py-line"><tt class="py-docstring"> If include_hrefs is true, then the href attribute of <a> tags is</tt> </tt>
<a name="L530"></a><tt class="py-lineno">530</tt> <tt class="py-line"><tt class="py-docstring"> included as a special kind of diffable token."""</tt> </tt>
<a name="L531"></a><tt class="py-lineno">531</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt id="link-173" class="py-name"><a title="lxml.etree
lxml.sax.ElementTreeContentHandler.etree
lxml.tests.test_elementtree.CElementTreeTestCase.etree
lxml.tests.test_elementtree._ETreeTestCaseBase.etree
lxml.tests.test_elementtree._XMLPullParserTest.etree
lxml.tests.test_io._IOTestCaseBase.etree" class="py-name" href="#" onclick="return doclink('link-173', 'etree', 'link-1');">etree</a></tt><tt class="py-op">.</tt><tt id="link-174" 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-174', 'iselement', 'link-174');">iselement</a></tt><tt class="py-op">(</tt><tt id="link-175" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-175', 'html', 'link-3');">html</a></tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L532"></a><tt class="py-lineno">532</tt> <tt class="py-line"> <tt class="py-name">body_el</tt> <tt class="py-op">=</tt> <tt id="link-176" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-176', 'html', 'link-3');">html</a></tt> </tt>
<a name="L533"></a><tt class="py-lineno">533</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L534"></a><tt class="py-lineno">534</tt> <tt class="py-line"> <tt class="py-name">body_el</tt> <tt class="py-op">=</tt> <tt id="link-177" 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-177', 'parse_html', 'link-177');">parse_html</a></tt><tt class="py-op">(</tt><tt id="link-178" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
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 class="py-name">cleanup</tt><tt class="py-op">=</tt><tt class="py-name">True</tt><tt class="py-op">)</tt> </tt>
<a name="L535"></a><tt class="py-lineno">535</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>
<a name="L536"></a><tt class="py-lineno">536</tt> <tt class="py-line"> <tt class="py-name">chunks</tt> <tt class="py-op">=</tt> <tt id="link-179" 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-179', 'flatten_el', 'link-179');">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>
<a name="L537"></a><tt class="py-lineno">537</tt> <tt class="py-line"> <tt class="py-comment"># Finally re-joining them into token objects:</tt> </tt>
<a name="L538"></a><tt class="py-lineno">538</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt id="link-180" 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-180', 'fixup_chunks', 'link-180');">fixup_chunks</a></tt><tt class="py-op">(</tt><tt class="py-name">chunks</tt><tt class="py-op">)</tt> </tt>
</div><a name="L539"></a><tt class="py-lineno">539</tt> <tt class="py-line"> </tt>
<a name="parse_html"></a><div id="parse_html-def"><a name="L540"></a><tt class="py-lineno">540</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>
</div><div id="parse_html-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="parse_html-expanded"><a name="L541"></a><tt class="py-lineno">541</tt> <tt class="py-line"> <tt class="py-docstring">"""</tt> </tt>
<a name="L542"></a><tt class="py-lineno">542</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>
<a name="L543"></a><tt class="py-lineno">543</tt> <tt class="py-line"><tt class="py-docstring"> wrapped in a <div> tag that was not in the original document.</tt> </tt>
<a name="L544"></a><tt class="py-lineno">544</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L545"></a><tt class="py-lineno">545</tt> <tt class="py-line"><tt class="py-docstring"> If cleanup is true, make sure there's no <head> or <body>, and get</tt> </tt>
<a name="L546"></a><tt class="py-lineno">546</tt> <tt class="py-line"><tt class="py-docstring"> rid of any <ins> and <del> tags.</tt> </tt>
<a name="L547"></a><tt class="py-lineno">547</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
<a name="L548"></a><tt class="py-lineno">548</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">cleanup</tt><tt class="py-op">:</tt> </tt>
<a name="L549"></a><tt class="py-lineno">549</tt> <tt class="py-line"> <tt class="py-comment"># This removes any extra markup or structure like <head>:</tt> </tt>
<a name="L550"></a><tt class="py-lineno">550</tt> <tt class="py-line"> <tt id="link-181" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-181', 'html', 'link-3');">html</a></tt> <tt class="py-op">=</tt> <tt id="link-182" 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-182', 'cleanup_html', 'link-182');">cleanup_html</a></tt><tt class="py-op">(</tt><tt id="link-183" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-183', 'html', 'link-3');">html</a></tt><tt class="py-op">)</tt> </tt>
<a name="L551"></a><tt class="py-lineno">551</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt id="link-184" class="py-name"><a title="lxml.html.html5parser.fragment_fromstring" class="py-name" href="#" onclick="return doclink('link-184', 'fragment_fromstring', 'link-4');">fragment_fromstring</a></tt><tt class="py-op">(</tt><tt id="link-185" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-185', '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>
</div><a name="L552"></a><tt class="py-lineno">552</tt> <tt class="py-line"> </tt>
<a name="L553"></a><tt class="py-lineno">553</tt> <tt class="py-line"><tt id="link-186" 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-186', '_body_re', 'link-186');">_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'<body.*?>'</tt><tt class="py-op">,</tt> <tt class="py-name">re</tt><tt class="py-op">.</tt><tt id="link-187" 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-187', 'I', 'link-187');">I</a></tt><tt class="py-op">|</tt><tt class="py-name">re</tt><tt class="py-op">.</tt><tt id="link-188" 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-188', 'S', 'link-188');">S</a></tt><tt class="py-op">)</tt> </tt>
<a name="L554"></a><tt class="py-lineno">554</tt> <tt class="py-line"><tt id="link-189" 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-189', '_end_body_re', 'link-189');">_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'</body.*?>'</tt><tt class="py-op">,</tt> <tt class="py-name">re</tt><tt class="py-op">.</tt><tt id="link-190" class="py-name"><a title="lxml.html.builder.I" class="py-name" href="#" onclick="return doclink('link-190', 'I', 'link-187');">I</a></tt><tt class="py-op">|</tt><tt class="py-name">re</tt><tt class="py-op">.</tt><tt id="link-191" class="py-name"><a title="lxml.html.builder.S" class="py-name" href="#" onclick="return doclink('link-191', 'S', 'link-188');">S</a></tt><tt class="py-op">)</tt> </tt>
<a name="L555"></a><tt class="py-lineno">555</tt> <tt class="py-line"><tt id="link-192" 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-192', '_ins_del_re', 'link-192');">_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'</?(ins|del).*?>'</tt><tt class="py-op">,</tt> <tt class="py-name">re</tt><tt class="py-op">.</tt><tt id="link-193" class="py-name"><a title="lxml.html.builder.I" class="py-name" href="#" onclick="return doclink('link-193', 'I', 'link-187');">I</a></tt><tt class="py-op">|</tt><tt class="py-name">re</tt><tt class="py-op">.</tt><tt id="link-194" class="py-name"><a title="lxml.html.builder.S" class="py-name" href="#" onclick="return doclink('link-194', 'S', 'link-188');">S</a></tt><tt class="py-op">)</tt> </tt>
<a name="L556"></a><tt class="py-lineno">556</tt> <tt class="py-line"> </tt>
<a name="cleanup_html"></a><div id="cleanup_html-def"><a name="L557"></a><tt class="py-lineno">557</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>
</div><div id="cleanup_html-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="cleanup_html-expanded"><a name="L558"></a><tt class="py-lineno">558</tt> <tt class="py-line"> <tt class="py-docstring">""" This 'cleans' the HTML, meaning that any page structure is removed</tt> </tt>
<a name="L559"></a><tt class="py-lineno">559</tt> <tt class="py-line"><tt class="py-docstring"> (only the contents of <body> are used, if there is any <body).</tt> </tt>
<a name="L560"></a><tt class="py-lineno">560</tt> <tt class="py-line"><tt class="py-docstring"> Also <ins> and <del> tags are removed. """</tt> </tt>
<a name="L561"></a><tt class="py-lineno">561</tt> <tt class="py-line"> <tt class="py-name">match</tt> <tt class="py-op">=</tt> <tt id="link-195" class="py-name"><a title="lxml.html.diff._body_re" class="py-name" href="#" onclick="return doclink('link-195', '_body_re', 'link-186');">_body_re</a></tt><tt class="py-op">.</tt><tt class="py-name">search</tt><tt class="py-op">(</tt><tt id="link-196" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-196', 'html', 'link-3');">html</a></tt><tt class="py-op">)</tt> </tt>
<a name="L562"></a><tt class="py-lineno">562</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">match</tt><tt class="py-op">:</tt> </tt>
<a name="L563"></a><tt class="py-lineno">563</tt> <tt class="py-line"> <tt id="link-197" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-197', 'html', 'link-3');">html</a></tt> <tt class="py-op">=</tt> <tt id="link-198" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-198', 'html', 'link-3');">html</a></tt><tt class="py-op">[</tt><tt class="py-name">match</tt><tt class="py-op">.</tt><tt id="link-199" class="py-name"><a title="lxml.etree.TreeBuilder.end" class="py-name" href="#" onclick="return doclink('link-199', 'end', 'link-93');">end</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">:</tt><tt class="py-op">]</tt> </tt>
<a name="L564"></a><tt class="py-lineno">564</tt> <tt class="py-line"> <tt class="py-name">match</tt> <tt class="py-op">=</tt> <tt id="link-200" class="py-name"><a title="lxml.html.diff._end_body_re" class="py-name" href="#" onclick="return doclink('link-200', '_end_body_re', 'link-189');">_end_body_re</a></tt><tt class="py-op">.</tt><tt class="py-name">search</tt><tt class="py-op">(</tt><tt id="link-201" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-201', 'html', 'link-3');">html</a></tt><tt class="py-op">)</tt> </tt>
<a name="L565"></a><tt class="py-lineno">565</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">match</tt><tt class="py-op">:</tt> </tt>
<a name="L566"></a><tt class="py-lineno">566</tt> <tt class="py-line"> <tt id="link-202" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
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
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
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 class="py-name">match</tt><tt class="py-op">.</tt><tt id="link-204" class="py-name"><a title="lxml.etree.TreeBuilder.start" class="py-name" href="#" onclick="return doclink('link-204', 'start', 'link-92');">start</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">]</tt> </tt>
<a name="L567"></a><tt class="py-lineno">567</tt> <tt class="py-line"> <tt id="link-205" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-205', 'html', 'link-3');">html</a></tt> <tt class="py-op">=</tt> <tt id="link-206" class="py-name"><a title="lxml.html.diff._ins_del_re" class="py-name" href="#" onclick="return doclink('link-206', '_ins_del_re', 'link-192');">_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-207" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-207', 'html', 'link-3');">html</a></tt><tt class="py-op">)</tt> </tt>
<a name="L568"></a><tt class="py-lineno">568</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt id="link-208" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-208', 'html', 'link-3');">html</a></tt> </tt>
</div><a name="L569"></a><tt class="py-lineno">569</tt> <tt class="py-line"> </tt>
<a name="L570"></a><tt class="py-lineno">570</tt> <tt class="py-line"> </tt>
<a name="L571"></a><tt class="py-lineno">571</tt> <tt class="py-line"><tt id="link-209" 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-209', 'end_whitespace_re', 'link-209');">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>
<a name="L572"></a><tt class="py-lineno">572</tt> <tt class="py-line"> </tt>
<a name="split_trailing_whitespace"></a><div id="split_trailing_whitespace-def"><a name="L573"></a><tt class="py-lineno">573</tt> <a class="py-toggle" href="#" id="split_trailing_whitespace-toggle" onclick="return toggle('split_trailing_whitespace');">-</a><tt class="py-line"><tt class="py-keyword">def</tt> <a class="py-def-name" href="lxml.html.diff-module.html#split_trailing_whitespace">split_trailing_whitespace</a><tt class="py-op">(</tt><tt class="py-param">word</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="split_trailing_whitespace-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="split_trailing_whitespace-expanded"><a name="L574"></a><tt class="py-lineno">574</tt> <tt class="py-line"> <tt class="py-docstring">"""</tt> </tt>
<a name="L575"></a><tt class="py-lineno">575</tt> <tt class="py-line"><tt class="py-docstring"> This function takes a word, such as 'test\n\n' and returns ('test','\n\n')</tt> </tt>
<a name="L576"></a><tt class="py-lineno">576</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
<a name="L577"></a><tt class="py-lineno">577</tt> <tt class="py-line"> <tt class="py-name">stripped_length</tt> <tt class="py-op">=</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">word</tt><tt class="py-op">.</tt><tt class="py-name">rstrip</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
<a name="L578"></a><tt class="py-lineno">578</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">word</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">:</tt><tt class="py-name">stripped_length</tt><tt class="py-op">]</tt><tt class="py-op">,</tt> <tt class="py-name">word</tt><tt class="py-op">[</tt><tt class="py-name">stripped_length</tt><tt class="py-op">:</tt><tt class="py-op">]</tt> </tt>
</div><a name="L579"></a><tt class="py-lineno">579</tt> <tt class="py-line"> </tt>
<a name="L580"></a><tt class="py-lineno">580</tt> <tt class="py-line"> </tt>
<a name="fixup_chunks"></a><div id="fixup_chunks-def"><a name="L581"></a><tt class="py-lineno">581</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>
</div><div id="fixup_chunks-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="fixup_chunks-expanded"><a name="L582"></a><tt class="py-lineno">582</tt> <tt class="py-line"> <tt class="py-docstring">"""</tt> </tt>
<a name="L583"></a><tt class="py-lineno">583</tt> <tt class="py-line"><tt class="py-docstring"> This function takes a list of chunks and produces a list of tokens.</tt> </tt>
<a name="L584"></a><tt class="py-lineno">584</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
<a name="L585"></a><tt class="py-lineno">585</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>
<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 class="py-name">None</tt> </tt>
<a name="L587"></a><tt class="py-lineno">587</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>
<a name="L588"></a><tt class="py-lineno">588</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>
<a name="L589"></a><tt class="py-lineno">589</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>
<a name="L590"></a><tt class="py-lineno">590</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>
<a name="L591"></a><tt class="py-lineno">591</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>
<a name="L592"></a><tt class="py-lineno">592</tt> <tt class="py-line"> <tt id="link-210" class="py-name"><a title="lxml.etree._Comment.tag
lxml.etree._Element.tag
lxml.etree._Entity.tag
lxml.etree._ProcessingInstruction.tag
lxml.tests.test_xpathevaluator.tag
xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-210', 'tag', 'link-103');">tag</a></tt><tt class="py-op">,</tt> <tt class="py-name">trailing_whitespace</tt> <tt class="py-op">=</tt> <tt id="link-211" class="py-name" targets="Function lxml.html.diff.split_trailing_whitespace()=lxml.html.diff-module.html#split_trailing_whitespace"><a title="lxml.html.diff.split_trailing_whitespace" class="py-name" href="#" onclick="return doclink('link-211', 'split_trailing_whitespace', 'link-211');">split_trailing_whitespace</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 class="py-op">)</tt> </tt>
<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-212" 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-212', 'tag_token', 'link-212');">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-213" class="py-name"><a title="lxml.etree._Comment.tag
lxml.etree._Element.tag
lxml.etree._Entity.tag
lxml.etree._ProcessingInstruction.tag
lxml.tests.test_xpathevaluator.tag
xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-213', 'tag', 'link-103');">tag</a></tt><tt class="py-op">,</tt> </tt>
<a name="L594"></a><tt class="py-lineno">594</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>
<a name="L595"></a><tt class="py-lineno">595</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>
<a name="L596"></a><tt class="py-lineno">596</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>
<a name="L597"></a><tt class="py-lineno">597</tt> <tt class="py-line"> <tt class="py-name">result</tt><tt class="py-op">.</tt><tt id="link-214" class="py-name"><a title="lxml.etree._Element.append" class="py-name" href="#" onclick="return doclink('link-214', 'append', 'link-24');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">cur_word</tt><tt class="py-op">)</tt> </tt>
<a name="L598"></a><tt class="py-lineno">598</tt> <tt class="py-line"> </tt>
<a name="L599"></a><tt class="py-lineno">599</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>
<a name="L600"></a><tt class="py-lineno">600</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>
<a name="L601"></a><tt class="py-lineno">601</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.href_token=lxml.html.diff.href_token-class.html"><a title="lxml.html.diff.href_token" class="py-name" href="#" onclick="return doclink('link-215', 'href_token', 'link-215');">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-string">" "</tt><tt class="py-op">)</tt> </tt>
<a name="L602"></a><tt class="py-lineno">602</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>
<a name="L603"></a><tt class="py-lineno">603</tt> <tt class="py-line"> <tt class="py-name">result</tt><tt class="py-op">.</tt><tt id="link-216" class="py-name"><a title="lxml.etree._Element.append" class="py-name" href="#" onclick="return doclink('link-216', 'append', 'link-24');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">cur_word</tt><tt class="py-op">)</tt> </tt>
<a name="L604"></a><tt class="py-lineno">604</tt> <tt class="py-line"> <tt class="py-keyword">continue</tt> </tt>
<a name="L605"></a><tt class="py-lineno">605</tt> <tt class="py-line"> </tt>
<a name="L606"></a><tt class="py-lineno">606</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt id="link-217" 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-217', 'is_word', 'link-217');">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>
<a name="L607"></a><tt class="py-lineno">607</tt> <tt class="py-line"> <tt class="py-name">chunk</tt><tt class="py-op">,</tt> <tt class="py-name">trailing_whitespace</tt> <tt class="py-op">=</tt> <tt id="link-218" class="py-name"><a title="lxml.html.diff.split_trailing_whitespace" class="py-name" href="#" onclick="return doclink('link-218', 'split_trailing_whitespace', 'link-211');">split_trailing_whitespace</a></tt><tt class="py-op">(</tt><tt class="py-name">chunk</tt><tt class="py-op">)</tt> </tt>
<a name="L608"></a><tt class="py-lineno">608</tt> <tt class="py-line"> <tt class="py-name">cur_word</tt> <tt class="py-op">=</tt> <tt id="link-219" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-219', 'token', 'link-26');">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>
<a name="L609"></a><tt class="py-lineno">609</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>
<a name="L610"></a><tt class="py-lineno">610</tt> <tt class="py-line"> <tt class="py-name">result</tt><tt class="py-op">.</tt><tt id="link-220" class="py-name"><a title="lxml.etree._Element.append" class="py-name" href="#" onclick="return doclink('link-220', 'append', 'link-24');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">cur_word</tt><tt class="py-op">)</tt> </tt>
<a name="L611"></a><tt class="py-lineno">611</tt> <tt class="py-line"> </tt>
<a name="L612"></a><tt class="py-lineno">612</tt> <tt class="py-line"> <tt class="py-keyword">elif</tt> <tt id="link-221" 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-221', 'is_start_tag', 'link-221');">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>
<a name="L613"></a><tt class="py-lineno">613</tt> <tt class="py-line"> <tt class="py-name">tag_accum</tt><tt class="py-op">.</tt><tt id="link-222" class="py-name"><a title="lxml.etree._Element.append" class="py-name" href="#" onclick="return doclink('link-222', 'append', 'link-24');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">chunk</tt><tt class="py-op">)</tt> </tt>
<a name="L614"></a><tt class="py-lineno">614</tt> <tt class="py-line"> </tt>
<a name="L615"></a><tt class="py-lineno">615</tt> <tt class="py-line"> <tt class="py-keyword">elif</tt> <tt id="link-223" 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-223', 'is_end_tag', 'link-223');">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>
<a name="L616"></a><tt class="py-lineno">616</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">tag_accum</tt><tt class="py-op">:</tt> </tt>
<a name="L617"></a><tt class="py-lineno">617</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._Element.append" class="py-name" href="#" onclick="return doclink('link-224', 'append', 'link-24');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">chunk</tt><tt class="py-op">)</tt> </tt>
<a name="L618"></a><tt class="py-lineno">618</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L619"></a><tt class="py-lineno">619</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>
<a name="L620"></a><tt class="py-lineno">620</tt> <tt class="py-line"> <tt class="py-string">"Weird state, cur_word=%r, result=%r, chunks=%r of %r"</tt> </tt>
<a name="L621"></a><tt class="py-lineno">621</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>
<a name="L622"></a><tt class="py-lineno">622</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-225" class="py-name"><a title="lxml.etree._Element.append" class="py-name" href="#" onclick="return doclink('link-225', 'append', 'link-24');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">chunk</tt><tt class="py-op">)</tt> </tt>
<a name="L623"></a><tt class="py-lineno">623</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L624"></a><tt class="py-lineno">624</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>
<a name="L625"></a><tt class="py-lineno">625</tt> <tt class="py-line"> </tt>
<a name="L626"></a><tt class="py-lineno">626</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>
<a name="L627"></a><tt class="py-lineno">627</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-op">[</tt><tt id="link-226" class="py-name"><a title="lxml.html.diff.token" class="py-name" href="#" onclick="return doclink('link-226', 'token', 'link-26');">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>
<a name="L628"></a><tt class="py-lineno">628</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L629"></a><tt class="py-lineno">629</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-227" class="py-name"><a title="lxml.etree._Element.extend" class="py-name" href="#" onclick="return doclink('link-227', 'extend', 'link-54');">extend</a></tt><tt class="py-op">(</tt><tt class="py-name">tag_accum</tt><tt class="py-op">)</tt> </tt>
<a name="L630"></a><tt class="py-lineno">630</tt> <tt class="py-line"> </tt>
<a name="L631"></a><tt class="py-lineno">631</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">result</tt> </tt>
</div><a name="L632"></a><tt class="py-lineno">632</tt> <tt class="py-line"> </tt>
<a name="L633"></a><tt class="py-lineno">633</tt> <tt class="py-line"> </tt>
<a name="L634"></a><tt class="py-lineno">634</tt> <tt class="py-line"><tt class="py-comment"># All the tags in HTML that don't require end tags:</tt> </tt>
<a name="L635"></a><tt class="py-lineno">635</tt> <tt class="py-line"><tt id="link-228" class="py-name"><a title="lxml.doctestcompare.LXMLOutputChecker.empty_tags
lxml.html.defs.empty_tags
lxml.html.diff.empty_tags" class="py-name" href="#" onclick="return doclink('link-228', 'empty_tags', 'link-98');">empty_tags</a></tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt> </tt>
<a name="L636"></a><tt class="py-lineno">636</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>
<a name="L637"></a><tt class="py-lineno">637</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>
<a name="L638"></a><tt class="py-lineno">638</tt> <tt class="py-line"> </tt>
<a name="L639"></a><tt class="py-lineno">639</tt> <tt class="py-line"><tt id="link-229" 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-229', 'block_level_tags', 'link-229');">block_level_tags</a></tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt> </tt>
<a name="L640"></a><tt class="py-lineno">640</tt> <tt class="py-line"> <tt class="py-string">'address'</tt><tt class="py-op">,</tt> </tt>
<a name="L641"></a><tt class="py-lineno">641</tt> <tt class="py-line"> <tt class="py-string">'blockquote'</tt><tt class="py-op">,</tt> </tt>
<a name="L642"></a><tt class="py-lineno">642</tt> <tt class="py-line"> <tt class="py-string">'center'</tt><tt class="py-op">,</tt> </tt>
<a name="L643"></a><tt class="py-lineno">643</tt> <tt class="py-line"> <tt class="py-string">'dir'</tt><tt class="py-op">,</tt> </tt>
<a name="L644"></a><tt class="py-lineno">644</tt> <tt class="py-line"> <tt class="py-string">'div'</tt><tt class="py-op">,</tt> </tt>
<a name="L645"></a><tt class="py-lineno">645</tt> <tt class="py-line"> <tt class="py-string">'dl'</tt><tt class="py-op">,</tt> </tt>
<a name="L646"></a><tt class="py-lineno">646</tt> <tt class="py-line"> <tt class="py-string">'fieldset'</tt><tt class="py-op">,</tt> </tt>
<a name="L647"></a><tt class="py-lineno">647</tt> <tt class="py-line"> <tt class="py-string">'form'</tt><tt class="py-op">,</tt> </tt>
<a name="L648"></a><tt class="py-lineno">648</tt> <tt class="py-line"> <tt class="py-string">'h1'</tt><tt class="py-op">,</tt> </tt>
<a name="L649"></a><tt class="py-lineno">649</tt> <tt class="py-line"> <tt class="py-string">'h2'</tt><tt class="py-op">,</tt> </tt>
<a name="L650"></a><tt class="py-lineno">650</tt> <tt class="py-line"> <tt class="py-string">'h3'</tt><tt class="py-op">,</tt> </tt>
<a name="L651"></a><tt class="py-lineno">651</tt> <tt class="py-line"> <tt class="py-string">'h4'</tt><tt class="py-op">,</tt> </tt>
<a name="L652"></a><tt class="py-lineno">652</tt> <tt class="py-line"> <tt class="py-string">'h5'</tt><tt class="py-op">,</tt> </tt>
<a name="L653"></a><tt class="py-lineno">653</tt> <tt class="py-line"> <tt class="py-string">'h6'</tt><tt class="py-op">,</tt> </tt>
<a name="L654"></a><tt class="py-lineno">654</tt> <tt class="py-line"> <tt class="py-string">'hr'</tt><tt class="py-op">,</tt> </tt>
<a name="L655"></a><tt class="py-lineno">655</tt> <tt class="py-line"> <tt class="py-string">'isindex'</tt><tt class="py-op">,</tt> </tt>
<a name="L656"></a><tt class="py-lineno">656</tt> <tt class="py-line"> <tt class="py-string">'menu'</tt><tt class="py-op">,</tt> </tt>
<a name="L657"></a><tt class="py-lineno">657</tt> <tt class="py-line"> <tt class="py-string">'noframes'</tt><tt class="py-op">,</tt> </tt>
<a name="L658"></a><tt class="py-lineno">658</tt> <tt class="py-line"> <tt class="py-string">'noscript'</tt><tt class="py-op">,</tt> </tt>
<a name="L659"></a><tt class="py-lineno">659</tt> <tt class="py-line"> <tt class="py-string">'ol'</tt><tt class="py-op">,</tt> </tt>
<a name="L660"></a><tt class="py-lineno">660</tt> <tt class="py-line"> <tt class="py-string">'p'</tt><tt class="py-op">,</tt> </tt>
<a name="L661"></a><tt class="py-lineno">661</tt> <tt class="py-line"> <tt class="py-string">'pre'</tt><tt class="py-op">,</tt> </tt>
<a name="L662"></a><tt class="py-lineno">662</tt> <tt class="py-line"> <tt class="py-string">'table'</tt><tt class="py-op">,</tt> </tt>
<a name="L663"></a><tt class="py-lineno">663</tt> <tt class="py-line"> <tt class="py-string">'ul'</tt><tt class="py-op">,</tt> </tt>
<a name="L664"></a><tt class="py-lineno">664</tt> <tt class="py-line"> <tt class="py-op">)</tt> </tt>
<a name="L665"></a><tt class="py-lineno">665</tt> <tt class="py-line"> </tt>
<a name="L666"></a><tt class="py-lineno">666</tt> <tt class="py-line"><tt id="link-230" 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-230', 'block_level_container_tags', 'link-230');">block_level_container_tags</a></tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt> </tt>
<a name="L667"></a><tt class="py-lineno">667</tt> <tt class="py-line"> <tt class="py-string">'dd'</tt><tt class="py-op">,</tt> </tt>
<a name="L668"></a><tt class="py-lineno">668</tt> <tt class="py-line"> <tt class="py-string">'dt'</tt><tt class="py-op">,</tt> </tt>
<a name="L669"></a><tt class="py-lineno">669</tt> <tt class="py-line"> <tt class="py-string">'frameset'</tt><tt class="py-op">,</tt> </tt>
<a name="L670"></a><tt class="py-lineno">670</tt> <tt class="py-line"> <tt class="py-string">'li'</tt><tt class="py-op">,</tt> </tt>
<a name="L671"></a><tt class="py-lineno">671</tt> <tt class="py-line"> <tt class="py-string">'tbody'</tt><tt class="py-op">,</tt> </tt>
<a name="L672"></a><tt class="py-lineno">672</tt> <tt class="py-line"> <tt class="py-string">'td'</tt><tt class="py-op">,</tt> </tt>
<a name="L673"></a><tt class="py-lineno">673</tt> <tt class="py-line"> <tt class="py-string">'tfoot'</tt><tt class="py-op">,</tt> </tt>
<a name="L674"></a><tt class="py-lineno">674</tt> <tt class="py-line"> <tt class="py-string">'th'</tt><tt class="py-op">,</tt> </tt>
<a name="L675"></a><tt class="py-lineno">675</tt> <tt class="py-line"> <tt class="py-string">'thead'</tt><tt class="py-op">,</tt> </tt>
<a name="L676"></a><tt class="py-lineno">676</tt> <tt class="py-line"> <tt class="py-string">'tr'</tt><tt class="py-op">,</tt> </tt>
<a name="L677"></a><tt class="py-lineno">677</tt> <tt class="py-line"> <tt class="py-op">)</tt> </tt>
<a name="L678"></a><tt class="py-lineno">678</tt> <tt class="py-line"> </tt>
<a name="L679"></a><tt class="py-lineno">679</tt> <tt class="py-line"> </tt>
<a name="flatten_el"></a><div id="flatten_el-def"><a name="L680"></a><tt class="py-lineno">680</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>
</div><div id="flatten_el-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="flatten_el-expanded"><a name="L681"></a><tt class="py-lineno">681</tt> <tt class="py-line"> <tt class="py-docstring">""" Takes an lxml element el, and generates all the text chunks for</tt> </tt>
<a name="L682"></a><tt class="py-lineno">682</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>
<a name="L683"></a><tt class="py-lineno">683</tt> <tt class="py-line"><tt class="py-docstring"> end tag is a chunk.</tt> </tt>
<a name="L684"></a><tt class="py-lineno">684</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L685"></a><tt class="py-lineno">685</tt> <tt class="py-line"><tt class="py-docstring"> If skip_tag is true, then the outermost container tag is</tt> </tt>
<a name="L686"></a><tt class="py-lineno">686</tt> <tt class="py-line"><tt class="py-docstring"> not returned (just its contents)."""</tt> </tt>
<a name="L687"></a><tt class="py-lineno">687</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>
<a name="L688"></a><tt class="py-lineno">688</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-231" class="py-name"><a title="lxml.etree._Comment.tag
lxml.etree._Element.tag
lxml.etree._Entity.tag
lxml.etree._ProcessingInstruction.tag
lxml.tests.test_xpathevaluator.tag
xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-231', 'tag', 'link-103');">tag</a></tt> <tt class="py-op">==</tt> <tt class="py-string">'img'</tt><tt class="py-op">:</tt> </tt>
<a name="L689"></a><tt class="py-lineno">689</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-232" 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"><a title="lxml.etree._Attrib.get
lxml.etree._Element.get
lxml.etree._IDDict.get
lxml.etree._ProcessingInstruction.get" class="py-name" href="#" onclick="return doclink('link-232', 'get', 'link-232');">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-233" 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-233', 'start_tag', 'link-233');">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>
<a name="L690"></a><tt class="py-lineno">690</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L691"></a><tt class="py-lineno">691</tt> <tt class="py-line"> <tt class="py-keyword">yield</tt> <tt id="link-234" class="py-name"><a title="lxml.html.diff.start_tag" class="py-name" href="#" onclick="return doclink('link-234', 'start_tag', 'link-233');">start_tag</a></tt><tt class="py-op">(</tt><tt class="py-name">el</tt><tt class="py-op">)</tt> </tt>
<a name="L692"></a><tt class="py-lineno">692</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-235" class="py-name"><a title="lxml.etree._Comment.tag
lxml.etree._Element.tag
lxml.etree._Entity.tag
lxml.etree._ProcessingInstruction.tag
lxml.tests.test_xpathevaluator.tag
xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-235', 'tag', 'link-103');">tag</a></tt> <tt class="py-keyword">in</tt> <tt id="link-236" class="py-name"><a title="lxml.doctestcompare.LXMLOutputChecker.empty_tags
lxml.html.defs.empty_tags
lxml.html.diff.empty_tags" class="py-name" href="#" onclick="return doclink('link-236', 'empty_tags', 'link-98');">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-237" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-237', 'text', 'link-11');">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-238" class="py-name" targets="Variable lxml.etree._Element.tail=lxml.etree._Element-class.html#tail,Variable xml.etree.ElementTree.Element.tail=xml.etree.ElementTree.Element-class.html#tail"><a title="lxml.etree._Element.tail
xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-238', 'tail', 'link-238');">tail</a></tt><tt class="py-op">:</tt> </tt>
<a name="L693"></a><tt class="py-lineno">693</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> </tt>
<a name="L694"></a><tt class="py-lineno">694</tt> <tt class="py-line"> <tt class="py-name">start_words</tt> <tt class="py-op">=</tt> <tt id="link-239" 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-239', 'split_words', 'link-239');">split_words</a></tt><tt class="py-op">(</tt><tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-240" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-240', 'text', 'link-11');">text</a></tt><tt class="py-op">)</tt> </tt>
<a name="L695"></a><tt class="py-lineno">695</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>
<a name="L696"></a><tt class="py-lineno">696</tt> <tt class="py-line"> <tt class="py-keyword">yield</tt> <tt class="py-name">html_escape</tt><tt class="py-op">(</tt><tt class="py-name">word</tt><tt class="py-op">)</tt> </tt>
<a name="L697"></a><tt class="py-lineno">697</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>
<a name="L698"></a><tt class="py-lineno">698</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-241" class="py-name"><a title="lxml.html.diff.flatten_el" class="py-name" href="#" onclick="return doclink('link-241', 'flatten_el', 'link-179');">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>
<a name="L699"></a><tt class="py-lineno">699</tt> <tt class="py-line"> <tt class="py-keyword">yield</tt> <tt class="py-name">item</tt> </tt>
<a name="L700"></a><tt class="py-lineno">700</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-242" class="py-name"><a title="lxml.etree._Comment.tag
lxml.etree._Element.tag
lxml.etree._Entity.tag
lxml.etree._ProcessingInstruction.tag
lxml.tests.test_xpathevaluator.tag
xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-242', 'tag', 'link-103');">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-243" class="py-name"><a title="lxml.etree._Attrib.get
lxml.etree._Element.get
lxml.etree._IDDict.get
lxml.etree._ProcessingInstruction.get" class="py-name" href="#" onclick="return doclink('link-243', 'get', 'link-232');">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>
<a name="L701"></a><tt class="py-lineno">701</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-244" class="py-name"><a title="lxml.etree._Attrib.get
lxml.etree._Element.get
lxml.etree._IDDict.get
lxml.etree._ProcessingInstruction.get" class="py-name" href="#" onclick="return doclink('link-244', 'get', 'link-232');">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>
<a name="L702"></a><tt class="py-lineno">702</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>
<a name="L703"></a><tt class="py-lineno">703</tt> <tt class="py-line"> <tt class="py-keyword">yield</tt> <tt id="link-245" 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-245', 'end_tag', 'link-245');">end_tag</a></tt><tt class="py-op">(</tt><tt class="py-name">el</tt><tt class="py-op">)</tt> </tt>
<a name="L704"></a><tt class="py-lineno">704</tt> <tt class="py-line"> <tt class="py-name">end_words</tt> <tt class="py-op">=</tt> <tt id="link-246" class="py-name"><a title="lxml.html.diff.split_words" class="py-name" href="#" onclick="return doclink('link-246', 'split_words', 'link-239');">split_words</a></tt><tt class="py-op">(</tt><tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-247" class="py-name"><a title="lxml.etree._Element.tail
xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-247', 'tail', 'link-238');">tail</a></tt><tt class="py-op">)</tt> </tt>
<a name="L705"></a><tt class="py-lineno">705</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>
<a name="L706"></a><tt class="py-lineno">706</tt> <tt class="py-line"> <tt class="py-keyword">yield</tt> <tt class="py-name">html_escape</tt><tt class="py-op">(</tt><tt class="py-name">word</tt><tt class="py-op">)</tt> </tt>
</div><a name="L707"></a><tt class="py-lineno">707</tt> <tt class="py-line"> </tt>
<a name="L708"></a><tt class="py-lineno">708</tt> <tt class="py-line"><tt id="link-248" class="py-name" targets="Variable lxml.html.diff.split_words_re=lxml.html.diff-module.html#split_words_re"><a title="lxml.html.diff.split_words_re" class="py-name" href="#" onclick="return doclink('link-248', 'split_words_re', 'link-248');">split_words_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'\S+(?:\s+|$)'</tt><tt class="py-op">,</tt> <tt class="py-name">re</tt><tt class="py-op">.</tt><tt id="link-249" class="py-name" targets="Variable lxml.html.builder.U=lxml.html.builder-module.html#U"><a title="lxml.html.builder.U" class="py-name" href="#" onclick="return doclink('link-249', 'U', 'link-249');">U</a></tt><tt class="py-op">)</tt> </tt>
<a name="L709"></a><tt class="py-lineno">709</tt> <tt class="py-line"> </tt>
<a name="split_words"></a><div id="split_words-def"><a name="L710"></a><tt class="py-lineno">710</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>
</div><div id="split_words-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="split_words-expanded"><a name="L711"></a><tt class="py-lineno">711</tt> <tt class="py-line"> <tt class="py-docstring">""" Splits some text into words. Includes trailing whitespace</tt> </tt>
<a name="L712"></a><tt class="py-lineno">712</tt> <tt class="py-line"><tt class="py-docstring"> on each word when appropriate. """</tt> </tt>
<a name="L713"></a><tt class="py-lineno">713</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
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-250', 'text', 'link-11');">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
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-251', 'text', 'link-11');">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-19');">strip</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L714"></a><tt class="py-lineno">714</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-op">[</tt><tt class="py-op">]</tt> </tt>
<a name="L715"></a><tt class="py-lineno">715</tt> <tt class="py-line"> </tt>
<a name="L716"></a><tt class="py-lineno">716</tt> <tt class="py-line"> <tt class="py-name">words</tt> <tt class="py-op">=</tt> <tt id="link-253" class="py-name"><a title="lxml.html.diff.split_words_re" class="py-name" href="#" onclick="return doclink('link-253', 'split_words_re', 'link-248');">split_words_re</a></tt><tt class="py-op">.</tt><tt id="link-254" class="py-name" targets="Method lxml.etree._Element.findall()=lxml.etree._Element-class.html#findall,Method lxml.etree._ElementTree.findall()=lxml.etree._ElementTree-class.html#findall"><a title="lxml.etree._Element.findall
lxml.etree._ElementTree.findall" class="py-name" href="#" onclick="return doclink('link-254', 'findall', 'link-254');">findall</a></tt><tt class="py-op">(</tt><tt id="link-255" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-255', 'text', 'link-11');">text</a></tt><tt class="py-op">)</tt> </tt>
<a name="L717"></a><tt class="py-lineno">717</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">words</tt> </tt>
</div><a name="L718"></a><tt class="py-lineno">718</tt> <tt class="py-line"> </tt>
<a name="L719"></a><tt class="py-lineno">719</tt> <tt class="py-line"><tt id="link-256" 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-256', 'start_whitespace_re', 'link-256');">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>
<a name="L720"></a><tt class="py-lineno">720</tt> <tt class="py-line"> </tt>
<a name="start_tag"></a><div id="start_tag-def"><a name="L721"></a><tt class="py-lineno">721</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>
</div><div id="start_tag-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="start_tag-expanded"><a name="L722"></a><tt class="py-lineno">722</tt> <tt class="py-line"> <tt class="py-docstring">"""</tt> </tt>
<a name="L723"></a><tt class="py-lineno">723</tt> <tt class="py-line"><tt class="py-docstring"> The text representation of the start tag for a tag.</tt> </tt>
<a name="L724"></a><tt class="py-lineno">724</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
<a name="L725"></a><tt class="py-lineno">725</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-string">'<%s%s>'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt> </tt>
<a name="L726"></a><tt class="py-lineno">726</tt> <tt class="py-line"> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-257" class="py-name"><a title="lxml.etree._Comment.tag
lxml.etree._Element.tag
lxml.etree._Entity.tag
lxml.etree._ProcessingInstruction.tag
lxml.tests.test_xpathevaluator.tag
xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-257', 'tag', 'link-103');">tag</a></tt><tt class="py-op">,</tt> <tt class="py-string">''</tt><tt class="py-op">.</tt><tt class="py-name">join</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-258" class="py-name"><a title="lxml.etree.DTD.name
lxml.etree._Entity.name
lxml.html.InputMixin.name
lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-258', 'name', 'link-95');">name</a></tt><tt class="py-op">,</tt> <tt class="py-name">html_escape</tt><tt class="py-op">(</tt><tt id="link-259" 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
lxml.html.InputElement.value
lxml.html.RadioGroup.value
lxml.html.SelectElement.value
lxml.html.TextareaElement.value" class="py-name" href="#" onclick="return doclink('link-259', 'value', 'link-259');">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>
<a name="L727"></a><tt class="py-lineno">727</tt> <tt class="py-line"> <tt class="py-keyword">for</tt> <tt id="link-260" class="py-name"><a title="lxml.etree.DTD.name
lxml.etree._Entity.name
lxml.html.InputMixin.name
lxml.objectify.PyType.name" class="py-name" href="#" onclick="return doclink('link-260', 'name', 'link-95');">name</a></tt><tt class="py-op">,</tt> <tt id="link-261" class="py-name"><a title="lxml.html.CheckboxGroup.value
lxml.html.InputElement.value
lxml.html.RadioGroup.value
lxml.html.SelectElement.value
lxml.html.TextareaElement.value" class="py-name" href="#" onclick="return doclink('link-261', 'value', 'link-259');">value</a></tt> <tt class="py-keyword">in</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-262" 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,Function lxml.tests.selftest2.attrib()=lxml.tests.selftest2-module.html#attrib,Variable xml.etree.ElementTree.Element.attrib=xml.etree.ElementTree.Element-class.html#attrib"><a title="lxml.etree._Element.attrib
lxml.etree._ProcessingInstruction.attrib
lxml.tests.selftest2.attrib
xml.etree.ElementTree.Element.attrib" class="py-name" href="#" onclick="return doclink('link-262', 'attrib', 'link-262');">attrib</a></tt><tt class="py-op">.</tt><tt id="link-263" 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"><a title="lxml.etree._Attrib.items
lxml.etree._Element.items
lxml.etree._IDDict.items" class="py-name" href="#" onclick="return doclink('link-263', 'items', 'link-263');">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>
</div><a name="L728"></a><tt class="py-lineno">728</tt> <tt class="py-line"> </tt>
<a name="end_tag"></a><div id="end_tag-def"><a name="L729"></a><tt class="py-lineno">729</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>
</div><div id="end_tag-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="end_tag-expanded"><a name="L730"></a><tt class="py-lineno">730</tt> <tt class="py-line"> <tt class="py-docstring">""" The text representation of an end tag for a tag. Includes</tt> </tt>
<a name="L731"></a><tt class="py-lineno">731</tt> <tt class="py-line"><tt class="py-docstring"> trailing whitespace when appropriate. """</tt> </tt>
<a name="L732"></a><tt class="py-lineno">732</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-264" class="py-name"><a title="lxml.etree._Element.tail
xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-264', 'tail', 'link-238');">tail</a></tt> <tt class="py-keyword">and</tt> <tt id="link-265" class="py-name"><a title="lxml.html.diff.start_whitespace_re" class="py-name" href="#" onclick="return doclink('link-265', 'start_whitespace_re', 'link-256');">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-266" class="py-name"><a title="lxml.etree._Element.tail
xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-266', 'tail', 'link-238');">tail</a></tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L733"></a><tt class="py-lineno">733</tt> <tt class="py-line"> <tt class="py-name">extra</tt> <tt class="py-op">=</tt> <tt class="py-string">' '</tt> </tt>
<a name="L734"></a><tt class="py-lineno">734</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L735"></a><tt class="py-lineno">735</tt> <tt class="py-line"> <tt class="py-name">extra</tt> <tt class="py-op">=</tt> <tt class="py-string">''</tt> </tt>
<a name="L736"></a><tt class="py-lineno">736</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-string">'</%s>%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-267" class="py-name"><a title="lxml.etree._Comment.tag
lxml.etree._Element.tag
lxml.etree._Entity.tag
lxml.etree._ProcessingInstruction.tag
lxml.tests.test_xpathevaluator.tag
xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-267', 'tag', 'link-103');">tag</a></tt><tt class="py-op">,</tt> <tt class="py-name">extra</tt><tt class="py-op">)</tt> </tt>
</div><a name="L737"></a><tt class="py-lineno">737</tt> <tt class="py-line"> </tt>
<a name="is_word"></a><div id="is_word-def"><a name="L738"></a><tt class="py-lineno">738</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>
</div><div id="is_word-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="is_word-expanded"><a name="L739"></a><tt class="py-lineno">739</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">'<'</tt><tt class="py-op">)</tt> </tt>
</div><a name="L740"></a><tt class="py-lineno">740</tt> <tt class="py-line"> </tt>
<a name="is_end_tag"></a><div id="is_end_tag-def"><a name="L741"></a><tt class="py-lineno">741</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>
</div><div id="is_end_tag-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="is_end_tag-expanded"><a name="L742"></a><tt class="py-lineno">742</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">'</'</tt><tt class="py-op">)</tt> </tt>
</div><a name="L743"></a><tt class="py-lineno">743</tt> <tt class="py-line"> </tt>
<a name="is_start_tag"></a><div id="is_start_tag-def"><a name="L744"></a><tt class="py-lineno">744</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>
</div><div id="is_start_tag-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="is_start_tag-expanded"><a name="L745"></a><tt class="py-lineno">745</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">'<'</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">'</'</tt><tt class="py-op">)</tt> </tt>
</div><a name="L746"></a><tt class="py-lineno">746</tt> <tt class="py-line"> </tt>
<a name="fixup_ins_del_tags"></a><div id="fixup_ins_del_tags-def"><a name="L747"></a><tt class="py-lineno">747</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>
</div><div id="fixup_ins_del_tags-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="fixup_ins_del_tags-expanded"><a name="L748"></a><tt class="py-lineno">748</tt> <tt class="py-line"> <tt class="py-docstring">""" Given an html string, move any <ins> or <del> tags inside of any</tt> </tt>
<a name="L749"></a><tt class="py-lineno">749</tt> <tt class="py-line"><tt class="py-docstring"> block-level elements, e.g. transform <ins><p>word</p></ins> to</tt> </tt>
<a name="L750"></a><tt class="py-lineno">750</tt> <tt class="py-line"><tt class="py-docstring"> <p><ins>word</ins></p> """</tt> </tt>
<a name="L751"></a><tt class="py-lineno">751</tt> <tt class="py-line"> <tt class="py-name">doc</tt> <tt class="py-op">=</tt> <tt id="link-268" class="py-name"><a title="lxml.html.diff.parse_html" class="py-name" href="#" onclick="return doclink('link-268', 'parse_html', 'link-177');">parse_html</a></tt><tt class="py-op">(</tt><tt id="link-269" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-269', '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>
<a name="L752"></a><tt class="py-lineno">752</tt> <tt class="py-line"> <tt id="link-270" 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-270', '_fixup_ins_del_tags', 'link-270');">_fixup_ins_del_tags</a></tt><tt class="py-op">(</tt><tt class="py-name">doc</tt><tt class="py-op">)</tt> </tt>
<a name="L753"></a><tt class="py-lineno">753</tt> <tt class="py-line"> <tt id="link-271" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
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 id="link-272" 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-272', 'serialize_html_fragment', 'link-272');">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>
<a name="L754"></a><tt class="py-lineno">754</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt id="link-273" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-273', 'html', 'link-3');">html</a></tt> </tt>
</div><a name="L755"></a><tt class="py-lineno">755</tt> <tt class="py-line"> </tt>
<a name="serialize_html_fragment"></a><div id="serialize_html_fragment-def"><a name="L756"></a><tt class="py-lineno">756</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>
</div><div id="serialize_html_fragment-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="serialize_html_fragment-expanded"><a name="L757"></a><tt class="py-lineno">757</tt> <tt class="py-line"> <tt class="py-docstring">""" Serialize a single lxml element as HTML. The serialized form</tt> </tt>
<a name="L758"></a><tt class="py-lineno">758</tt> <tt class="py-line"><tt class="py-docstring"> includes the elements tail. </tt> </tt>
<a name="L759"></a><tt class="py-lineno">759</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L760"></a><tt class="py-lineno">760</tt> <tt class="py-line"><tt class="py-docstring"> If skip_outer is true, then don't serialize the outermost tag</tt> </tt>
<a name="L761"></a><tt class="py-lineno">761</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
<a name="L762"></a><tt class="py-lineno">762</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 id="link-274" class="py-name"><a title="lxml.html.clean.basestring" class="py-name" href="#" onclick="return doclink('link-274', 'basestring', 'link-7');">basestring</a></tt><tt class="py-op">)</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt> </tt>
<a name="L763"></a><tt class="py-lineno">763</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>
<a name="L764"></a><tt class="py-lineno">764</tt> <tt class="py-line"> <tt id="link-275" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-275', 'html', 'link-3');">html</a></tt> <tt class="py-op">=</tt> <tt id="link-276" class="py-name"><a title="lxml.etree
lxml.sax.ElementTreeContentHandler.etree
lxml.tests.test_elementtree.CElementTreeTestCase.etree
lxml.tests.test_elementtree._ETreeTestCaseBase.etree
lxml.tests.test_elementtree._XMLPullParserTest.etree
lxml.tests.test_io._IOTestCaseBase.etree" class="py-name" href="#" onclick="return doclink('link-276', 'etree', 'link-1');">etree</a></tt><tt class="py-op">.</tt><tt id="link-277" class="py-name" targets="Method lxml.etree.XSLT.tostring()=lxml.etree.XSLT-class.html#tostring,Function lxml.etree.tostring()=lxml.etree-module.html#tostring"><a title="lxml.etree.XSLT.tostring
lxml.etree.tostring" class="py-name" href="#" onclick="return doclink('link-277', 'tostring', 'link-277');">tostring</a></tt><tt class="py-op">(</tt><tt class="py-name">el</tt><tt class="py-op">,</tt> <tt id="link-278" 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-278', 'method', 'link-278');">method</a></tt><tt class="py-op">=</tt><tt class="py-string">"html"</tt><tt class="py-op">,</tt> <tt id="link-279" class="py-name" targets="Variable lxml.etree.DocInfo.encoding=lxml.etree.DocInfo-class.html#encoding,Function lxml.tests.selftest.encoding()=lxml.tests.selftest-module.html#encoding,Function lxml.tests.selftest2.encoding()=lxml.tests.selftest2-module.html#encoding"><a title="lxml.etree.DocInfo.encoding
lxml.tests.selftest.encoding
lxml.tests.selftest2.encoding" class="py-name" href="#" onclick="return doclink('link-279', 'encoding', 'link-279');">encoding</a></tt><tt class="py-op">=</tt><tt class="py-name">_unicode</tt><tt class="py-op">)</tt> </tt>
<a name="L765"></a><tt class="py-lineno">765</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">skip_outer</tt><tt class="py-op">:</tt> </tt>
<a name="L766"></a><tt class="py-lineno">766</tt> <tt class="py-line"> <tt class="py-comment"># Get rid of the extra starting tag:</tt> </tt>
<a name="L767"></a><tt class="py-lineno">767</tt> <tt class="py-line"> <tt id="link-280" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-280', 'html', 'link-3');">html</a></tt> <tt class="py-op">=</tt> <tt id="link-281" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
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
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
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" 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,Function lxml.tests.selftest.find()=lxml.tests.selftest-module.html#find,Function lxml.tests.selftest2.find()=lxml.tests.selftest2-module.html#find"><a title="lxml.etree._Element.find
lxml.etree._ElementTree.find
lxml.objectify.ObjectPath.find
lxml.tests.selftest.find
lxml.tests.selftest2.find" class="py-name" href="#" onclick="return doclink('link-283', 'find', 'link-283');">find</a></tt><tt class="py-op">(</tt><tt class="py-string">'>'</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>
<a name="L768"></a><tt class="py-lineno">768</tt> <tt class="py-line"> <tt class="py-comment"># Get rid of the extra end tag:</tt> </tt>
<a name="L769"></a><tt class="py-lineno">769</tt> <tt class="py-line"> <tt id="link-284" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-284', 'html', 'link-3');">html</a></tt> <tt class="py-op">=</tt> <tt id="link-285" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
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 class="py-op">:</tt><tt id="link-286" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
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-name">rfind</tt><tt class="py-op">(</tt><tt class="py-string">'<'</tt><tt class="py-op">)</tt><tt class="py-op">]</tt> </tt>
<a name="L770"></a><tt class="py-lineno">770</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt id="link-287" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
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 id="link-288" class="py-name"><a title="lxml.doctestcompare.strip" class="py-name" href="#" onclick="return doclink('link-288', 'strip', 'link-19');">strip</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L771"></a><tt class="py-lineno">771</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L772"></a><tt class="py-lineno">772</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt id="link-289" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-289', 'html', 'link-3');">html</a></tt> </tt>
</div><a name="L773"></a><tt class="py-lineno">773</tt> <tt class="py-line"> </tt>
<a name="_fixup_ins_del_tags"></a><div id="_fixup_ins_del_tags-def"><a name="L774"></a><tt class="py-lineno">774</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>
</div><div id="_fixup_ins_del_tags-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="_fixup_ins_del_tags-expanded"><a name="L775"></a><tt class="py-lineno">775</tt> <tt class="py-line"> <tt class="py-docstring">"""fixup_ins_del_tags that works on an lxml document in-place</tt> </tt>
<a name="L776"></a><tt class="py-lineno">776</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
<a name="L777"></a><tt class="py-lineno">777</tt> <tt class="py-line"> <tt class="py-keyword">for</tt> <tt id="link-290" class="py-name"><a title="lxml.etree._Comment.tag
lxml.etree._Element.tag
lxml.etree._Entity.tag
lxml.etree._ProcessingInstruction.tag
lxml.tests.test_xpathevaluator.tag
xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-290', 'tag', 'link-103');">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>
<a name="L778"></a><tt class="py-lineno">778</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-291" class="py-name" targets="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.etree._Element.xpath
lxml.etree._ElementTree.xpath
lxml.tests.test_xpathevaluator.xpath" class="py-name" href="#" onclick="return doclink('link-291', 'xpath', 'link-291');">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-292" class="py-name"><a title="lxml.etree._Comment.tag
lxml.etree._Element.tag
lxml.etree._Entity.tag
lxml.etree._ProcessingInstruction.tag
lxml.tests.test_xpathevaluator.tag
xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-292', 'tag', 'link-103');">tag</a></tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L779"></a><tt class="py-lineno">779</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt id="link-293" class="py-name" targets="Function lxml.html.diff._contains_block_level_tag()=lxml.html.diff-module.html#_contains_block_level_tag"><a title="lxml.html.diff._contains_block_level_tag" class="py-name" href="#" onclick="return doclink('link-293', '_contains_block_level_tag', 'link-293');">_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>
<a name="L780"></a><tt class="py-lineno">780</tt> <tt class="py-line"> <tt class="py-keyword">continue</tt> </tt>
<a name="L781"></a><tt class="py-lineno">781</tt> <tt class="py-line"> <tt id="link-294" 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-294', '_move_el_inside_block', 'link-294');">_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-295" class="py-name"><a title="lxml.etree._Comment.tag
lxml.etree._Element.tag
lxml.etree._Entity.tag
lxml.etree._ProcessingInstruction.tag
lxml.tests.test_xpathevaluator.tag
xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-295', 'tag', 'link-103');">tag</a></tt><tt class="py-op">=</tt><tt id="link-296" class="py-name"><a title="lxml.etree._Comment.tag
lxml.etree._Element.tag
lxml.etree._Entity.tag
lxml.etree._ProcessingInstruction.tag
lxml.tests.test_xpathevaluator.tag
xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-296', 'tag', 'link-103');">tag</a></tt><tt class="py-op">)</tt> </tt>
<a name="L782"></a><tt class="py-lineno">782</tt> <tt class="py-line"> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-297" 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-297', 'drop_tag', 'link-297');">drop_tag</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
</div><a name="L783"></a><tt class="py-lineno">783</tt> <tt class="py-line"> <tt class="py-comment">#_merge_element_contents(el)</tt> </tt>
<a name="L784"></a><tt class="py-lineno">784</tt> <tt class="py-line"> </tt>
<a name="_contains_block_level_tag"></a><div id="_contains_block_level_tag-def"><a name="L785"></a><tt class="py-lineno">785</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>
</div><div id="_contains_block_level_tag-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="_contains_block_level_tag-expanded"><a name="L786"></a><tt class="py-lineno">786</tt> <tt class="py-line"> <tt class="py-docstring">"""True if the element contains any block-level elements, like <p>, <td>, etc.</tt> </tt>
<a name="L787"></a><tt class="py-lineno">787</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
<a name="L788"></a><tt class="py-lineno">788</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-298" class="py-name"><a title="lxml.etree._Comment.tag
lxml.etree._Element.tag
lxml.etree._Entity.tag
lxml.etree._ProcessingInstruction.tag
lxml.tests.test_xpathevaluator.tag
xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-298', 'tag', 'link-103');">tag</a></tt> <tt class="py-keyword">in</tt> <tt id="link-299" class="py-name"><a title="lxml.html.diff.block_level_tags" class="py-name" href="#" onclick="return doclink('link-299', 'block_level_tags', 'link-229');">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-300" class="py-name"><a title="lxml.etree._Comment.tag
lxml.etree._Element.tag
lxml.etree._Entity.tag
lxml.etree._ProcessingInstruction.tag
lxml.tests.test_xpathevaluator.tag
xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-300', 'tag', 'link-103');">tag</a></tt> <tt class="py-keyword">in</tt> <tt id="link-301" class="py-name"><a title="lxml.html.diff.block_level_container_tags" class="py-name" href="#" onclick="return doclink('link-301', 'block_level_container_tags', 'link-230');">block_level_container_tags</a></tt><tt class="py-op">:</tt> </tt>
<a name="L789"></a><tt class="py-lineno">789</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">True</tt> </tt>
<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>
<a name="L791"></a><tt class="py-lineno">791</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt id="link-302" class="py-name"><a title="lxml.html.diff._contains_block_level_tag" class="py-name" href="#" onclick="return doclink('link-302', '_contains_block_level_tag', 'link-293');">_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>
<a name="L792"></a><tt class="py-lineno">792</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">True</tt> </tt>
<a name="L793"></a><tt class="py-lineno">793</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt class="py-name">False</tt> </tt>
</div><a name="L794"></a><tt class="py-lineno">794</tt> <tt class="py-line"> </tt>
<a name="_move_el_inside_block"></a><div id="_move_el_inside_block-def"><a name="L795"></a><tt class="py-lineno">795</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>
</div><div id="_move_el_inside_block-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="_move_el_inside_block-expanded"><a name="L796"></a><tt class="py-lineno">796</tt> <tt class="py-line"> <tt class="py-docstring">""" helper for _fixup_ins_del_tags; actually takes the <ins> etc tags</tt> </tt>
<a name="L797"></a><tt class="py-lineno">797</tt> <tt class="py-line"><tt class="py-docstring"> and moves them inside any block-level tags. """</tt> </tt>
<a name="L798"></a><tt class="py-lineno">798</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>
<a name="L799"></a><tt class="py-lineno">799</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt id="link-303" class="py-name"><a title="lxml.html.diff._contains_block_level_tag" class="py-name" href="#" onclick="return doclink('link-303', '_contains_block_level_tag', 'link-293');">_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>
<a name="L800"></a><tt class="py-lineno">800</tt> <tt class="py-line"> <tt class="py-keyword">break</tt> </tt>
<a name="L801"></a><tt class="py-lineno">801</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L802"></a><tt class="py-lineno">802</tt> <tt class="py-line"> <tt class="py-keyword">import</tt> <tt class="py-name">sys</tt> </tt>
<a name="L803"></a><tt class="py-lineno">803</tt> <tt class="py-line"> <tt class="py-comment"># No block-level tags in any child</tt> </tt>
<a name="L804"></a><tt class="py-lineno">804</tt> <tt class="py-line"> <tt class="py-name">children_tag</tt> <tt class="py-op">=</tt> <tt id="link-304" class="py-name"><a title="lxml.etree
lxml.sax.ElementTreeContentHandler.etree
lxml.tests.test_elementtree.CElementTreeTestCase.etree
lxml.tests.test_elementtree._ETreeTestCaseBase.etree
lxml.tests.test_elementtree._XMLPullParserTest.etree
lxml.tests.test_io._IOTestCaseBase.etree" class="py-name" href="#" onclick="return doclink('link-304', 'etree', 'link-1');">etree</a></tt><tt class="py-op">.</tt><tt id="link-305" class="py-name" targets="Function lxml.etree.Element()=lxml.etree-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.etree.Element
lxml.objectify.Element
lxml.tests.test_pyclasslookup.PyClassLookupTestCase.Element
xml.etree.ElementTree.Element" class="py-name" href="#" onclick="return doclink('link-305', 'Element', 'link-305');">Element</a></tt><tt class="py-op">(</tt><tt id="link-306" class="py-name"><a title="lxml.etree._Comment.tag
lxml.etree._Element.tag
lxml.etree._Entity.tag
lxml.etree._ProcessingInstruction.tag
lxml.tests.test_xpathevaluator.tag
xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-306', 'tag', 'link-103');">tag</a></tt><tt class="py-op">)</tt> </tt>
<a name="L805"></a><tt class="py-lineno">805</tt> <tt class="py-line"> <tt class="py-name">children_tag</tt><tt class="py-op">.</tt><tt id="link-307" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-307', 'text', 'link-11');">text</a></tt> <tt class="py-op">=</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-308" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-308', 'text', 'link-11');">text</a></tt> </tt>
<a name="L806"></a><tt class="py-lineno">806</tt> <tt class="py-line"> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-309" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-309', 'text', 'link-11');">text</a></tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt> </tt>
<a name="L807"></a><tt class="py-lineno">807</tt> <tt class="py-line"> <tt class="py-name">children_tag</tt><tt class="py-op">.</tt><tt id="link-310" class="py-name"><a title="lxml.etree._Element.extend" class="py-name" href="#" onclick="return doclink('link-310', 'extend', 'link-54');">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>
<a name="L808"></a><tt class="py-lineno">808</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>
<a name="L809"></a><tt class="py-lineno">809</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> </tt>
<a name="L810"></a><tt class="py-lineno">810</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>
<a name="L811"></a><tt class="py-lineno">811</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt id="link-311" class="py-name"><a title="lxml.html.diff._contains_block_level_tag" class="py-name" href="#" onclick="return doclink('link-311', '_contains_block_level_tag', 'link-293');">_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>
<a name="L812"></a><tt class="py-lineno">812</tt> <tt class="py-line"> <tt id="link-312" class="py-name"><a title="lxml.html.diff._move_el_inside_block" class="py-name" href="#" onclick="return doclink('link-312', '_move_el_inside_block', 'link-294');">_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-313" class="py-name"><a title="lxml.etree._Comment.tag
lxml.etree._Element.tag
lxml.etree._Entity.tag
lxml.etree._ProcessingInstruction.tag
lxml.tests.test_xpathevaluator.tag
xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-313', 'tag', 'link-103');">tag</a></tt><tt class="py-op">)</tt> </tt>
<a name="L813"></a><tt class="py-lineno">813</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-314" class="py-name"><a title="lxml.etree._Element.tail
xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-314', 'tail', 'link-238');">tail</a></tt><tt class="py-op">:</tt> </tt>
<a name="L814"></a><tt class="py-lineno">814</tt> <tt class="py-line"> <tt class="py-name">tail_tag</tt> <tt class="py-op">=</tt> <tt id="link-315" class="py-name"><a title="lxml.etree
lxml.sax.ElementTreeContentHandler.etree
lxml.tests.test_elementtree.CElementTreeTestCase.etree
lxml.tests.test_elementtree._ETreeTestCaseBase.etree
lxml.tests.test_elementtree._XMLPullParserTest.etree
lxml.tests.test_io._IOTestCaseBase.etree" class="py-name" href="#" onclick="return doclink('link-315', 'etree', 'link-1');">etree</a></tt><tt class="py-op">.</tt><tt id="link-316" class="py-name"><a title="lxml.etree.Element
lxml.objectify.Element
lxml.tests.test_pyclasslookup.PyClassLookupTestCase.Element
xml.etree.ElementTree.Element" class="py-name" href="#" onclick="return doclink('link-316', 'Element', 'link-305');">Element</a></tt><tt class="py-op">(</tt><tt id="link-317" class="py-name"><a title="lxml.etree._Comment.tag
lxml.etree._Element.tag
lxml.etree._Entity.tag
lxml.etree._ProcessingInstruction.tag
lxml.tests.test_xpathevaluator.tag
xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-317', 'tag', 'link-103');">tag</a></tt><tt class="py-op">)</tt> </tt>
<a name="L815"></a><tt class="py-lineno">815</tt> <tt class="py-line"> <tt class="py-name">tail_tag</tt><tt class="py-op">.</tt><tt id="link-318" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-318', 'text', 'link-11');">text</a></tt> <tt class="py-op">=</tt> <tt class="py-name">child</tt><tt class="py-op">.</tt><tt id="link-319" class="py-name"><a title="lxml.etree._Element.tail
xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-319', 'tail', 'link-238');">tail</a></tt> </tt>
<a name="L816"></a><tt class="py-lineno">816</tt> <tt class="py-line"> <tt class="py-name">child</tt><tt class="py-op">.</tt><tt id="link-320" class="py-name"><a title="lxml.etree._Element.tail
xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-320', 'tail', 'link-238');">tail</a></tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt> </tt>
<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-321" class="py-name"><a title="lxml.etree._Element.insert" class="py-name" href="#" onclick="return doclink('link-321', 'insert', 'link-156');">insert</a></tt><tt class="py-op">(</tt><tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-322" class="py-name"><a title="lxml.etree._Element.index" class="py-name" href="#" onclick="return doclink('link-322', 'index', 'link-123');">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>
<a name="L818"></a><tt class="py-lineno">818</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L819"></a><tt class="py-lineno">819</tt> <tt class="py-line"> <tt class="py-name">child_tag</tt> <tt class="py-op">=</tt> <tt id="link-323" class="py-name"><a title="lxml.etree
lxml.sax.ElementTreeContentHandler.etree
lxml.tests.test_elementtree.CElementTreeTestCase.etree
lxml.tests.test_elementtree._ETreeTestCaseBase.etree
lxml.tests.test_elementtree._XMLPullParserTest.etree
lxml.tests.test_io._IOTestCaseBase.etree" class="py-name" href="#" onclick="return doclink('link-323', 'etree', 'link-1');">etree</a></tt><tt class="py-op">.</tt><tt id="link-324" class="py-name"><a title="lxml.etree.Element
lxml.objectify.Element
lxml.tests.test_pyclasslookup.PyClassLookupTestCase.Element
xml.etree.ElementTree.Element" class="py-name" href="#" onclick="return doclink('link-324', 'Element', 'link-305');">Element</a></tt><tt class="py-op">(</tt><tt id="link-325" class="py-name"><a title="lxml.etree._Comment.tag
lxml.etree._Element.tag
lxml.etree._Entity.tag
lxml.etree._ProcessingInstruction.tag
lxml.tests.test_xpathevaluator.tag
xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-325', 'tag', 'link-103');">tag</a></tt><tt class="py-op">)</tt> </tt>
<a name="L820"></a><tt class="py-lineno">820</tt> <tt class="py-line"> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-326" class="py-name" targets="Method lxml.etree._Element.replace()=lxml.etree._Element-class.html#replace"><a title="lxml.etree._Element.replace" class="py-name" href="#" onclick="return doclink('link-326', 'replace', 'link-326');">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>
<a name="L821"></a><tt class="py-lineno">821</tt> <tt class="py-line"> <tt class="py-name">child_tag</tt><tt class="py-op">.</tt><tt id="link-327" class="py-name"><a title="lxml.etree._Element.append" class="py-name" href="#" onclick="return doclink('link-327', 'append', 'link-24');">append</a></tt><tt class="py-op">(</tt><tt class="py-name">child</tt><tt class="py-op">)</tt> </tt>
<a name="L822"></a><tt class="py-lineno">822</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-328" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-328', 'text', 'link-11');">text</a></tt><tt class="py-op">:</tt> </tt>
<a name="L823"></a><tt class="py-lineno">823</tt> <tt class="py-line"> <tt class="py-name">text_tag</tt> <tt class="py-op">=</tt> <tt id="link-329" class="py-name"><a title="lxml.etree
lxml.sax.ElementTreeContentHandler.etree
lxml.tests.test_elementtree.CElementTreeTestCase.etree
lxml.tests.test_elementtree._ETreeTestCaseBase.etree
lxml.tests.test_elementtree._XMLPullParserTest.etree
lxml.tests.test_io._IOTestCaseBase.etree" class="py-name" href="#" onclick="return doclink('link-329', 'etree', 'link-1');">etree</a></tt><tt class="py-op">.</tt><tt id="link-330" class="py-name"><a title="lxml.etree.Element
lxml.objectify.Element
lxml.tests.test_pyclasslookup.PyClassLookupTestCase.Element
xml.etree.ElementTree.Element" class="py-name" href="#" onclick="return doclink('link-330', 'Element', 'link-305');">Element</a></tt><tt class="py-op">(</tt><tt id="link-331" class="py-name"><a title="lxml.etree._Comment.tag
lxml.etree._Element.tag
lxml.etree._Entity.tag
lxml.etree._ProcessingInstruction.tag
lxml.tests.test_xpathevaluator.tag
xml.etree.ElementTree.Element.tag" class="py-name" href="#" onclick="return doclink('link-331', 'tag', 'link-103');">tag</a></tt><tt class="py-op">)</tt> </tt>
<a name="L824"></a><tt class="py-lineno">824</tt> <tt class="py-line"> <tt class="py-name">text_tag</tt><tt class="py-op">.</tt><tt id="link-332" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-332', 'text', 'link-11');">text</a></tt> <tt class="py-op">=</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-333" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-333', 'text', 'link-11');">text</a></tt> </tt>
<a name="L825"></a><tt class="py-lineno">825</tt> <tt class="py-line"> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-334" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-334', 'text', 'link-11');">text</a></tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt> </tt>
<a name="L826"></a><tt class="py-lineno">826</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._Element.insert" class="py-name" href="#" onclick="return doclink('link-335', 'insert', 'link-156');">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>
</div><a name="L827"></a><tt class="py-lineno">827</tt> <tt class="py-line"> </tt>
<a name="_merge_element_contents"></a><div id="_merge_element_contents-def"><a name="L828"></a><tt class="py-lineno">828</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>
</div><div id="_merge_element_contents-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="_merge_element_contents-expanded"><a name="L829"></a><tt class="py-lineno">829</tt> <tt class="py-line"> <tt class="py-docstring">"""</tt> </tt>
<a name="L830"></a><tt class="py-lineno">830</tt> <tt class="py-line"><tt class="py-docstring"> Removes an element, but merges its contents into its place, e.g.,</tt> </tt>
<a name="L831"></a><tt class="py-lineno">831</tt> <tt class="py-line"><tt class="py-docstring"> given <p>Hi <i>there!</i></p>, if you remove the <i> element you get</tt> </tt>
<a name="L832"></a><tt class="py-lineno">832</tt> <tt class="py-line"><tt class="py-docstring"> <p>Hi there!</p></tt> </tt>
<a name="L833"></a><tt class="py-lineno">833</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
<a name="L834"></a><tt class="py-lineno">834</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-336" 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"><a title="lxml.etree._Element.getparent
lxml.etree._ElementStringResult.getparent
lxml.etree._ElementUnicodeResult.getparent" class="py-name" href="#" onclick="return doclink('link-336', 'getparent', 'link-336');">getparent</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L835"></a><tt class="py-lineno">835</tt> <tt class="py-line"> <tt id="link-337" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-337', 'text', 'link-11');">text</a></tt> <tt class="py-op">=</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-338" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-338', 'text', 'link-11');">text</a></tt> <tt class="py-keyword">or</tt> <tt class="py-string">''</tt> </tt>
<a name="L836"></a><tt class="py-lineno">836</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-339" class="py-name"><a title="lxml.etree._Element.tail
xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-339', 'tail', 'link-238');">tail</a></tt><tt class="py-op">:</tt> </tt>
<a name="L837"></a><tt class="py-lineno">837</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>
<a name="L838"></a><tt class="py-lineno">838</tt> <tt class="py-line"> <tt id="link-340" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-340', 'text', 'link-11');">text</a></tt> <tt class="py-op">+=</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-341" class="py-name"><a title="lxml.etree._Element.tail
xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-341', 'tail', 'link-238');">tail</a></tt> </tt>
<a name="L839"></a><tt class="py-lineno">839</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L840"></a><tt class="py-lineno">840</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-342" class="py-name"><a title="lxml.etree._Element.tail
xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-342', 'tail', 'link-238');">tail</a></tt><tt class="py-op">:</tt> </tt>
<a name="L841"></a><tt class="py-lineno">841</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-343" class="py-name"><a title="lxml.etree._Element.tail
xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-343', 'tail', 'link-238');">tail</a></tt> <tt class="py-op">+=</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-344" class="py-name"><a title="lxml.etree._Element.tail
xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-344', 'tail', 'link-238');">tail</a></tt> </tt>
<a name="L842"></a><tt class="py-lineno">842</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L843"></a><tt class="py-lineno">843</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-345" class="py-name"><a title="lxml.etree._Element.tail
xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-345', 'tail', 'link-238');">tail</a></tt> <tt class="py-op">=</tt> <tt class="py-name">el</tt><tt class="py-op">.</tt><tt id="link-346" class="py-name"><a title="lxml.etree._Element.tail
xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-346', 'tail', 'link-238');">tail</a></tt> </tt>
<a name="L844"></a><tt class="py-lineno">844</tt> <tt class="py-line"> <tt id="link-347" class="py-name"><a title="lxml.etree._Element.index" class="py-name" href="#" onclick="return doclink('link-347', 'index', 'link-123');">index</a></tt> <tt class="py-op">=</tt> <tt class="py-name">parent</tt><tt class="py-op">.</tt><tt id="link-348" class="py-name"><a title="lxml.etree._Element.index" class="py-name" href="#" onclick="return doclink('link-348', 'index', 'link-123');">index</a></tt><tt class="py-op">(</tt><tt class="py-name">el</tt><tt class="py-op">)</tt> </tt>
<a name="L845"></a><tt class="py-lineno">845</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt id="link-349" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-349', 'text', 'link-11');">text</a></tt><tt class="py-op">:</tt> </tt>
<a name="L846"></a><tt class="py-lineno">846</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt id="link-350" class="py-name"><a title="lxml.etree._Element.index" class="py-name" href="#" onclick="return doclink('link-350', 'index', 'link-123');">index</a></tt> <tt class="py-op">==</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L847"></a><tt class="py-lineno">847</tt> <tt class="py-line"> <tt class="py-name">previous</tt> <tt class="py-op">=</tt> <tt class="py-name">None</tt> </tt>
<a name="L848"></a><tt class="py-lineno">848</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<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 class="py-name">parent</tt><tt class="py-op">[</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-123');">index</a></tt><tt class="py-op">-</tt><tt class="py-number">1</tt><tt class="py-op">]</tt> </tt>
<a name="L850"></a><tt class="py-lineno">850</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>
<a name="L851"></a><tt class="py-lineno">851</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-352" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-352', 'text', 'link-11');">text</a></tt><tt class="py-op">:</tt> </tt>
<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-353" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-353', 'text', 'link-11');">text</a></tt> <tt class="py-op">+=</tt> <tt id="link-354" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-354', 'text', 'link-11');">text</a></tt> </tt>
<a name="L853"></a><tt class="py-lineno">853</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L854"></a><tt class="py-lineno">854</tt> <tt class="py-line"> <tt class="py-name">parent</tt><tt class="py-op">.</tt><tt id="link-355" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-355', 'text', 'link-11');">text</a></tt> <tt class="py-op">=</tt> <tt id="link-356" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-356', 'text', 'link-11');">text</a></tt> </tt>
<a name="L855"></a><tt class="py-lineno">855</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L856"></a><tt class="py-lineno">856</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-357" class="py-name"><a title="lxml.etree._Element.tail
xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-357', 'tail', 'link-238');">tail</a></tt><tt class="py-op">:</tt> </tt>
<a name="L857"></a><tt class="py-lineno">857</tt> <tt class="py-line"> <tt class="py-name">previous</tt><tt class="py-op">.</tt><tt id="link-358" class="py-name"><a title="lxml.etree._Element.tail
xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-358', 'tail', 'link-238');">tail</a></tt> <tt class="py-op">+=</tt> <tt id="link-359" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-359', 'text', 'link-11');">text</a></tt> </tt>
<a name="L858"></a><tt class="py-lineno">858</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L859"></a><tt class="py-lineno">859</tt> <tt class="py-line"> <tt class="py-name">previous</tt><tt class="py-op">.</tt><tt id="link-360" class="py-name"><a title="lxml.etree._Element.tail
xml.etree.ElementTree.Element.tail" class="py-name" href="#" onclick="return doclink('link-360', 'tail', 'link-238');">tail</a></tt> <tt class="py-op">=</tt> <tt id="link-361" class="py-name"><a title="lxml.etree.QName.text
lxml.etree._Element.text
lxml.etree._Entity.text
lxml.objectify.ObjectifiedElement.text
xml.etree.ElementTree.Element.text" class="py-name" href="#" onclick="return doclink('link-361', 'text', 'link-11');">text</a></tt> </tt>
<a name="L860"></a><tt class="py-lineno">860</tt> <tt class="py-line"> <tt class="py-name">parent</tt><tt class="py-op">[</tt><tt id="link-362" class="py-name"><a title="lxml.etree._Element.index" class="py-name" href="#" onclick="return doclink('link-362', 'index', 'link-123');">index</a></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-123');">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-364" class="py-name" targets="Method lxml.etree._Element.getchildren()=lxml.etree._Element-class.html#getchildren,Method lxml.objectify.ObjectifiedElement.getchildren()=lxml.objectify.ObjectifiedElement-class.html#getchildren"><a title="lxml.etree._Element.getchildren
lxml.objectify.ObjectifiedElement.getchildren" class="py-name" href="#" onclick="return doclink('link-364', 'getchildren', 'link-364');">getchildren</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
</div><a name="L861"></a><tt class="py-lineno">861</tt> <tt class="py-line"> </tt>
<a name="InsensitiveSequenceMatcher"></a><div id="InsensitiveSequenceMatcher-def"><a name="L862"></a><tt class="py-lineno">862</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>
</div><div id="InsensitiveSequenceMatcher-collapsed" style="display:none;" pad="+++" indent="++++"></div><div id="InsensitiveSequenceMatcher-expanded"><a name="L863"></a><tt class="py-lineno">863</tt> <tt class="py-line"> <tt class="py-docstring">"""</tt> </tt>
<a name="L864"></a><tt class="py-lineno">864</tt> <tt class="py-line"><tt class="py-docstring"> Acts like SequenceMatcher, but tries not to find very small equal</tt> </tt>
<a name="L865"></a><tt class="py-lineno">865</tt> <tt class="py-line"><tt class="py-docstring"> blocks amidst large spans of changes</tt> </tt>
<a name="L866"></a><tt class="py-lineno">866</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
<a name="L867"></a><tt class="py-lineno">867</tt> <tt class="py-line"> </tt>
<a name="L868"></a><tt class="py-lineno">868</tt> <tt class="py-line"> <tt id="link-365" 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-365', 'threshold', 'link-365');">threshold</a></tt> <tt class="py-op">=</tt> <tt class="py-number">2</tt> </tt>
<a name="L869"></a><tt class="py-lineno">869</tt> <tt class="py-line"> </tt>
<a name="InsensitiveSequenceMatcher.get_matching_blocks"></a><div id="InsensitiveSequenceMatcher.get_matching_blocks-def"><a name="L870"></a><tt class="py-lineno">870</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>
</div><div id="InsensitiveSequenceMatcher.get_matching_blocks-collapsed" style="display:none;" pad="+++" indent="++++++++"></div><div id="InsensitiveSequenceMatcher.get_matching_blocks-expanded"><a name="L871"></a><tt class="py-lineno">871</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>
<a name="L872"></a><tt class="py-lineno">872</tt> <tt class="py-line"> <tt id="link-366" class="py-name"><a title="lxml.html.diff.InsensitiveSequenceMatcher.threshold" class="py-name" href="#" onclick="return doclink('link-366', 'threshold', 'link-365');">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-367" class="py-name"><a title="lxml.html.diff.InsensitiveSequenceMatcher.threshold" class="py-name" href="#" onclick="return doclink('link-367', 'threshold', 'link-365');">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>
<a name="L873"></a><tt class="py-lineno">873</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-368" 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-368', 'get_matching_blocks', 'link-368');">get_matching_blocks</a></tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">)</tt> </tt>
<a name="L874"></a><tt class="py-lineno">874</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>
<a name="L875"></a><tt class="py-lineno">875</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">></tt> <tt id="link-369" class="py-name"><a title="lxml.html.diff.InsensitiveSequenceMatcher.threshold" class="py-name" href="#" onclick="return doclink('link-369', 'threshold', 'link-365');">threshold</a></tt> </tt>
<a name="L876"></a><tt class="py-lineno">876</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>
</div></div><a name="L877"></a><tt class="py-lineno">877</tt> <tt class="py-line"> </tt>
<a name="L878"></a><tt class="py-lineno">878</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>
<a name="L879"></a><tt class="py-lineno">879</tt> <tt class="py-line"> <tt class="py-keyword">from</tt> <tt id="link-370" class="py-name"><a title="lxml" class="py-name" href="#" onclick="return doclink('link-370', 'lxml', 'link-0');">lxml</a></tt><tt class="py-op">.</tt><tt id="link-371" class="py-name"><a title="lxml.html
lxml.html.diff.href_token.html
lxml.html.diff.tag_token.html
lxml.html.diff.token.html" class="py-name" href="#" onclick="return doclink('link-371', 'html', 'link-3');">html</a></tt> <tt class="py-keyword">import</tt> <tt class="py-name">_diffcommand</tt> </tt>
<a name="L880"></a><tt class="py-lineno">880</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>
<a name="L881"></a><tt class="py-lineno">881</tt> <tt class="py-line"> </tt><script type="text/javascript">
<!--
expandto(location.href);
// -->
</script>
</pre>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
bgcolor="#a0c0ff" cellspacing="0">
<tr valign="middle">
<!-- Home link -->
<th> <a
href="lxml-module.html">Home</a> </th>
<!-- Tree link -->
<th> <a
href="module-tree.html">Trees</a> </th>
<!-- Index link -->
<th> <a
href="identifier-index.html">Indices</a> </th>
<!-- Help link -->
<th> <a
href="help.html">Help</a> </th>
<!-- Project homepage -->
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center"
><a class="navbar" target="_top" href="/">lxml API</a></th>
</tr></table></th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
<tr>
<td align="left" class="footer">
Generated by Epydoc 3.0.1
on Fri Dec 23 19:00:53 2016
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
>http://epydoc.sourceforge.net</a>
</td>
</tr>
</table>
<script type="text/javascript">
<!--
// Private objects are initially displayed (because if
// javascript is turned off then we want them to be
// visible); but by default, we want to hide them. So hide
// them unless we have a cookie that says to show them.
checkCookie();
// -->
</script>
</body>
</html>
|