Skip to content

Register custom nodes for the Markdown builder - #885

Merged
mgeier merged 1 commit into
spatialaudio:masterfrom
RClaudiuM:fix/859-markdown-builder-code-cells
Nov 8, 2026
Merged

mgeier merged 1 commit into
spatialaudio:masterfrom
RClaudiuM:fix/859-markdown-builder-code-cells

Conversation

@RClaudiuM

Copy link
Copy Markdown
Contributor

Fixes #859

CodeAreaNode, FancyOutputNode, AdmonitionNode and GalleryNode only have handlers for the html, latex and text builders. sphinx-markdown-builder (builder name markdown) skips nodes it has no handler for, so notebook code cells, nbinfo/nbwarning boxes and galleries were dropped from its output, each with a WARNING: unknown node type.

This registers markdown handlers the same way the text builder is handled (do_nothing), so the children (the literal_block of a code cell, the paragraphs of an info box, ...) get rendered by the Markdown translator.

Reproduction (nbsphinx_execute = 'never', a notebook with a markdown cell, two code cells with outputs, an alert-info box and an nbgallery; sphinx-build -b markdown, Sphinx 9.1.1, sphinx-markdown-builder 0.6.11):

Before:

index.rst:2: WARNING: unknown node type: <GalleryNode: >
nb.ipynb:: WARNING: unknown node type: <CodeAreaNode: <literal_block...>>
nb.ipynb:9: WARNING: unknown node type: <AdmonitionNode: <paragraph...>>

and nb.md contains only the markdown cells (0 code blocks).

After: no warnings, and every code cell shows up as a fenced block:

```python
print('hello stdout')
6 * 7
```

Note: plain-text outputs now appear too, but sphinx-markdown-builder currently emits the content of every raw node regardless of its format, so the .. raw:: html/latex/text variants of an output are all written out. That is liran-funaro/sphinx-markdown-builder#74, not something nbsphinx can fix by itself.

The html and text builds of the same project are unchanged.

sphinx-markdown-builder (builder name "markdown") skips nodes without a
registered handler, so code cells, info/warning boxes and galleries were
dropped from its output with "unknown node type" warnings. Handle them
like the text builder does, so their children are rendered.
@mgeier
mgeier merged commit 946ea62 into spatialaudio:master Nov 8, 2026
13 checks passed
@mgeier

mgeier commented Nov 8, 2026

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Markdown builder output missing code cells

2 participants