Skip to content

Commit

Permalink
Handle needs_background cell metadata (#1704)
Browse files Browse the repository at this point in the history
This fixes issues when rendering Matplotlib figures with the
HTMLExporter, lab template and dark theme
  • Loading branch information
martinRenou authored Jan 17, 2022
1 parent b645841 commit 8df914d
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions share/jupyter/nbconvert/templates/lab/base.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,17 @@ width={{ width }}
{%- if height is not none %}
height={{ height }}
{%- endif %}
class="
{%- if output | get_metadata('unconfined', 'image/png') %}
class="unconfined"
unconfined
{%- endif %}
{%- if output | get_metadata('needs_background', 'image/png') == 'light' %}
jp-needs-light-background
{%- endif %}
{%- if output | get_metadata('needs_background', 'image/png') == 'dark' %}
jp-needs-dark-background
{%- endif %}
"
>
</div>
{%- endblock data_png %}
Expand All @@ -198,9 +206,17 @@ width={{ width }}
{%- if height is not none %}
height={{ height }}
{%- endif %}
class="
{%- if output | get_metadata('unconfined', 'image/jpeg') %}
class="unconfined"
unconfined
{%- endif %}
{%- if output | get_metadata('needs_background', 'image/jpeg') == 'light' %}
jp-needs-light-background
{%- endif %}
{%- if output | get_metadata('needs_background', 'image/jpeg') == 'dark' %}
jp-needs-dark-background
{%- endif %}
"
>
</div>
{%- endblock data_jpg %}
Expand Down

0 comments on commit 8df914d

Please sign in to comment.