Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,

i.e. do *not* expand tabs, but treat them as whitespace that is not
equivalent to spaces.  Add a couple of test cases.  Clarify docs.
This commit is contained in:
Greg Ward 2006-06-11 00:40:49 +00:00
parent 0e1159583c
commit 7f54740c4d
4 changed files with 107 additions and 43 deletions

View file

@ -47,12 +47,17 @@ remove indentation from strings that have unwanted whitespace to the
left of the text.
\begin{funcdesc}{dedent}{text}
Remove any whitespace that can be uniformly removed from the left
of every line in \var{text}.
Remove any common leading whitespace from every line in \var{text}.
This is typically used to make triple-quoted strings line up with
the left edge of screen/whatever, while still presenting it in the
source code in indented form.
This can be used to make triple-quoted strings line up with the left
edge of the display, while still presenting them in the source code
in indented form.
Note that tabs and spaces are both treated as whitespace, but they are
not equal: the lines \code{" {} hello"} and \code{"\textbackslash{}thello"}
are considered to have no common leading whitespace. (This behaviour is
new in Python 2.5; older versions of this module incorrectly expanded
tabs before searching for common leading whitespace.)
For example:
\begin{verbatim}