| 621 | return self.escape(cram(stripid(repr(x)), self.maxother)) |
| 622 | |
| 623 | def repr_string(self, x, level): |
| 624 | test = cram(x, self.maxstring) |
| 625 | testrepr = repr(test) |
| 626 | if '\\' in test and '\\' not in replace(testrepr, r'\\', ''): |
| 627 | # Backslashes are only literal in the string and are never |
| 628 | # needed to make any special characters, so show a raw string. |
| 629 | return 'r' + testrepr[0] + self.escape(test) + testrepr[0] |
| 630 | return re.sub(r'((\\[\\abfnrtv\'"]|\\[0-9]..|\\x..|\\u....)+)', |
| 631 | r'<span class="repr">\1</span>', |
| 632 | self.escape(testrepr)) |
| 633 | |
| 634 | repr_str = repr_string |
| 635 | |