From d7cdb9e22dbf57a3673d4d765dad5246ad878081 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 10 Jan 2021 23:38:50 +0900 Subject: [PATCH] Fix #8671: highlight_options is not working Sadly HTML and LaTeX writers compares the highlight languages using `is` operator. As a result, it has not worked even if languages are same. This replaces the comparison operator by `==`. --- CHANGES | 1 + sphinx/writers/html.py | 2 +- sphinx/writers/html5.py | 2 +- sphinx/writers/latex.py | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index b10c7f5fd..cc6b20774 100644 --- a/CHANGES +++ b/CHANGES @@ -46,6 +46,7 @@ Bugs fixed * #8665: html theme: Could not override globaltoc_maxdepth in theme.conf * #8094: texinfo: image files on the different directory with document are not copied +* #8671: :confval:`highlight_options` is not working Testing -------- diff --git a/sphinx/writers/html.py b/sphinx/writers/html.py index 5c6feaf7f..fc20f6e3b 100644 --- a/sphinx/writers/html.py +++ b/sphinx/writers/html.py @@ -439,7 +439,7 @@ class HTMLTranslator(SphinxTranslator, BaseTranslator): linenos = node.get('linenos', False) highlight_args = node.get('highlight_args', {}) highlight_args['force'] = node.get('force', False) - if lang is self.config.highlight_language: + if lang == self.config.highlight_language: # only pass highlighter options for original language opts = self.config.highlight_options else: diff --git a/sphinx/writers/html5.py b/sphinx/writers/html5.py index b49d80bfa..557027da5 100644 --- a/sphinx/writers/html5.py +++ b/sphinx/writers/html5.py @@ -390,7 +390,7 @@ class HTML5Translator(SphinxTranslator, BaseTranslator): linenos = node.get('linenos', False) highlight_args = node.get('highlight_args', {}) highlight_args['force'] = node.get('force', False) - if lang is self.config.highlight_language: + if lang == self.config.highlight_language: # only pass highlighter options for original language opts = self.config.highlight_options else: diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index f5b782c66..dc16bd32c 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1751,7 +1751,7 @@ class LaTeXTranslator(SphinxTranslator): linenos = node.get('linenos', False) highlight_args = node.get('highlight_args', {}) highlight_args['force'] = node.get('force', False) - if lang is self.config.highlight_language: + if lang == self.config.highlight_language: # only pass highlighter options for original language opts = self.config.highlight_options else: