Fix rowspan, colspan on TDs.
The export script was dropping them prior to this CL.
Bug: 1267385
Change-Id: Ida17e0b9a5d6c2aa98a2ad3eeae9d79f2f74635c
Reviewed-on: https://chromium-review.googlesource.com/c/website/+/3265747
Auto-Submit: Dirk Pranke <dpranke@google.com>
Reviewed-by: Gary Tong <gatong@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@google.com>
diff --git a/scripts/html2markdown.py b/scripts/html2markdown.py
index 0ba8381..280223e 100644
--- a/scripts/html2markdown.py
+++ b/scripts/html2markdown.py
@@ -366,8 +366,14 @@
class TD(Text):
- def __init__(self):
- super().__init__(indent='', prefix='<td>', suffix='</td>')
+ def __init__(self, rowspan, colspan):
+ prefix = '<td'
+ if rowspan and str(rowspan) != '1':
+ prefix += ' rowspan=%s' % rowspan
+ if colspan and str(colspan) != '1':
+ prefix += ' colspan=%s' % colspan
+ prefix += '>'
+ super().__init__(indent='', prefix=prefix, suffix='</td>')
class Content(TextBlock):
@@ -1141,7 +1147,7 @@
if self._IsWithinFragmentType(Table):
self._AddHTMLBlock('</tr>')
- def StartTD(self, cls):
+ def StartTD(self, cls, rowspan, colspan):
if self._LastFragmentIs(Div, cls='two-column-container'):
if cls and ('sites-tile-name-content-1' in cls or
'sites-tile-name-content-2' in cls):
@@ -1150,7 +1156,7 @@
else:
self._Push(Text())
elif self._IsWithinFragmentType(Table):
- self._Push(TD())
+ self._Push(TD(rowspan, colspan))
def EndTD(self):
if self._LastFragmentIs(Div, cls='column'):
@@ -1276,7 +1282,9 @@
elif tag == 'tr':
self._generator.StartTR()
elif tag == 'td':
- self._generator.StartTD(attrs.get((None, 'class')))
+ self._generator.StartTD(attrs.get((None, 'class')),
+ attrs.get((None, 'rowspan')),
+ attrs.get((None, 'colspan')))
else:
match = self._HEADER_TAG_RE.match(tag)
if match: