module helper_in_notebook
¶
Short summary¶
module jyquickhelper.helper_in_notebook
Functions to call from the notebook
Functions¶
function |
truncated documentation |
---|---|
Adds javascript and HTML to the notebook which gathers all in the notebook and builds a menu. |
|
install an extension, checks first it exists, if not displays an exception with the list of them |
|
This function must be called from the notebook you want to know the name. It relies on a javascript piece of code. … |
Documentation¶
Functions to call from the notebook
Adds javascript and HTML to the notebook which gathers all in the notebook and builds a menu.
- Parameters:
menu_id – menu_id
raw – raw HTML and Javascript
format – html or rst
header – title of the menu (None for None)
first_level – first level to consider
last_level – last level to consider
keep_item – None or integer (starts at 0), reduce the number of displayed items to 1 and its descendant
- Returns:
HTML object
In a notebook, it is easier to do by using a magic command
%%html
for the HTML and another one%%javascript
for the Javascript. This function returns a full text with HTML and javascript.If the format is RST, the menu can be copied/pasted in a text cell.
On the notebook, the instruction would work:
var anchors = document.getElementsByClassName("anchor-link");
But it fails during the conversion from a notebook to format RST.
- jyquickhelper.helper_in_notebook.load_extension(name)¶
install an extension, checks first it exists, if not displays an exception with the list of them
- Parameters:
name – extension name
- jyquickhelper.helper_in_notebook.set_notebook_name_theNotebook(name='theNotebook', display=True)¶
This function must be called from the notebook you want to know the name. It relies on a javascript piece of code. It populates the variable
theNotebook
with the notebook name.- Parameters:
name – name of the variable to create
display – calls display or returns a javascript object
- Returns:
None or Javascript
This solution was found at How to I get the current IPython Notebook name.
The function can be called in a cell. The variable
theNotebook
will be available in the next cells.Try function
store_notebook_path()
if this one does not work.