diff options
author | Latosha Maltba <79100569+latosha-maltba@users.noreply.github.com> | 2021-09-21 09:19:55 +0000 |
---|---|---|
committer | Latosha Maltba <79100569+latosha-maltba@users.noreply.github.com> | 2021-09-21 09:19:55 +0000 |
commit | 3b9ecf95dec5a7ea7447b7502a74082d6962d070 (patch) | |
tree | a50ca9175aa416155d6121966b93bcee1d6f7296 /sphinx/directives/code.py | |
parent | 3b4655310ff2e7521cd9fc73385510cba60512f3 (diff) | |
download | sphinx-git-3b9ecf95dec5a7ea7447b7502a74082d6962d070.tar.gz |
Fix: 9636: code-block: Do not remove newlines with :dedent:
If the option :dedent: (without numeric argument) was given to
code-block then all newlines where striped from the resulting code.
Preserve newlines when stripping common whitespace at the beginning of
code blocks.
Diffstat (limited to 'sphinx/directives/code.py')
-rw-r--r-- | sphinx/directives/code.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py index 5859f359a..2d3c87be9 100644 --- a/sphinx/directives/code.py +++ b/sphinx/directives/code.py @@ -58,7 +58,7 @@ class Highlight(SphinxDirective): def dedent_lines(lines: List[str], dedent: int, location: Tuple[str, int] = None) -> List[str]: if dedent is None: - return textwrap.dedent(''.join(lines)).splitlines(True) + return textwrap.dedent('\n'.join(lines)).split('\n') if any(s[:dedent].strip() for s in lines): logger.warning(__('non-whitespace stripped by dedent'), location=location) |