mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #6742: end-before option of literalinclude skips first line
This commit is contained in:
parent
ec8d41b237
commit
39b166b6b9
3
CHANGES
3
CHANGES
@ -7,6 +7,9 @@ Dependencies
|
||||
Incompatible changes
|
||||
--------------------
|
||||
|
||||
* #6742: ``end-before`` option of :rst:dir:`literalinclude` directive does not
|
||||
match the first line of the code block.
|
||||
|
||||
Deprecated
|
||||
----------
|
||||
|
||||
|
@ -348,7 +348,7 @@ class LiteralIncludeReader:
|
||||
return lines[:lineno + 1]
|
||||
else:
|
||||
if lineno == 0:
|
||||
return []
|
||||
pass # end-before ignores first line
|
||||
else:
|
||||
return lines[:lineno]
|
||||
if inclusive is True:
|
||||
|
@ -206,6 +206,14 @@ def test_LiteralIncludeReader_missing_start_and_end(literal_inc_path):
|
||||
content, lines = reader.read()
|
||||
|
||||
|
||||
def test_LiteralIncludeReader_end_before(literal_inc_path):
|
||||
options = {'end-before': 'nclud'} # *nclud* matches first and third lines.
|
||||
reader = LiteralIncludeReader(literal_inc_path, options, DUMMY_CONFIG)
|
||||
content, lines = reader.read()
|
||||
assert content == ("# Literally included file using Python highlighting\n"
|
||||
"\n")
|
||||
|
||||
|
||||
@pytest.mark.xfail(os.name != 'posix', reason="Not working on windows")
|
||||
def test_LiteralIncludeReader_prepend(literal_inc_path):
|
||||
options = {'lines': '1', 'prepend': 'Hello', 'append': 'Sphinx'}
|
||||
|
Loading…
Reference in New Issue
Block a user