mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-10-13 17:02:12 -05:00
fixed bugs, and extended unit test to catch them again if they reappear
This commit is contained in:
1 parent
a3745cfb5e
commit
0b0cf82a75
2 files changed
+5
-4
No files matched your search
@@ -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