Skip to content

Commit

Permalink
Preserve leading whitespace for wrapped list items.
Browse files Browse the repository at this point in the history
The previous implementation indented subsequent wrapped lines by
transforming the entire initial prefix into spaces.
This implementation detects the leading whitespace present in the
initial prefix, and uses the same whitespace (be it tabs, spaces, or
some combination thereof) to indent subsequent lines.
The non-whitespace portion of the initial prefix is still transformed
into spaces as before.
  • Loading branch information
Anaminus committed Jul 19, 2016
1 parent 4b23a5c commit 0797893
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion wrap_plus.py
Expand Up @@ -544,7 +544,9 @@ def _extract_prefix(self, paragraph_r, lines, required_comment_prefix):
m = list_pattern.match(first_line)
if m:
initial_prefix = first_line[0:m.end()]
subsequent_prefix = ' '*self._width_in_spaces(initial_prefix)
stripped_prefix = initial_prefix.lstrip()
leading_whitespace = initial_prefix[:len(initial_prefix)-len(stripped_prefix)]
subsequent_prefix = leading_whitespace+' '*self._width_in_spaces(stripped_prefix)
else:
m = field_pattern.match(first_line)
if m:
Expand Down

0 comments on commit 0797893

Please sign in to comment.