Skip to content

Commit

Permalink
support #@hide, #@hide_output, #@hide_code to hide notebook code and …
Browse files Browse the repository at this point in the history
…output
  • Loading branch information
Mu Li committed Oct 23, 2020
1 parent 52f80cc commit 89b8934
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions d2lbook/rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ def _process_nb(nb):
# hide/show
for cell in new_cells:
if cell.cell_type == 'code':
if '# hide outputs' in cell.source.lower():
src = cell.source.lower()
if '# hide outputs' in src or '#@hide' in src or '#@hide_output' in src:
cell.outputs = []
if '# hide code' in cell.source.lower():
if '# hide code' in src or '#@hide' in src or '#@hide_code' in src:
cell.source = ''
return notebook.create_new_notebook(nb, new_cells)

Expand Down

0 comments on commit 89b8934

Please sign in to comment.