Add backslash continuation characters if the row has increased without encountering a newline token. This also inserts the correct amount of whitespace before the backslash.
(self, start)
| 183 | self.tokens.append(" " * col_offset) |
| 184 | |
| 185 | def add_backslash_continuation(self, start): |
| 186 | """Add backslash continuation characters if the row has increased |
| 187 | without encountering a newline token. |
| 188 | |
| 189 | This also inserts the correct amount of whitespace before the backslash. |
| 190 | """ |
| 191 | row = start[0] |
| 192 | row_offset = row - self.prev_row |
| 193 | if row_offset == 0: |
| 194 | return |
| 195 | |
| 196 | newline = '\r\n' if self.prev_line.endswith('\r\n') else '\n' |
| 197 | line = self.prev_line.rstrip('\\\r\n') |
| 198 | ws = ''.join(_itertools.takewhile(str.isspace, reversed(line))) |
| 199 | self.tokens.append(ws + f"\\{newline}" * row_offset) |
| 200 | self.prev_col = 0 |
| 201 | |
| 202 | def escape_brackets(self, token): |
| 203 | characters = [] |
no test coverage detected