2
2
# * Phases and insertion modes are one concept in parser.py.
3
3
# * EOF handling is slightly different to make sure <html>, <head> and <body>
4
4
# always exist.
5
- # * Active formatting elements not reconstructed on whitespace tokens
6
-
7
5
8
6
9
7
try :
@@ -756,11 +754,12 @@ def processSpaceCharactersDropNewline(self, data):
756
754
# Sometimes (start of <pre> and <textarea> blocks) we want to drop
757
755
# leading newlines
758
756
self .processSpaceCharacters = self .processSpaceCharactersNonPre
759
- if (data .startswith ("\n " ) and ( self . tree . openElements [ - 1 ]. name == "pre"
760
- or self .tree .openElements [- 1 ].name == " textarea" )
761
- and not self .tree .openElements [- 1 ].hasContent ()):
757
+ if (data .startswith ("\n " ) and
758
+ self .tree .openElements [- 1 ].name in ( "pre" , " textarea" ) and
759
+ not self .tree .openElements [- 1 ].hasContent ()):
762
760
data = data [1 :]
763
761
if data :
762
+ self .tree .reconstructActiveFormattingElements ()
764
763
self .tree .insertText (data )
765
764
766
765
def processCharacters (self , data ):
@@ -770,10 +769,10 @@ def processCharacters(self, data):
770
769
self .tree .reconstructActiveFormattingElements ()
771
770
self .tree .insertText (data )
772
771
773
- #Uncomment the following to match the current spec rather than the behaviour above
774
- # def processSpaceCharacters(self, data):
775
- # self.tree.reconstructActiveFormattingElements()
776
- # self.tree.insertText(data)
772
+ #This matches the current spec but may not match the real world
773
+ def processSpaceCharacters (self , data ):
774
+ self .tree .reconstructActiveFormattingElements ()
775
+ self .tree .insertText (data )
777
776
778
777
def startTagProcessInHead (self , name , attributes ):
779
778
self .parser .phases ["inHead" ].processStartTag (name , attributes )
0 commit comments