mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #3770: Fix KeyError from code-block directive
This commit is contained in:
parent
b18a3f82b4
commit
a43cac55bc
2
CHANGES
2
CHANGES
@ -22,6 +22,8 @@ Bugs fixed
|
|||||||
`rtfd/readthedocs.org#2857
|
`rtfd/readthedocs.org#2857
|
||||||
<https://github.com/rtfd/readthedocs.org/issues/2857>`_ issue, a workaround
|
<https://github.com/rtfd/readthedocs.org/issues/2857>`_ issue, a workaround
|
||||||
is obtained using some extra LaTeX code in Sphinx's own :file:`conf.py`
|
is obtained using some extra LaTeX code in Sphinx's own :file:`conf.py`
|
||||||
|
* #3770: Build fails when a "code-block" has the option emphasize-lines and the
|
||||||
|
number indicated is higher than the number of lines
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
@ -127,7 +127,7 @@ class CodeBlock(Directive):
|
|||||||
hl_lines = parselinenos(linespec, nlines)
|
hl_lines = parselinenos(linespec, nlines)
|
||||||
if any(i >= nlines for i in hl_lines):
|
if any(i >= nlines for i in hl_lines):
|
||||||
logger.warning('line number spec is out of range(1-%d): %r' %
|
logger.warning('line number spec is out of range(1-%d): %r' %
|
||||||
(nlines, self.options['emphasize_lines']),
|
(nlines, self.options['emphasize-lines']),
|
||||||
location=location)
|
location=location)
|
||||||
|
|
||||||
hl_lines = [x + 1 for x in hl_lines if x < nlines]
|
hl_lines = [x + 1 for x in hl_lines if x < nlines]
|
||||||
@ -441,7 +441,7 @@ class LiteralInclude(Directive):
|
|||||||
hl_lines = parselinenos(self.options['emphasize-lines'], lines)
|
hl_lines = parselinenos(self.options['emphasize-lines'], lines)
|
||||||
if any(i >= lines for i in hl_lines):
|
if any(i >= lines for i in hl_lines):
|
||||||
logger.warning('line number spec is out of range(1-%d): %r' %
|
logger.warning('line number spec is out of range(1-%d): %r' %
|
||||||
(lines, self.options['emphasize_lines']),
|
(lines, self.options['emphasize-lines']),
|
||||||
location=location)
|
location=location)
|
||||||
extra_args['hl_lines'] = [x + 1 for x in hl_lines if x < lines]
|
extra_args['hl_lines'] = [x + 1 for x in hl_lines if x < lines]
|
||||||
extra_args['linenostart'] = reader.lineno_start
|
extra_args['linenostart'] = reader.lineno_start
|
||||||
|
Loading…
Reference in New Issue
Block a user