mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
fixed bugs, and extended unit test to catch them again if they reappear
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
import sys
|
||||
import codecs
|
||||
import os
|
||||
from difflib import unified_diff
|
||||
|
||||
from docutils import nodes
|
||||
@@ -286,7 +287,7 @@ class LiteralInclude(Directive):
|
||||
for line_number, line in enumerate(lines):
|
||||
if not use and startafter and startafter in line:
|
||||
if 'lineno-match' in self.options:
|
||||
linenostart += line_number + 2
|
||||
linenostart += line_number + 1
|
||||
use = True
|
||||
elif use and endbefore and endbefore in line:
|
||||
break
|
||||
@@ -296,8 +297,8 @@ class LiteralInclude(Directive):
|
||||
|
||||
if 'lineno-match' in self.options:
|
||||
# handle that preceding, empty lines ('\n') are removed.
|
||||
for line in lines[linenostart-1:]:
|
||||
if line != '\n':
|
||||
for line in lines:
|
||||
if line != os.linesep:
|
||||
break
|
||||
linenostart += 1
|
||||
|
||||
|
@@ -8,7 +8,7 @@ Literal Includes with Line Numbers Matching
|
||||
|
||||
.. literalinclude:: literal.inc
|
||||
:language: python
|
||||
:lines: 6,7,8-9
|
||||
:lines: 5-6,7,8-9
|
||||
:lineno-match:
|
||||
|
||||
.. literalinclude:: literal.inc
|
||||
|
Reference in New Issue
Block a user