Skip to content

Hide code in book: toggle in HTML, removed in PDF - #46

Merged
agentmess merged 1 commit into
mainfrom
agentmess-hide-book-code
Nov 3, 2026
Merged

agentmess merged 1 commit into
mainfrom
agentmess-hide-book-code

Conversation

@agentmess

Copy link
Copy Markdown
Member

Readers of the book mostly want the figures and text, so code cells are now hidden by default.

  • HTML: all code cells are tagged hide-input, so the source sits behind a "Show code cell source" toggle and outputs stay visible.
  • PDF: a small local Sphinx extension (Notebooks/hide_code_latex.py, registered in _config.yml) sets nb_remove_code_source only for latex/pdflatex builds, so the PDF omits code.
  • Removed the jupyter: hide-input block in _config.yml, which is not a valid Jupyter Book option and had no effect.

Notes: notebook diffs only add the cell tag. Not yet verified with a full HTML or PDF build; worth checking the PR's deploy output.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 3, 2026 23:00
@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities found.

Scanned Files

None

@agentmess
agentmess merged commit f83cad8 into main Nov 3, 2026
2 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The callback runs after MyST-NB copies the Sphinx options, so the LaTeX override is applied too late and code source remains visible in the PDF.

1 open issue
What changed in this PR

This PR adjusts the MRI education book to emphasize text and figures, with collapsible code in HTML and an extension intended to omit code from PDF builds.

Changes:

  • Adds hide-input tags across 17 notebooks without changing code or outputs.
  • Adds and registers a LaTeX-specific source-hiding extension.
  • Removes the ineffective jupyter: hide-input configuration.
File Description
Notebooks/​Spectral-Spatial RF Pulses.ipynb Adds code-input hiding tags.
Notebooks/​Spatial Encoding.ipynb Adds code-input hiding tags.
Notebooks/​RF Pulses.ipynb Adds a code-input hiding tag.
Notebooks/​RF Pulse Design.ipynb Adds code-input hiding tags.
Notebooks/​Point Spread Function Analysis.ipynb Adds code-input hiding tags.
Notebooks/​MRI Math Concepts.ipynb Adds code-input hiding tags.
Notebooks/​Magnetic Fields in MRI.ipynb Adds code-input hiding tags.
Notebooks/​K-space.ipynb Adds code-input hiding tags.
Notebooks/​Image Reconstruction.ipynb Adds a code-input hiding tag.
Notebooks/​Image Contrast Examples.ipynb Adds a code-input hiding tag.
Notebooks/​hide_code_latex.py Adds a builder-specific source-removal callback.
Notebooks/​FOV and Resolution.ipynb Adds code-input hiding tags.
Notebooks/​Fast Imaging Pulse Sequences.ipynb Adds a code-input hiding tag.
Notebooks/​Bloch Equation.ipynb Adds code-input hiding tags.
Notebooks/​Basic Contrast Mechanisms.ipynb Adds tags while preserving existing metadata.
Notebooks/​Artifacts.ipynb Adds code-input hiding tags.
Notebooks/​Advanced SNR.ipynb Adds code-input hiding tags.
Notebooks/​Accelerated Imaging Methods.ipynb Adds code-input hiding tags.
Notebooks/​_config.yml Registers the extension and removes ineffective configuration.

Review effort: Balanced



def setup(app):
app.connect("builder-inited", _on_builder_inited, priority=900)
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.

3 participants