Fix #3770: Fix KeyError from code-block directive

This commit is contained in:
Takeshi KOMIYA 2017-05-21 09:51:35 +09:00
parent b18a3f82b4
commit a43cac55bc
2 changed files with 4 additions and 2 deletions

View File

@ -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
-------- --------

View File

@ -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