A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/jcb91/jupyter_highlight_selected_word below:

jcb91/jupyter_highlight_selected_word: Jupyter notebook extension that enables highlighting every instance of the current word in the notebook

This nbextension highlights all instances of the selected word in either the current cell's editor, or in all cells in the notebook. It is based on the CodeMirror addon Match Highlighter, but now uses its own codebase in order to permit matching across multiple editors.

There are a few configurable options, all of which sit under the config key highlight_selected_word in the notebook config section.

jupyter_highlight_selected_word is available as part of the jupyter_contrib_nbextensions collection. If you want to install this nbextension without the rest of the contrib collection, read on.

To use the nbextension, there are three basic steps:

  1. First, install the python package:

    pip install jupyter_highlight_selected_word
    

    Or, for those using conda, there is now a recipe provided through the excellent excellent conda-forge channel, which also performs the install into the conda env's jupyter data directory, so you can skip step 2. To install the conda recipe, use

    conda install -c conda-forge jupyter_highlight_selected_word
    
  2. Next, install javascript files from the python package into a jupyter data directory. For those using conda, the conda install performs this step automatically, so you can skip this.

    If you have jupyter version 4.2 or greater, you can install directly using jupyter:

    jupyter nbextension install --py jupyter_highlight_selected_word
    

    For jupyter versions before 4.2, you'll need to do a little more work to find the nbextension's static files. To find the nbextension source directory, you can use the following one-liner (for a rather stretched definition of 'line'):

    python -c "import os.path as p; from jupyter_highlight_selected_word import __file__ as f, _jupyter_nbextension_paths as n; print(p.normpath(p.join(p.dirname(f), n()[0]['src'])))"
    

    then execute

    jupyter nbextension install <output source directory>
    

    replacing <output source directory> with the directory found above.

  3. Enable the nbextension, so that it gets loaded automatically in each notebook:

    jupyter nbextension enable highlight_selected_word/main
    

Options are stored in the notebook section of the nbconfig. The easiest way to configure these is using the jupyter_nbextensions_configurator serverextension, but you can also configure them directly with a few lines of python.

The available options are:

For example, to set the delay to half a second, and limit highlighting to code cells, we can use the following python snippet:

from notebook.services.config import ConfigManager
cm = ConfigManager()
cm.update('notebook', {'highlight_selected_word': {
    'delay': 500,
    'code_cells_only': True,
}})

If you have any feedback, or have any problems, please let me know by opening an issue at the project's github repository.

Thanks!

Josh.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4