From: Jarret \Jax\ R. <jar...@pr...> - 2023-10-29 07:14:42
|
Support logical width for tab characters in the trim_left() function. --- docutils/docutils/statemachine.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docutils/docutils/statemachine.py b/docutils/docutils/statemachine.py index 167cb7744..4b482c57e 100644 --- a/docutils/docutils/statemachine.py +++ b/docutils/docutils/statemachine.py @@ -1324,13 +1324,16 @@ class StringList(ViewList): """A `ViewList` with string-specific methods.""" - def trim_left(self, length, start=0, end=sys.maxsize): + def trim_left(self, length, start=0, end=sys.maxsize, tab_width=8): """ - Trim `length` characters off the beginning of each item, in-place, - from index `start` to `end`. No whitespace-checking is done on the - trimmed text. Does not affect slice parent. + Trim `length` logical characters off the beginning of each item, + in-place, from index `start` to `end`. No whitespace-checking is done + on the trimmed text. Does not affect slice parent. + + A tab counts (depending on the column) for up to `tab_width` characters. + See `logical_rslice()` for details. """ - self.data[start:end] = [line[length:] + self.data[start:end] = [logical_rslice(line, length, tab_width) for line in self.data[start:end]] def get_text_block(self, start, flush_left=False): |