Fix #3755: incorrectly warns about dedent with literalinclude

This commit is contained in:
Takeshi KOMIYA 2017-05-19 00:25:23 +09:00
parent ec50d014ee
commit dabd356f8e
2 changed files with 10 additions and 6 deletions

View File

@ -16,6 +16,7 @@ Bugs fixed
* #3754: HTML builder crashes if HTML theme appends own stylesheets
* #3756: epub: Entity 'mdash' not defined
* #3758: Sphinx crashed if logs are emitted in conf.py
* #3755: incorrectly warns about dedent with literalinclude
Testing
--------

View File

@ -209,11 +209,7 @@ class LiteralIncludeReader(object):
if 'tab-width' in self.options:
text = text.expandtabs(self.options['tab-width'])
lines = text.splitlines(True)
if 'dedent' in self.options:
return dedent_lines(lines, self.options.get('dedent'), location=location)
else:
return lines
return text.splitlines(True)
except (IOError, OSError):
raise IOError(_('Include file %r not found or reading it failed') % filename)
except UnicodeError:
@ -231,7 +227,8 @@ class LiteralIncludeReader(object):
self.end_filter,
self.lines_filter,
self.prepend_filter,
self.append_filter]
self.append_filter,
self.dedent_filter]
lines = self.read_file(self.filename, location=location)
for func in filters:
lines = func(lines, location=location)
@ -367,6 +364,12 @@ class LiteralIncludeReader(object):
return lines
def dedent_filter(self, lines, location=None):
if 'dedent' in self.options:
return dedent_lines(lines, self.options.get('dedent'), location=location)
else:
return lines
class LiteralInclude(Directive):
"""