1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-04 16:07:57 +03:00

Replace footnotes by footnote-calls

This commit is contained in:
Guillaume Ayoub 2021-11-15 15:00:59 +01:00
parent 75e343591d
commit 20fdc45ccc
4 changed files with 10 additions and 6 deletions

View File

@ -519,6 +519,8 @@ var { font-style: italic; }
video { object-fit: contain; } video { object-fit: contain; }
xmp { display: block; font-family: monospace; margin-bottom: 1em; margin-top: 1em; /* unicode-bidi: isolate; */ white-space: pre; } xmp { display: block; font-family: monospace; margin-bottom: 1em; margin-top: 1em; /* unicode-bidi: isolate; */ white-space: pre; }
::footnote-call { content: counter(footnote); vertical-align: baseline; font-size: 100%; line-height: inherit; font-variant-position: super; }
@page { @page {
/* `size: auto` (the initial) is A4 portrait */ /* `size: auto` (the initial) is A4 portrait */
margin: 75px; margin: 75px;

View File

@ -137,7 +137,7 @@ def element_to_box(element, style_for, get_image_from_uri, base_url,
{}, # counter_values: name -> stacked/scoped values {}, # counter_values: name -> stacked/scoped values
[set()] # counter_scopes: element tree depths -> counter names [set()] # counter_scopes: element tree depths -> counter names
) )
_quote_depth, counter_values, counter_scopes = state quote_depth, counter_values, counter_scopes = state
update_counters(state, style) update_counters(state, style)
@ -213,6 +213,13 @@ def element_to_box(element, style_for, get_image_from_uri, base_url,
if style['list_style_position'] == 'outside': if style['list_style_position'] == 'outside':
box.children.append(boxes.TextBox.anonymous_from(box, '')) box.children.append(boxes.TextBox.anonymous_from(box, ''))
if style['float'] == 'footnote':
style = style_for(element, 'footnote-call')
box = make_box(f'{element.tag}::footnote-call', style, [], element)
box.children = content_to_boxes(
style, box, quote_depth, counter_values, get_image_from_uri,
target_collector, counter_style)
# Specific handling for the element. (eg. replaced element) # Specific handling for the element. (eg. replaced element)
return html.handle_element(element, box, get_image_from_uri, base_url) return html.handle_element(element, box, get_image_from_uri, base_url)

View File

@ -245,8 +245,6 @@ def _out_of_flow_layout(context, box, index, child, new_children,
if result: if result:
new_children, resume_at = result new_children, resume_at = result
stop = True stop = True
elif child.is_footnote():
pass
elif child.is_running(): elif child.is_running():
running_name = child.style['position'][1] running_name = child.style['position'][1]
page = context.current_page page = context.current_page

View File

@ -581,9 +581,6 @@ def _out_of_flow_layout(context, box, containing_block, index, child,
box.style['direction'] == 'rtl')): box.style['direction'] == 'rtl')):
old_child.translate(dx=dx) old_child.translate(dx=dx)
elif child.is_footnote():
pass
elif child.is_running(): elif child.is_running():
running_name = child.style['position'][1] running_name = child.style['position'][1]
page = context.current_page page = context.current_page