diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2022-01-15 20:35:21 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2022-01-15 20:35:21 +0900 |
commit | ff54f97aba881f31359d983d1e82c63199886768 (patch) | |
tree | 2b6317ca8377ffbdce0eeb7745c82a3a3fd2fd26 /sphinx/directives | |
parent | e2f141620d11e931f0dd94a4690b341ad37d334c (diff) | |
download | sphinx-git-ff54f97aba881f31359d983d1e82c63199886768.tar.gz |
code-block: Pass list of strings ends with CR code to dedent_lines()
Diffstat (limited to 'sphinx/directives')
-rw-r--r-- | sphinx/directives/code.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py index 046916bde..ddd47e1f8 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('\n'.join(lines)).split('\n') + return textwrap.dedent(''.join(lines)).splitlines(True) if any(s[:dedent].strip() for s in lines): logger.warning(__('non-whitespace stripped by dedent'), location=location) @@ -138,9 +138,9 @@ class CodeBlock(SphinxDirective): if 'dedent' in self.options: location = self.state_machine.get_source_and_line(self.lineno) - lines = code.split('\n') + lines = code.splitlines(True) lines = dedent_lines(lines, self.options['dedent'], location=location) - code = '\n'.join(lines) + code = ''.join(lines) literal: Element = nodes.literal_block(code, code) if 'linenos' in self.options or 'lineno-start' in self.options: |