| 557 | return self.escape(cram(stripid(repr(x)), self.maxother)) |
| 558 | |
| 559 | def repr_string(self, x, level): |
| 560 | test = cram(x, self.maxstring) |
| 561 | testrepr = repr(test) |
| 562 | if '\\' in test and '\\' not in replace(testrepr, r'\\', ''): |
| 563 | # Backslashes are only literal in the string and are never |
| 564 | # needed to make any special characters, so show a raw string. |
| 565 | return 'r' + testrepr[0] + self.escape(test) + testrepr[0] |
| 566 | return re.sub(r'((\\[\\abfnrtv\'"]|\\[0-9]..|\\x..|\\u....)+)', |
| 567 | r'<span class="repr">\1</span>', |
| 568 | self.escape(testrepr)) |
| 569 | |
| 570 | repr_str = repr_string |
| 571 | |