diff --git a/markdownify/__init__.py b/markdownify/__init__.py index 47485f5..3d67a49 100644 --- a/markdownify/__init__.py +++ b/markdownify/__init__.py @@ -96,11 +96,14 @@ class MarkdownConverter(object): def process_tag(self, node, convert_as_inline, children_only=False): text = '' - # markdown headings can't include block elements (elements w/newlines) + + # markdown headings or cells can't include + # block elements (elements w/newlines) isHeading = html_heading_re.match(node.name) is not None + isCell = node.name in ['td', 'th'] convert_children_as_inline = convert_as_inline - if not children_only and isHeading: + if not children_only and (isHeading or isCell): convert_children_as_inline = True # Remove whitespace-only textnodes in purely nested nodes @@ -200,8 +203,6 @@ class MarkdownConverter(object): prefix, suffix, text = chomp(text) if not text: return '' - if convert_as_inline: - return text href = el.get('href') title = el.get('title') # For the replacement see #29: text nodes underscores are escaped diff --git a/setup.py b/setup.py index c310552..467c1fa 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ read = lambda filepath: codecs.open(filepath, 'r', 'utf-8').read() pkgmeta = { '__title__': 'markdownify', '__author__': 'Matthew Tretter', - '__version__': '0.9.2', + '__version__': '0.9.3', } diff --git a/tests/test_tables.py b/tests/test_tables.py index e481e92..27d4403 100644 --- a/tests/test_tables.py +++ b/tests/test_tables.py @@ -39,6 +39,25 @@ table_with_html_content = """
| Firstname | +Lastname |
+ Age | +
|---|---|---|
Jill |
+ Smith |
+ 50 |
+
| Eve | +Jackson | +94 | +
| Firstname | @@ -124,6 +143,7 @@ table_missing_head = """
|---|