ipython-contrib / jupyter_contrib_nbextensions

A collection of various notebook extensions for Jupyter
http://jupyter-contrib-nbextensions.readthedocs.io/en/latest
Other
5.22k stars 805 forks source link

runtools: Saving hidden input property #312

Open vladchimescu opened 9 years ago

vladchimescu commented 9 years ago

Hi, I am having an issue with hide_input.js nbextension. When pressing the hide input button, the code block indeed disappears. However, if the hidden block was run and the notebook is saved and restarted, the hidden block is visible in the new session (the block itself not its output). It appears that init_hide_input() function doesn't work properly for hidden blocks that were executed in the previous session. Was this behavior programmed in by design? Also it seems like the extension is not correctly loaded in my notebook app as the message is not printed in the console (as it should judging from the code) I am running IPython Notebook 3.2.0. Despite that code hiding works but only in the current session. I am setting some options in these hidden blocks which I am trying to hide from the reader to not interrupt the narrative. The reader receives live notebooks

juhasch commented 9 years ago

This extension is a little outdated. The runtools extension provides this feature among other things, too.

vladchimescu commented 9 years ago

Thank you, Jürgen! I am using runtools now, but the code hiding is still not being remembered, if the hidden cell was executed in the previous session. Perhaps, upon execution the hidden cell metadata is changed and upon reload it's no longer hidden (?).

juhasch commented 9 years ago

Works for me without any problems. You can check in the ipynb file for hidden_input: true in the metadata. Example:

{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true,
    "hide_input": true,
    "run_control": {
     "marked": true
    }
   },
   "outputs": [],
   "source": [
    "a = \"Hidden cell\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "b = \"Visible cell\""
   ]
  }
 ], 
jcb91 commented 8 years ago

@vladchimescu did you get this working? I've updated hide_input since you raised this, so if you fancy testing that, it would be useful to know if it works for you. It uses a different metadata key to runtools, so the two won't necessarily agree on which cells are hidden. @juhasch, there are a few extensions providing subsets of runtools' functionality, do you think it would be worth updating them to work better in concert with runtools (e.g. using runtools' metadata namespace), or better to remove them to avoid confusion?