summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKorrawit Pruegsanusak <detective.conan.1412@gmail.com>2011-12-02 22:27:03 +0700
committerPetr Mladek <pmladek@suse.cz>2012-02-10 17:55:00 +0100
commit156670a5401b55f5b9a938c6d673f27137077e09 (patch)
tree4b334d6a02d3d646d59e5acc6e4ae793eb5365c4
parent939e7316dec9d919b4e93aefcf9e38680c015cec (diff)
fdo#42924 don't ignore empty TableCell Element, also check if it's a header
Checking whether an empty TableCell Element is a header row is now in 2 cases: * | e | h | h | h | h | ... => The empty cell should be a header This case occurs when this row is the first row in the table. * | h | p | p | e | p | ... => The empty cell should not be a header This case occurs when this row is not the first row in the table, but the first column is the row header. where | is a column seperator, e is an empty cell, h is a header cell (which has role="tablehead" attribute), and p is not a header cell. Note that parsing occurs left-to-right, so isTableHeader depends on the last TableCell Element in that row. I assume that if the last element is a header, that row should be a header row. Currently this code gives correct behaviour, but checking whether a row is the first row might be more correct. Signed-off-by: Petr Mladek <pmladek@suse.cz>
-rwxr-xr-xhelpcontent2/to-wiki/wikiconv2.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/helpcontent2/to-wiki/wikiconv2.py b/helpcontent2/to-wiki/wikiconv2.py
index 7d5cc3eda4..0ad50385e3 100755
--- a/helpcontent2/to-wiki/wikiconv2.py
+++ b/helpcontent2/to-wiki/wikiconv2.py
@@ -472,8 +472,10 @@ class Text:
class TableCell(ElementBase):
def __init__(self, attrs, parent):
ElementBase.__init__(self, 'tablecell', parent)
+ self.cellHasChildElement = False
def start_element(self, parser, name, attrs):
+ self.cellHasChildElement = True
if name == 'bookmark':
self.parse_child(Bookmark(attrs, self, 'div', parser))
elif name == 'comment':
@@ -489,6 +491,18 @@ class TableCell(ElementBase):
else:
self.unhandled_element(parser, name)
+ def get_all(self):
+ text = ''
+ if not self.cellHasChildElement: # an empty element
+ if self.parent.isTableHeader: # get from TableRow Element
+ role = 'tablehead'
+ else:
+ role = 'tablecontent'
+ text = text + replace_paragraph_role['start'][role]
+ text = text + replace_paragraph_role['end'][role]
+ text = text + ElementBase.get_all(self)
+ return text
+
class TableRow(ElementBase):
def __init__(self, attrs, parent):
ElementBase.__init__(self, 'tablerow', parent)
@@ -1086,6 +1100,10 @@ class TableContentParagraph(Paragraph):
self.role = 'tablecontentcode'
else:
self.role = 'tablecontent'
+ if self.role == 'tablehead':
+ self.parent.parent.isTableHeader = True # self.parent.parent is TableRow Element
+ else:
+ self.parent.parent.isTableHeader = False
class ParserBase:
def __init__(self, filename, follow_embed, embedding_app, current_app, wiki_page_name, lang, head_object, buffer):