From e2021ca9d4a295a5584eaae7c5ca726bc4d0de6b Mon Sep 17 00:00:00 2001 From: Matthias Geier Date: Sat, 20 Feb 2021 14:38:38 +0100 Subject: [PATCH] Disable automatic highlighting in notebooks --- doc/conf.py | 3 --- doc/usage.ipynb | 28 +--------------------------- src/nbsphinx.py | 1 + 3 files changed, 2 insertions(+), 30 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index bafdf091..9bd37e32 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -13,9 +13,6 @@ 'sphinx_last_updated_by_git', # get "last updated" from Git ] -# Default language for syntax highlighting in reST and Markdown cells: -highlight_language = 'none' - # Don't add .txt suffix to source files: html_sourcelink_suffix = '' diff --git a/doc/usage.ipynb b/doc/usage.ipynb index 7288d438..48287463 100644 --- a/doc/usage.ipynb +++ b/doc/usage.ipynb @@ -116,28 +116,6 @@ "* `'sphinx_gallery.load_style'` to load CSS styles for [thumbnail galleries](subdir/gallery.ipynb)" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### `highlight_language`\n", - "\n", - "Default language for syntax highlighting in reST and Markdown cells,\n", - "when no language is specified explicitly.\n", - "\n", - "By default, this is `'python3'`,\n", - "while Jupyter doesn't have a default language.\n", - "Set\n", - "[highlight_language](http://www.sphinx-doc.org/en/master/usage/configuration.html#confval-highlight_language)\n", - "to `'none'` to get the same behavior as in Jupyter:\n", - "\n", - "```python\n", - "highlight_language = 'none'\n", - "```\n", - "\n", - "See also [nbsphinx_codecell_lexer](#nbsphinx_codecell_lexer)." - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -273,11 +251,7 @@ "\n", "Default Pygments lexer for syntax highlighting in code cells.\n", "If available,\n", - "this information is taken from the notebook metadata instead.\n", - "\n", - "Please note that this is not the same as\n", - "[highlight_language](#highlight_language),\n", - "which is used for formatting code in Markdown cells!" + "this information is taken from the notebook metadata instead." ] }, { diff --git a/src/nbsphinx.py b/src/nbsphinx.py index c4915a5a..104b1bdd 100644 --- a/src/nbsphinx.py +++ b/src/nbsphinx.py @@ -1049,6 +1049,7 @@ def parse(self, inputstring, document): if resources.get('nbsphinx_orphan', False): rst.Parser.parse(self, ':orphan:', document) + rst.Parser.parse(self, '.. highlight:: none', document) if env.config.nbsphinx_prolog: prolog = exporter.environment.from_string( env.config.nbsphinx_prolog).render(env=env)