Skip to content

Commit 2623c75

Browse files
committed
Preprocess: Workaround bad formatting by using non-zero width
1 parent 23598b8 commit 2623c75

4 files changed

Lines changed: 174 additions & 121 deletions

File tree

commands/preprocess_cssless.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def preprocess_html_merge_cssless(src_path, dst_path):
3737
strip_style_tags(root)
3838
convert_span_tables_to_tr_td(root)
3939
convert_inline_block_elements_to_table(root)
40+
convert_zero_td_width_to_nonzero(root)
4041

4142
head = os.path.dirname(dst_path)
4243
os.makedirs(head, exist_ok=True)
@@ -182,3 +183,12 @@ def convert_inline_block_elements_to_table(root_el):
182183
el.getparent().remove(el)
183184
td.append(el)
184185

186+
187+
def convert_zero_td_width_to_nonzero(root_el):
188+
for el in root_el.xpath('//*[contains(@style, "width")]'):
189+
if has_css_property_value(el, 'width', '0%'):
190+
el.attrib['width'] = "1px"
191+
remove_css_property(el, 'width')
192+
193+
for el in root_el.xpath('//*[contains(@width, "0%")]'):
194+
el.attrib['width'] = "1px"

0 commit comments

Comments
 (0)