diff options
author | Jeppe Pihl <jpihl08@gmail.com> | 2014-10-06 10:58:03 +0200 |
---|---|---|
committer | Jeppe Pihl <jpihl08@gmail.com> | 2014-10-06 10:58:03 +0200 |
commit | 9119424dfab8181930da8a8c16683d4aad0dd249 (patch) | |
tree | 2dc1693a97dd9d93332ff8434f7bfd81dbda22dc | |
parent | bd0b5f19426148f0ead0c70e564d1b301da7fc53 (diff) | |
download | sphinx-9119424dfab8181930da8a8c16683d4aad0dd249.tar.gz |
fixed bugs, and extended unit test to catch them again if they reappear
-rw-r--r-- | sphinx/directives/code.py | 7 | ||||
-rw-r--r-- | tests/roots/test-directive-code/lineno_match.rst | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py index 90be1557..4e1a0e8b 100644 --- a/sphinx/directives/code.py +++ b/sphinx/directives/code.py @@ -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 diff --git a/tests/roots/test-directive-code/lineno_match.rst b/tests/roots/test-directive-code/lineno_match.rst index f1e9cf15..4e3b3835 100644 --- a/tests/roots/test-directive-code/lineno_match.rst +++ b/tests/roots/test-directive-code/lineno_match.rst @@ -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 |