|
| 1 | + |
1 | 2 | # Differences from the current specification (23 December 2006) are as follows:
|
2 | 3 | # * Phases and insertion modes are one concept in parser.py.
|
3 | 4 | # * EOF handling is slightly different to make sure <html>, <head> and <body>
|
|
17 | 18 | # Import from the sets module for python 2.3
|
18 | 19 | from sets import Set as set
|
19 | 20 | from sets import ImmutableSet as frozenset
|
| 21 | +import new |
20 | 22 | import gettext
|
21 | 23 | _ = gettext.gettext
|
22 | 24 |
|
@@ -624,8 +626,10 @@ def addFormattingElement(self, name, attributes):
|
624 | 626 | # the real deal
|
625 | 627 | def processSpaceCharactersPre(self, data):
|
626 | 628 | #Sometimes (start of <pre> blocks) we want to drop leading newlines
|
627 |
| - self.processSpaceCharacters = Phase.processSpaceCharacters |
628 |
| - if data.startswith("\n"): |
| 629 | + self.processSpaceCharacters = new.instancemethod( |
| 630 | + Phase.processSpaceCharacters, self) |
| 631 | + if (data.startswith("\n") and not |
| 632 | + self.tree.openElements[-1].hasContent()): |
629 | 633 | data = data[1:]
|
630 | 634 | if data:
|
631 | 635 | self.tree.insertText(data)
|
@@ -859,6 +863,10 @@ def endTagHtml(self, name):
|
859 | 863 | self.parser.phase.processEndTag(name)
|
860 | 864 |
|
861 | 865 | def endTagBlock(self, name):
|
| 866 | + #Put us back in the right whitespace handling mode |
| 867 | + if name == "pre": |
| 868 | + self.processSpaceCharacters = new.instancemethod( |
| 869 | + Phase.processSpaceCharacters, self) |
862 | 870 | inScope = self.tree.elementInScope(name)
|
863 | 871 | if inScope:
|
864 | 872 | self.tree.generateImpliedEndTags()
|
|
0 commit comments