diff --git a/commonmark_extensions/tables.py b/commonmark_extensions/tables.py
index d30ae89..567a901 100644
--- a/commonmark_extensions/tables.py
+++ b/commonmark_extensions/tables.py
@@ -171,7 +171,7 @@ def inner_parser(cell):
for part in table_parts:
for row in part:
for i, cell in enumerate(row):
- row[i] = inner_parser(cell)
+ row[i] = inner_parser(cell) if cell != "-" else None
# Store the parsed table on the node.
block.column_properties = column_properties
@@ -211,6 +211,9 @@ def table(self, node, entering):
for row in part:
self.lit("
\n")
for colidx, cell in enumerate(row):
+ if cell is None:
+ continue
+
if part_tag == "thead":
col_tag = "th"
if self.options.get("table_th_scope"):
@@ -224,6 +227,15 @@ def table(self, node, entering):
if colidx in node.column_properties and "align" in node.column_properties[colidx]:
col_attrs += ' align=\"' + node.column_properties[colidx]["align"] + "\""
+ span = 1
+ for nextid in range(colidx+1, len(row)):
+ if row[nextid] is None:
+ span += 1
+ else:
+ break
+ if span > 1:
+ col_attrs += ' colspan=\"' + str(span) + '\"'
+
self.lit("<" + col_tag + col_attrs + ">")
import copy