Skip to content

Commit 03d65fa

Browse files
committed
Fix hide code for non html builders
1 parent fce1902 commit 03d65fa

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

jupyter_sphinx/execute.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,17 @@ def depart_container_html(self, node):
791791
self.depart_container(node)
792792
self.body.append(node.depart_html())
793793

794+
def visit_thebe_source(self, node):
795+
if node['hide_code']:
796+
raise docutils.nodes.SkipNode
797+
else:
798+
self.visit_container(node)
799+
800+
render_thebe_source = (
801+
visit_thebe_source,
802+
lambda self, node: self.depart_container(node)
803+
)
804+
794805
app.add_node(
795806
JupyterWidgetViewNode,
796807
html=(visit_widget_html, None),
@@ -813,10 +824,10 @@ def depart_container_html(self, node):
813824
app.add_node(
814825
ThebeSourceNode,
815826
html=(visit_widget_html, None),
816-
latex=render_container,
817-
textinfo=render_container,
818-
text=render_container,
819-
man=render_container,
827+
latex=render_thebe_source,
828+
textinfo=render_thebe_source,
829+
text=render_thebe_source,
830+
man=render_thebe_source,
820831
)
821832

822833
app.add_node(

0 commit comments

Comments
 (0)