@@ -661,11 +661,13 @@ def addFormattingElement(self, name, attributes):
661
661
self .tree .openElements [- 1 ])
662
662
663
663
# the real deal
664
- def processSpaceCharactersPre (self , data ):
665
- #Sometimes (start of <pre> blocks) we want to drop leading newlines
664
+ def processSpaceCharactersDropNewline (self , data ):
665
+ # Sometimes (start of <pre> and <textarea> blocks) we want to drop
666
+ # leading newlines
666
667
self .processSpaceCharacters = self .processSpaceCharactersNonPre
667
- if (data .startswith ("\n " ) and self .tree .openElements [- 1 ].name == "pre"
668
- and not self .tree .openElements [- 1 ].hasContent ()):
668
+ if (data .startswith ("\n " ) and (self .tree .openElements [- 1 ].name == "pre"
669
+ or self .tree .openElements [- 1 ].name == "textarea" )
670
+ and not self .tree .openElements [- 1 ].hasContent ()):
669
671
data = data [1 :]
670
672
if data :
671
673
self .tree .insertText (data )
@@ -700,7 +702,7 @@ def startTagCloseP(self, name, attributes):
700
702
self .endTagP ("p" )
701
703
self .tree .insertElement (name , attributes )
702
704
if name == "pre" :
703
- self .processSpaceCharacters = self .processSpaceCharactersPre
705
+ self .processSpaceCharacters = self .processSpaceCharactersDropNewline
704
706
705
707
def startTagForm (self , name , attributes ):
706
708
if self .tree .formPointer :
@@ -842,6 +844,7 @@ def startTagTextarea(self, name, attributes):
842
844
# XXX Form element pointer checking here as well...
843
845
self .tree .insertElement (name , attributes )
844
846
self .parser .tokenizer .contentModelFlag = contentModelFlags ["RCDATA" ]
847
+ self .processSpaceCharacters = self .processSpaceCharactersDropNewline
845
848
846
849
def startTagCdata (self , name , attributes ):
847
850
"""iframe, noembed noframes, noscript(if scripting enabled)"""
0 commit comments