Skip to content

Commit d0c4b85

Browse files
authored
simplify computation of convert_children_as_inline variable (#182)
Signed-off-by: chrispy <[email protected]>
1 parent ae0597d commit d0c4b85

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

Diff for: markdownify/__init__.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,13 @@ def convert_soup(self, soup):
135135
def process_tag(self, node, convert_as_inline):
136136
text = ''
137137

138-
# markdown headings or cells can't include
139-
# block elements (elements w/newlines)
140-
isHeading = html_heading_re.match(node.name) is not None
141-
isCell = node.name in ['td', 'th']
142-
convert_children_as_inline = convert_as_inline
143-
144-
if isHeading or isCell:
145-
convert_children_as_inline = True
138+
# For Markdown headings and table cells, convert children as inline
139+
# (so that block element children do not produce newlines).
140+
convert_children_as_inline = (
141+
convert_as_inline # propagated from parent
142+
or html_heading_re.match(node.name) is not None # headings
143+
or node.name in ['td', 'th'] # table cells
144+
)
146145

147146
# Remove whitespace-only textnodes just before, after or
148147
# inside block-level elements.

0 commit comments

Comments
 (0)