diff --git a/parser.py b/parser.py index ef266ec..bfd656d 100755 --- a/parser.py +++ b/parser.py @@ -43,6 +43,7 @@ class GoogleSheetsCalParser(HTMLParser): self.column = -1 self.nextCol = -1 self.rowspan = 0 + self.multirows = {} self.date = {} import priv @@ -64,6 +65,9 @@ class GoogleSheetsCalParser(HTMLParser): self.row += 1 self.nextCol = -1 elif tag == 'td': + while self.nextCol in self.multirows.keys() and self.multirows[self.nextCol][1] > 0: + self.nextCol += self.multirows[self.nextCol][0] + self.column = self.nextCol if 'colspan' in dAttrs.keys(): self.nextCol += int(dAttrs['colspan']) @@ -73,6 +77,8 @@ class GoogleSheetsCalParser(HTMLParser): self.inCell = True if 'rowspan' in dAttrs.keys(): self.rowspan = int(dAttrs['rowspan']) + self.multirows[self.column] = [self.nextCol - + self.column, self.rowspan] else: self.rowspan = 1 elif (self.row - 2) % 12 == 1: self.inDate = True @@ -83,6 +89,9 @@ class GoogleSheetsCalParser(HTMLParser): if tag == 'td': self.inCell = False self.inDate = False + elif tag == 'tr': + for mr in self.multirows.values(): + mr[1] -= 1 elif tag == 'tbody': self.inTable = False