Commit 7bef6c0
docs(text): document whitespace-stripped indexing in Text (#4866)
* docs(text): document whitespace-stripped indexing in Text
Text.__init__ strips spaces/newlines from self.text and never creates
submobjects for whitespace, so slicing (text[a:b]) and the t2c/t2s/t2w/t2f/t2g
'[a:b]' syntax silently index into that stripped copy rather than the
original string, with no warning. Add a docstring callout explaining this and
pointing to substring-keyed t2c/etc. as the unaffected alternative.
Refs #4864
* docs(text): fix t2c/t2s/etc slice-index whitespace claim
Reviewer (chopan050) pointed out on PR #4866 that t2c/t2s/t2w/t2f/t2g
slice syntax (e.g. t2c={'[3:7]': RED}) indexes into the original text
with whitespace included, not the whitespace-stripped text as the
previous wording implied -- the opposite of how direct object slicing
(my_text[3:5]) behaves. Verified both behaviors empirically and
reworded the warning to describe each convention correctly.
---------
Co-authored-by: Francisco Manríquez Novoa <49853152+chopan050@users.noreply.github.com>1 parent 4d25c03 commit 7bef6c0
1 file changed
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
305 | 305 | | |
306 | 306 | | |
307 | 307 | | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
308 | 331 | | |
309 | 332 | | |
310 | 333 | | |
| |||
0 commit comments