@@ -67,7 +67,7 @@ def _todict(obj):
67
67
return dict ((k , getattr (obj , k )) for k in dir (obj ) if not k .startswith ('_' ))
68
68
69
69
70
- def remove_whitespace_inside (el ):
70
+ def should_remove_whitespace_inside (el ):
71
71
"""Return to remove whitespace immediately inside a block-level element."""
72
72
if not el or not el .name :
73
73
return False
@@ -79,9 +79,9 @@ def remove_whitespace_inside(el):
79
79
'tr' , 'td' , 'th' )
80
80
81
81
82
- def remove_whitespace_outside (el ):
82
+ def should_remove_whitespace_outside (el ):
83
83
"""Return to remove whitespace immediately outside a block-level element."""
84
- return remove_whitespace_inside (el ) or (el and el .name == 'pre' )
84
+ return should_remove_whitespace_inside (el ) or (el and el .name == 'pre' )
85
85
86
86
87
87
class MarkdownConverter (object ):
@@ -139,17 +139,17 @@ def process_tag(self, node, convert_as_inline, children_only=False):
139
139
140
140
# Remove whitespace-only textnodes just before, after or
141
141
# inside block-level elements.
142
- remove_inside = remove_whitespace_inside (node )
142
+ should_remove_inside = should_remove_whitespace_inside (node )
143
143
for el in node .children :
144
144
# Only extract (remove) whitespace-only text node if any of the
145
145
# conditions is true:
146
146
# - el is the first element in its parent (block-level)
147
147
# - el is the last element in its parent (block-level)
148
148
# - el is adjacent to a block-level node
149
- can_extract = (remove_inside and (not el .previous_sibling
150
- or not el .next_sibling )
151
- or remove_whitespace_outside (el .previous_sibling )
152
- or remove_whitespace_outside (el .next_sibling ))
149
+ can_extract = (should_remove_inside and (not el .previous_sibling
150
+ or not el .next_sibling )
151
+ or should_remove_whitespace_outside (el .previous_sibling )
152
+ or should_remove_whitespace_outside (el .next_sibling ))
153
153
if (isinstance (el , NavigableString )
154
154
and six .text_type (el ).strip () == ''
155
155
and can_extract ):
@@ -195,12 +195,12 @@ def process_text(self, el):
195
195
# remove leading whitespace at the start or just after a
196
196
# block-level element; remove traliing whitespace at the end
197
197
# or just before a block-level element.
198
- if (remove_whitespace_outside (el .previous_sibling )
199
- or (remove_whitespace_inside (el .parent )
198
+ if (should_remove_whitespace_outside (el .previous_sibling )
199
+ or (should_remove_whitespace_inside (el .parent )
200
200
and not el .previous_sibling )):
201
201
text = text .lstrip ()
202
- if (remove_whitespace_outside (el .next_sibling )
203
- or (remove_whitespace_inside (el .parent )
202
+ if (should_remove_whitespace_outside (el .next_sibling )
203
+ or (should_remove_whitespace_inside (el .parent )
204
204
and not el .next_sibling )):
205
205
text = text .rstrip ()
206
206
0 commit comments