Skip to content

Thebe clashes with hide-cell tag in Jupyter-book #26

Description

@fortierq

Describe the bug

Thebe prevents cells with hide-cell tag from opening in Jupyter-book. "Click to show" does nothing. This is because the ID of the div is overwritten by shpinx-thebe, and the "click to show" button uses the original ID to toggle visibility.

To Reproduce

Steps to reproduce the behavior:

  1. Define a code cell for Jupyter-book:
```{code-cell} ipython3
:tags: [hide-cell]
(1 + 5**0.5)/2
```
  1. Launch Thebe inside Jupyter-book
  2. "Click to show" does not show hidden cell.

Expected behavior

"Click to show" should show the hidden cell.

Environment

  • Python Version: 3.8.5
  • Package versions or output of jupyter-book --version: 0.11.1
  • Operating System: Ubuntu

Additional context

The following line of code change the id of an hidden cell, preventing to toggle its hidden status:

const codeCells = document.querySelectorAll(thebe_selector)
codeCells.forEach((codeCell, index) => {
const codeCellId = index => `codecell${index}`;
codeCell.id = codeCellId(index);

Why do we need to change this codeCell.id? Can we modify only the id of non-hidden cells?

I would happily try to submit a PR if needed :)

PS: in https://jupyterbook.org/interactive/thebe.html, an example is provided with a hide-input cell. This works because the corresponding HTML element has class cell-input and not class cell (like hide-cell tag), and thus its id is not modified.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions