From 1b773e0eb3fdb89860b66efde00a9c54eb7573cf Mon Sep 17 00:00:00 2001 From: Josh Barnes Date: Thu, 17 Sep 2015 01:05:29 +0100 Subject: [PATCH] standardise and prettify code snippets in readme.md files --- nbextensions/slidemode/slidemode/README.md | 2 +- nbextensions/usability/codefolding/readme.md | 3 +++ nbextensions/usability/dragdrop/readme.md | 8 +++++++- nbextensions/usability/latex_envs/readme.md | 19 +++++++++++++------ nbextensions/usability/limit_output/readme.md | 1 + .../usability/python-markdown/readme.md | 6 ++++++ nbextensions/usability/rubberband/readme.md | 2 ++ nbextensions/usability/ruler/readme.md | 1 + nbextensions/usability/runtools/readme.md | 3 +++ .../usability/skip-traceback/readme.md | 2 ++ 10 files changed, 39 insertions(+), 8 deletions(-) diff --git a/nbextensions/slidemode/slidemode/README.md b/nbextensions/slidemode/slidemode/README.md index 1d4535c..e31dc11 100644 --- a/nbextensions/slidemode/slidemode/README.md +++ b/nbextensions/slidemode/slidemode/README.md @@ -6,7 +6,7 @@ This folder contains the legacy slidemode Put the following in your custom.js -``` +```javascript // Slidemode require(['nbextensions/IPython-notebook-extensions/slidemode/main','base/js/events'], function(slidemode, events){ events.on('app_initialized.NotebookApp', function(){ diff --git a/nbextensions/usability/codefolding/readme.md b/nbextensions/usability/codefolding/readme.md index dbfbf20..ea56c9e 100644 --- a/nbextensions/usability/codefolding/readme.md +++ b/nbextensions/usability/codefolding/readme.md @@ -48,6 +48,7 @@ Installation Install the master version of the IPython-notebook-extensions repository as explained in the [wiki](https://github.com/ipython-contrib/IPython-notebook-extensions/wiki/). Then load the extension from within the IPyton notebook: + ```javascript %%javascript IPython.load_extensions('IPython-notebook-extensions-master/usability/codefolding/codefolding'); @@ -60,9 +61,11 @@ Internals You need the current master branch from Codemirror in order to get codefolding to work. This is still very much work-in-progress. The folding information is saved in the metadata of each codecell. The number of the folding start line (beginning with 0) is stored in an array: + ```javascript cell.metadata.code_folding = [ 3, 20, 33 ] ``` + When reloading the IPython notebook, the folding status is restored. diff --git a/nbextensions/usability/dragdrop/readme.md b/nbextensions/usability/dragdrop/readme.md index c8e2d9e..66cc39a 100644 --- a/nbextensions/usability/dragdrop/readme.md +++ b/nbextensions/usability/dragdrop/readme.md @@ -9,16 +9,19 @@ Installation ============ From IPython simply call + ```python import IPython IPython.html.nbextensions.install_nbextension('https://raw.githubusercontent.com/ipython-contrib/IPython-notebook-extensions/master/nbextensions/usability/dragdrop/main.js') ``` Then load the extension from within the IPyton notebook: + ```javascript %%javascript IPython.load_extensions('drag-and-drop'); ``` + Alternatively, you can add the load command to your `custom.js`. @@ -26,6 +29,9 @@ Internals ========= The image will be uploaded to the server into the directory where your notebook resides. This means, the image is not copied into the notebook itself, it will only be linked to. The markdown cell in the notebook will contain this tag: -`` + +```html + +``` If you run `nbconvert` to generate a HTML file, this image will remain outside of the html file. You can embedd all images by calling `nbconvert` with the option `--post=embed.EmbedPostProcessor`. The file `embed.py`, located in the same directory of this extension needs to be in `PYTHONPATH` to be found. \ No newline at end of file diff --git a/nbextensions/usability/latex_envs/readme.md b/nbextensions/usability/latex_envs/readme.md index 953c3d2..cf3bc6f 100644 --- a/nbextensions/usability/latex_envs/readme.md +++ b/nbextensions/usability/latex_envs/readme.md @@ -37,19 +37,26 @@ You should follow the instructions in the wiki. the notebook extension directory, usually ~/.local/share/jupyter/nebextensions (Jupyter) or ~/.ipython/nbextensions (IPython 3.x). Copy the scripts in conversion/ to some directory (preferably in your path). - Automated installation -An even more simple procedure is to issue -``` -jupyter nbextension install https://rawgit.com/jfbercher/latex_envs/master/latex_envs.zip --user +An even more simple procedure is to issue + +``` bash +jupyter nbextension install https://rawgit.com/jfbercher/latex_envs/master/latex_envs.zip --user ``` + at the command line. Either load the extension from your `custom.js` or use a code cell with - %%javascript - require("base/js/utils").load_extensions("latex_envs/latex_envs") +```javascript +%%javascript +require("base/js/utils").load_extensions("latex_envs/latex_envs") +``` You can automatically load the extension via - jupyter nbextension enable latex_envs/latex_envs + +```bash +jupyter nbextension enable latex_envs/latex_envs +``` Disclaimer, sources and acknowledgments diff --git a/nbextensions/usability/limit_output/readme.md b/nbextensions/usability/limit_output/readme.md index 61406dc..7575756 100644 --- a/nbextensions/usability/limit_output/readme.md +++ b/nbextensions/usability/limit_output/readme.md @@ -3,6 +3,7 @@ This extension limits the number of characters a codecell can output as text. Th [![Demo Video](http://img.youtube.com/vi/U26ujuPXf00/0.jpg)](https://youtu.be/U26ujuPXf00) You can set the number of characters using the ConfigManager: + ```Python from IPython.html.services.config import ConfigManager ip = get_ipython() diff --git a/nbextensions/usability/python-markdown/readme.md b/nbextensions/usability/python-markdown/readme.md index c1d34fc..8f3a812 100644 --- a/nbextensions/usability/python-markdown/readme.md +++ b/nbextensions/usability/python-markdown/readme.md @@ -1,14 +1,19 @@ This extension allows dynamically displaying Python variables in markdown cells. Example: If you set variable `a` in Python + ```Python a = 1.23 ``` + and write the following line in a markdown cell: + ```Markdown a = {{a}} ``` + It will be displayed as: + ```Markdown a = 1.23 ``` @@ -38,6 +43,7 @@ Installation Install the master version of the IPython-notebook-extensions repository as explained on the main wiki page. Then load the extension from within the IPyton notebook: + ```javascript %%javascript IPython.load_extensions('IPython-notebook-extensions-master/usability/python-markdown/main'); diff --git a/nbextensions/usability/rubberband/readme.md b/nbextensions/usability/rubberband/readme.md index 93c1ae0..e5bcb5b 100644 --- a/nbextensions/usability/rubberband/readme.md +++ b/nbextensions/usability/rubberband/readme.md @@ -22,9 +22,11 @@ Installation ============ Copy the `rubberband` directory to a new `/nbextensions/usability/rubberband` directory of your user's IPython directory and add + ```javascript IPython.load_extensions('usability/rubberband/main') ``` + to your `custom.js` file. Take a look at the general installation instructions in the Wiki if you are unsure how to proceed. diff --git a/nbextensions/usability/ruler/readme.md b/nbextensions/usability/ruler/readme.md index c29c1e3..251c4b4 100644 --- a/nbextensions/usability/ruler/readme.md +++ b/nbextensions/usability/ruler/readme.md @@ -5,6 +5,7 @@ Configuration ------------- You can set the number of characters in the notebook extensions configration page or use the ConfigManager: + ```Python from IPython.html.services.config import ConfigManager ip = get_ipython() diff --git a/nbextensions/usability/runtools/readme.md b/nbextensions/usability/runtools/readme.md index c75e59b..55bd1dc 100644 --- a/nbextensions/usability/runtools/readme.md +++ b/nbextensions/usability/runtools/readme.md @@ -45,11 +45,14 @@ A IPython notebook with marked cells looks like this: Installation ============ Copy the `runtools` directory to a new `/nbextensions/usability/runtools` directory of your user's IPython directory and add + ```javascript IPython.load_extensions('usability/runtools/main.js') ``` + to your `custom.js` file. Take a look at the general installation instructions in the Wiki if you are unsure how to proceed. + Internals ========= diff --git a/nbextensions/usability/skip-traceback/readme.md b/nbextensions/usability/skip-traceback/readme.md index eb064f5..24c2366 100644 --- a/nbextensions/usability/skip-traceback/readme.md +++ b/nbextensions/usability/skip-traceback/readme.md @@ -12,9 +12,11 @@ Installation ============ Copy the `skip-exceptions` directory to a new `/nbextensions/usability/skip-exceptions` directory of your user's IPython directory and add + ```javascript IPython.load_extensions('usability/skip-exceptions/main.js') ``` + to your `custom.js` file. Alternatively, you might want to use the `nbextensions` UI. Take a look at the general installation instructions in the Wiki if you are unsure how to proceed.