Merge pull request #10323 from tk0miya/10318_literalinclude_prepend_and_dedent

Fix #10318: literalinclude: :prepend: option working with :dedent:
This commit is contained in:
Takeshi KOMIYA
2022-04-03 20:13:39 +09:00
committed by GitHub
3 changed files with 17 additions and 2 deletions

View File

@@ -80,6 +80,8 @@ Bugs fixed
bulding texinfo document bulding texinfo document
* #10000: LaTeX: glossary terms with common definition are rendered with * #10000: LaTeX: glossary terms with common definition are rendered with
too much vertical whitespace too much vertical whitespace
* #10318: ``:prepend:`` option of :rst:dir:`literalinclude` directive does not
work with ``:dedent:`` option
Testing Testing
-------- --------

View File

@@ -224,9 +224,9 @@ class LiteralIncludeReader:
self.start_filter, self.start_filter,
self.end_filter, self.end_filter,
self.lines_filter, self.lines_filter,
self.dedent_filter,
self.prepend_filter, self.prepend_filter,
self.append_filter, self.append_filter]
self.dedent_filter]
lines = self.read_file(self.filename, location=location) lines = self.read_file(self.filename, location=location)
for func in filters: for func in filters:
lines = func(lines, location=location) lines = func(lines, location=location)

View File

@@ -251,6 +251,19 @@ def test_LiteralIncludeReader_dedent(literal_inc_path):
"\n") "\n")
@pytest.mark.xfail(os.name != 'posix', reason="Not working on windows")
def test_LiteralIncludeReader_dedent_and_append_and_prepend(literal_inc_path):
# dedent: 2
options = {'lines': '9-11', 'dedent': 2, 'prepend': 'class Foo:', 'append': '# comment'}
reader = LiteralIncludeReader(literal_inc_path, options, DUMMY_CONFIG)
content, lines = reader.read()
assert content == ("class Foo:\n"
" def baz():\n"
" pass\n"
"\n"
"# comment\n")
@pytest.mark.xfail(os.name != 'posix', reason="Not working on windows") @pytest.mark.xfail(os.name != 'posix', reason="Not working on windows")
def test_LiteralIncludeReader_tabwidth(testroot): def test_LiteralIncludeReader_tabwidth(testroot):
# tab-width: 4 # tab-width: 4