@@ -889,7 +889,54 @@ def startTagIsIndex(self, name, attributes):
889889 self .parser .processStartTag ("hr" )
890890 self .parser .processEndTag ("form" )
891891
892- class InTable (InsertionMode ): pass
892+ class InTable (InsertionMode ):
893+ # http://www.whatwg.org/specs/web-apps/current-work/#in-table
894+
895+ # helper methods
896+ def clearStackToTableContext (self ):
897+ # "clear the stack back to a table context"
898+ while self .parser .openElements [- 1 ].name not in ("table" , "html" ):
899+ self .parser .openElements .pop ()
900+ self .parser .parseError ()
901+
902+ # When the current node is <html> it's an innerHTML case
903+
904+
905+ # processing methods
906+ def processCharacter (self , data ):
907+ # XXX
908+ pass
909+
910+ def processComment (self , data ):
911+ # XXX AT Perhaps this should be done in InsertionMode and then we can
912+ # overwrite it when you don't need to do this...
913+ self .parser .openElements [- 1 ].appendChild (CommentNode (data ))
914+
915+ def processStartTag (self , name , attributes ):
916+ handlers = utils .MethodDispatcher ([
917+ ("caption" , self .startTagCaption ),
918+ ("colgroup" , self .startTagColgroup ),
919+ ("col" , self .startTagCol ),
920+ (("tbody" , "tfoot" , "thead" ), self .startTagRowGroup ),
921+ (("td" , "th" , "tr" ), self .startTagImplyTbody ),
922+ ("table" , self .startTagTable )
923+ ])
924+ # XXX Can we handle this through the anything else case??
925+ handlers .setDefaultValue (self .processAnythingElse )
926+ handlers [name ](name , attributes )
927+
928+ def startTagCaption (self , name , attributes ):
929+ self .clearStackToTableContext ()
930+ # XXX insert marker etc.
931+
932+ def startTagColgroup (self , name = "colgroup" , attributes = {}):
933+ self .clearStackToTableContext ()
934+ # XXX switch modes
935+
936+ def startTagCol (self , name , attributes ):
937+ self .startTagColgroup ()
938+ self .parser .processStartTag (name , attributes )
939+
893940class InCaption (InsertionMode ): pass
894941class InColumnGroup (InsertionMode ): pass
895942class InTableBody (InsertionMode ): pass
@@ -972,7 +1019,7 @@ def endTagTableElements(self, name):
9721019 self .parser .parseError ()
9731020 # XXX table elements in scope blah...
9741021
975- def processAnythingElse (self ):
1022+ def processAnythingElse (self , name , attributes = {} ):
9761023 self .parser .parseError ()
9771024
9781025class AfterBody (InsertionMode ):
@@ -985,7 +1032,7 @@ def processStartTag(self, name, attributes):
9851032 self .parser .processStartTag (name , attributes )
9861033
9871034 def processEndTag (self , name ):
988- handlers = utils .MethodDispatcher ([(' html' , self .endTagHtml )])
1035+ handlers = utils .MethodDispatcher ([(" html" , self .endTagHtml )])
9891036 handlers .setDefaultValue (self .endTagOther )
9901037 handlers [name ](name )
9911038
0 commit comments