@@ -595,7 +595,11 @@ def startTagScript(self, name, attributes):
595
595
596
596
def startTagBaseLinkMeta (self , name , attributes ):
597
597
element = self .tree .createElement (name , attributes )
598
- self .appendToHead (element )
598
+ if (self .tree .headPointer is not None and
599
+ self .parser .phase == self .parser .phases ["inHead" ]):
600
+ self .appendToHead (element )
601
+ else :
602
+ self .tree .openElements [- 1 ].appendChild (element )
599
603
600
604
def startTagOther (self , name , attributes ):
601
605
self .anythingElse ()
@@ -692,9 +696,9 @@ def __init__(self, parser, tree):
692
696
693
697
self .startTagHandler = utils .MethodDispatcher ([
694
698
("html" , self .startTagHtml ),
695
- (("script " , "style" ), self . startTagScriptStyle ),
696
- (( "base" , "link" , "meta" , "title" ),
697
- self .startTagFromHead ),
699
+ (("base " , "link" , "meta" , "script" , "style" ),
700
+ self . startTagProcessInHead ),
701
+ ( "title" , self .startTagTitle ),
698
702
("body" , self .startTagBody ),
699
703
(("address" , "blockquote" , "center" , "dir" , "div" , "dl" ,
700
704
"fieldset" , "listing" , "menu" , "ol" , "p" , "pre" , "ul" ),
@@ -779,10 +783,10 @@ def processCharacters(self, data):
779
783
self .tree .reconstructActiveFormattingElements ()
780
784
self .tree .insertText (data )
781
785
782
- def startTagScriptStyle (self , name , attributes ):
786
+ def startTagProcessInHead (self , name , attributes ):
783
787
self .parser .phases ["inHead" ].processStartTag (name , attributes )
784
788
785
- def startTagFromHead (self , name , attributes ):
789
+ def startTagTitle (self , name , attributes ):
786
790
self .parser .parseError (_ (u"Unexpected start tag (" + name + \
787
791
") that belongs in the head. Moved." ))
788
792
self .parser .phases ["inHead" ].processStartTag (name , attributes )
0 commit comments