Add fixedsize as third image_size value
When True, enclose the image cell in a table without borders to avoid narrow borders when the fixed width is less than the node width.
This commit is contained in:
parent
b1173a0a50
commit
6081bf5c28
@ -58,8 +58,17 @@ def nested_html_table(rows):
|
||||
def html_image(node):
|
||||
if not node.image:
|
||||
return None
|
||||
return f'''<tdX{' sides="TLR"' if node.caption else ''}{html_size_attr(node.image_size)}>''' \
|
||||
f'''<img scale="{node.image_scale}" src="{node.image}"/>'''
|
||||
size = html_size_attr(node.image_size)
|
||||
# The leading attributes belong to the preceeding tag. See where used below.
|
||||
html = f'{"".join(size)}><img scale="{node.image_scale}" src="{node.image}"/>'
|
||||
if size[2]: # fixedsize
|
||||
# Close the preceeding tag and enclose the image cell in a table without
|
||||
# borders to avoid narrow borders when the fixed width < the node width.
|
||||
html = f'''>
|
||||
<table border="0" cellspacing="0" cellborder="0"><tr>
|
||||
<td{html}</td>
|
||||
</tr></table>'''
|
||||
return f'''<tdX{' sides="TLR"' if node.caption else ''}{html}'''
|
||||
|
||||
def html_caption(node):
|
||||
return f'''<tdX{' sides="LRB"' if node.image else ''}>{html_line_breaks(node.caption)}''' if node.caption else None
|
||||
@ -69,10 +78,13 @@ def html_size_attr(size):
|
||||
# size: List of values where only these are used:
|
||||
# - First value is minimum width of object in points, an int value in the range 1-65535. (Default 0 = none)
|
||||
# - Second value is minimum height of the object in points, an int value in the range 1-65535. (Default 0 = none)
|
||||
# - Third value is a boolean where TRUE specify that the first two values are the fixed image cell size.
|
||||
# (Default FALSE) Other string values, e.g. FIXED are also interpreted as TRUE.
|
||||
if not size or not isinstance(size, list):
|
||||
return ''
|
||||
return ((f' width="{size[0]}"' if len(size) > 0 and size[0] else '')
|
||||
+ (f' height="{size[1]}"' if len(size) > 1 and size[1] else ''))
|
||||
return [''] * 3
|
||||
return [f' width="{size[0]}"' if len(size) > 0 and size[0] else '',
|
||||
f' height="{size[1]}"' if len(size) > 1 and size[1] else '',
|
||||
' fixedsize="TRUE"' if len(size) > 2 and size[2] else '']
|
||||
|
||||
|
||||
def expand(yaml_data):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user