Skip to content

remove input for hidden cells for exports#9548

Merged
Light2Dark merged 2 commits into
mainfrom
sham/export-respect-hide-cell
May 14, 2026
Merged

remove input for hidden cells for exports#9548
Light2Dark merged 2 commits into
mainfrom
sham/export-respect-hide-cell

Conversation

@Light2Dark
Copy link
Copy Markdown
Collaborator

@Light2Dark Light2Dark commented May 14, 2026

📝 Summary

Related to #9523 . For hidden cells, we don't include them in the export. Also adds source_hidden which is respected by Vscode, Jupyter notebooks.
image

📋 Pre-Review Checklist

  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • Video or media evidence is provided for any visual changes (optional).

✅ Merge Checklist

  • I have read the contributor guidelines.
  • Documentation has been updated where applicable, including docstrings for API changes.
  • Tests have been added for the changes made.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment May 14, 2026 1:12am

Request Review

@Light2Dark Light2Dark changed the title remove input for hidden cells remove input for hidden cells for exports May 14, 2026
@Light2Dark Light2Dark requested a review from Copilot May 14, 2026 00:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Honors hide_code=True cells when exporting marimo notebooks via nbconvert (PDF, WebPDF, Slides) by tagging them with the remove-input nbconvert tag and adding jupyter.source_hidden=true metadata for editor UIs (VS Code, JupyterLab).

Changes:

  • Add NBCONVERT_REMOVE_INPUT_TAG and emit remove-input tag + jupyter.source_hidden metadata in _create_ipynb_cell for hidden-code cells.
  • Configure PDFExporter, WebPDFExporter, and SlidesExporter with a TagRemovePreprocessor config that strips inputs for tagged cells.
  • Update snapshots and add unit/integration tests verifying the tag/metadata are emitted and that nbconvert strips the hidden cell source.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
marimo/_convert/ipynb/from_ir.py Adds remove-input tag and jupyter.source_hidden metadata to hidden-code cells in ipynb export.
marimo/_server/export/exporter.py Wires TagRemovePreprocessor config into PDF/WebPDF/Slides nbconvert exporters.
tests/_convert/ipynb/test_from_ir.py Adds unit test asserting hidden-cell metadata/tags.
tests/_server/export/test_exporter.py Adds integration test confirming nbconvert strips hidden cell source.
tests/_convert/ipynb/snapshots/*.ipynb.txt Updates snapshots for new metadata/tag fields.

@Light2Dark Light2Dark added the enhancement New feature or request label May 14, 2026
@Light2Dark Light2Dark marked this pull request as ready for review May 14, 2026 00:25
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 6 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="tests/_server/export/test_exporter.py">

<violation number="1" location="tests/_server/export/test_exporter.py:1241">
P2: Guard this nbconvert-based test with `DependencyManager.nbconvert.has()` too; otherwise it fails in optional-dependency environments.</violation>
</file>
Architecture diagram
sequenceDiagram
    participant Exporter as Export Service
    participant IR as IR Converter
    participant Config as Traitlets Config
    participant NBFormat as nbformat
    participant NBConvert as nbconvert (PDF/HTML/LaTeX/Slides)

    Note over Exporter,NBConvert: Export flow for hidden code cells

    Exporter->>IR: convert_from_ir_to_ipynb()
    IR->>IR: Build IPYNB cells from marimo IR
    
    alt Cell has hide_code=True
        IR->>IR: Set jupyter.source_hidden = True
        IR->>IR: Add "remove-input" to metadata.tags
    end
    
    IR-->>Exporter: IPYNB JSON string
    Exporter->>NBFormat: nbformat.reads(ipynb)
    NBFormat-->>Exporter: Notebook node
    
    alt PDF via standard exporter
        Exporter->>Config: _nbconvert_tag_remove_config()
        Config->>Config: Enable TagRemovePreprocessor
        Config->>Config: Set remove_input_tags = [NBCONVERT_REMOVE_INPUT_TAG]
        Config-->>Exporter: traitlets Config
        Exporter->>NBConvert: PDFExporter(config=config)
        NBConvert->>NBConvert: TagRemovePreprocessor strips cells with "remove-input"
        NBConvert-->>Exporter: PDF bytes
    else PDF via WebPDF
        Exporter->>Config: _nbconvert_tag_remove_config()
        Config-->>Exporter: traitlets Config
        Exporter->>NBConvert: WebPDFExporter(config=config)
        NBConvert->>NBConvert: TagRemovePreprocessor strips cells with "remove-input"
        NBConvert-->>Exporter: PDF bytes
    else Slides export
        Exporter->>Config: _nbconvert_tag_remove_config()
        Config-->>Exporter: traitlets Config
        Exporter->>NBConvert: SlidesExporter(config=config)
        NBConvert->>NBConvert: TagRemovePreprocessor strips cells with "remove-input"
        NBConvert-->>Exporter: HTML with reveal.js
    end
    
    Exporter-->>Exporter: Return exported data
Loading

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread tests/_server/export/test_exporter.py Outdated
Copy link
Copy Markdown
Contributor

@peter-gy peter-gy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks for addressing it so quickly!

@Light2Dark Light2Dark merged commit 5402c8d into main May 14, 2026
44 checks passed
@Light2Dark Light2Dark deleted the sham/export-respect-hide-cell branch May 14, 2026 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants