correctly count columns when there is an attribute "colspan"
This commit is contained in:
parent
dfbd82d933
commit
321f6f8633
1 changed files with 7 additions and 2 deletions
|
|
@ -294,11 +294,16 @@ class TableElement(ListElement):
|
||||||
cols = [cols]
|
cols = [cols]
|
||||||
columns[m.group(1)] = [s.lower() for s in cols]
|
columns[m.group(1)] = [s.lower() for s in cols]
|
||||||
|
|
||||||
for colnum, el in enumerate(self.el.xpath(self.head_xpath)):
|
colnum = 0
|
||||||
|
for el in self.el.xpath(self.head_xpath):
|
||||||
title = self.cleaner.clean(el).lower()
|
title = self.cleaner.clean(el).lower()
|
||||||
for name, titles in columns.iteritems():
|
for name, titles in columns.iteritems():
|
||||||
if title in titles:
|
if title in titles and not name in self._cols:
|
||||||
self._cols[name] = colnum
|
self._cols[name] = colnum
|
||||||
|
try:
|
||||||
|
colnum += int(el.attrib.get('colspan', 1))
|
||||||
|
except ValueError:
|
||||||
|
colnum += 1
|
||||||
|
|
||||||
def get_colnum(self, name):
|
def get_colnum(self, name):
|
||||||
return self._cols.get(name, None)
|
return self._cols.get(name, None)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue