mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #3755: incorrectly warns about dedent with literalinclude
This commit is contained in:
parent
ec50d014ee
commit
dabd356f8e
1
CHANGES
1
CHANGES
@ -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
|
||||
--------
|
||||
|
@ -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):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user