Open
Conversation
for more information, see https://pre-commit.ci
This was referenced Feb 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GIF Support Implementation for nbconvert
Overview
This document describes the implementation of native GIF image support in nbconvert, which eliminates the need for the monkey patch previously required for example in WhipperSnapPy (Deep-MI/WhipperSnapPy#59). See also Issue #2270 .
Problem Statement
Previously, nbconvert did not support the
image/gifMIME type for display data outputs. This meant that animated GIFs generated by notebook cells would:Solution Overview
The implementation adds native GIF support across three main areas. All changes are additive and existing conversion without gif will not break.
1. Output Extraction (ExtractOutputPreprocessor)
File:
nbconvert/preprocessors/extractoutput.pyChanges:
"image/gif"to theextract_output_typesSet (line 52)"image/gif"to the binary MIME types that are base64-decoded (line 92)Why: This ensures that GIF image data is properly extracted from notebook outputs and converted from base64 to binary format, just like PNG and JPEG images.
2. Display Priority
File:
share/templates/base/display_priority.j2Changes:
data_gifblock for template inheritanceWhy: This ensures that GIF outputs are selected and prioritized appropriately in the output rendering pipeline.
3. Template Rendering
Templates were updated across multiple export formats to handle GIF rendering:
HTML Templates
File:
share/templates/classic/base.html.j2data_gifblock with full HTML img tag supportFile:
share/templates/lab/base.html.j2data_gifblock with JupyterLab-specific CSS classesMarkdown Template
share/templates/markdown/index.md.j2data_gifblock with Markdown image syntaxReStructuredText Template
share/templates/rst/index.rst.j2data_gifblock with RST image directiveAsciiDoc Template
share/templates/asciidoc/index.asciidoc.j2data_gifblock with AsciiDoc image syntax4. Exporters
5. Tests