Skip to content

Commit c9d5476

Browse files
committed
first bits of inTableBody
--HG-- extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%40116
1 parent e7929ca commit c9d5476

1 file changed

Lines changed: 66 additions & 2 deletions

File tree

parser.py

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,8 +1231,72 @@ def endTagOther(self, name):
12311231

12321232
class InTableBody(InsertionMode):
12331233
# http://www.whatwg.org/specs/web-apps/current-work/#in-table0
1234-
pass
1235-
#assert False
1234+
1235+
# helper methods
1236+
def clearStackToTableBodyContext(self):
1237+
while self.parser.openElements[:-1].name in ("tbody", "tfoot", "thead",
1238+
"html"):
1239+
self.parser.openElements.pop()
1240+
self.parser.parseError()
1241+
1242+
# the rest
1243+
# XXX character tokens and all that ...
1244+
1245+
def processStartTag(self, name, attributes):
1246+
handlers = utils.MethodDispatcher([
1247+
("tr", self.startTagTr),
1248+
(("td", "th"), self.startTagTableCell),
1249+
(("caption", "col", "colgroup", "tbody", "tfoot", "thead"), self.startTagTableOther)
1250+
])
1251+
handlers.setDefaultValue(self.startTagOther)
1252+
handlers[name](name, attributes)
1253+
1254+
def startTagTr(self, name="tr", attributes={}):
1255+
self.clearStackToTableBodyContext()
1256+
self.parser.insertElement(name, attributes)
1257+
self.parser.switchInsertionMode("inRow")
1258+
1259+
def startTagTableCell(self, name, attributes):
1260+
self.parser.parseError()
1261+
self.startTagTr()
1262+
self.parser.processStartTag(name, attributes)
1263+
1264+
def startTagTableOther(self, name, attributes):
1265+
# XXX
1266+
# could share code with endTagTable ...
1267+
assert False
1268+
1269+
def startTagOther(self, name, attributes):
1270+
# XXX parse error?
1271+
self.parser.switchInsertionMode("inTable")
1272+
self.parser.processStartTag(name, attributes)
1273+
1274+
def processEndTag(self, name):
1275+
handlers = utils.MethodDispatcher([
1276+
(("tbody", "tfoot", "thead"), self.endTagTableRowGroup),
1277+
("table", self.endTagTable),
1278+
(("body", "caption", "col", "colgroup", "html", "td", "th",
1279+
"tr"), self.endTagIgnore)
1280+
])
1281+
handlers.setDefaultValue(self.endTagOther)
1282+
handlers[name](name)
1283+
1284+
def endTagTableRowGroup(self, name):
1285+
# XXX
1286+
assert False
1287+
1288+
def endTagTable(self, name):
1289+
# XXX
1290+
assert False
1291+
1292+
def endTagIgnore(self, name):
1293+
self.parser.parseError()
1294+
1295+
def endTagOther(self, name):
1296+
# XXX parser error? prolly not, already done inTable...
1297+
self.parser.switchInsertionMode("inTable")
1298+
self.parser.processEndTag(name)
1299+
12361300

12371301
class InRow(InsertionMode): pass
12381302

0 commit comments

Comments
 (0)