| 576 | return self.escape(cram(stripid(repr(x)), self.maxother)) |
| 577 | |
| 578 | def repr_string(self, x, level): |
| 579 | test = cram(x, self.maxstring) |
| 580 | testrepr = repr(test) |
| 581 | if '\\' in test and '\\' not in replace(testrepr, r'\\', ''): |
| 582 | # Backslashes are only literal in the string and are never |
| 583 | # needed to make any special characters, so show a raw string. |
| 584 | return 'r' + testrepr[0] + self.escape(test) + testrepr[0] |
| 585 | return re.sub(r'((\\[\\abfnrtv\'"]|\\[0-9]..|\\x..|\\u....)+)', |
| 586 | r'<span class="repr">\1</span>', |
| 587 | self.escape(testrepr)) |
| 588 | |
| 589 | repr_str = repr_string |
| 590 | |