The highlighter extension:

  • Firstable, the extension provides several toolbar buttons for highlighting a selected text within a markdown cell. Three different `color schemes' are provided, which can be easily customized in the \textit{stylesheet} highlighter.css. The last button enables to remove all highlightings in the current cell.
  • This works both when the cell is _rendered_ and when the cell is in edit mode;
  • In both modes, it is possible to highlight formatted portions of text (In rendered mode, since the selected text loose its formatting, an heuristic is applied to find the best alignment with the actual text)
  • When no text is selected, the whole cell is highlighted;
  • The extension also provides two keyboard shortcuts (Alt-G and Alt-H) which fire the highlighting of the selected text.
  • Highlights can be preserved when exporting to html or to LaTeX -- details are provided in export_highlights

Installation:

The extension can be installed with the nice UI available on jupyter_contrib_nbextensions website, which also allows to enable/disable the extension.

You may also install the extension from the original repo: issue

jupyter nbextension install https://rawgit.com/jfbercher/small_nbextensions/master/highlighter.zip  --user

at the command line.

Testing:

Use a code cell with

%%javascript
require("base/js/utils").load_extensions("highlighter/highlighter")

Automatic load

You may also automatically load the extension for any notebook via

jupyter nbextension enable highlighter/highlighter

In [2]:
%%javascript
require("base/js/utils").load_extensions("highlighter/highlighter")