Fix: nbviewer does not render notebooks without any code cells correctly #2259
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.
Summary
This PR fixes Issue #2222. It updates the notebook metadata for markdown‑only cookbook notebooks by setting language_info.nbconvert_exporter to markdown. This ensures that nbviewer returns a non‑empty response when using “View as Markdown”.
For example, GPT-5.1 prompting guide 'View as Markdown' is broken: https://nbviewer.org/format/script/github/openai/openai-cookbook/blob/main/examples/gpt-5/gpt-5-1_prompting_guide.ipynb
The notebook in a commit of this PR including the fix does render: https://nbviewer.org/format/script/github/openai/openai-cookbook/blob/141d9eadd12588bcfc803a4a2d850f465de05010/examples/gpt-5/gpt-5-1_prompting_guide.ipynb?flush_cache=1
This is a temporary fix to restore functionality while we should work toward a better solution that does not rely on nbviewer’s script exporter behavior.
Motivation
Some cookbook pages failed to render in nbviewer when opened via the “View as Markdown” link. The root cause was that nbviewer’s /format/script endpoint delegates to the exporter specified in language_info.nbconvert_exporter. For markdown‑only notebooks, this exporter was set to python, causing nbviewer to emit an empty output because the notebook contained zero code cells. The result was a completely blank page on nbviewer.