summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Hatch <tim@timhatch.com>2012-08-27 00:14:25 -0700
committerTim Hatch <tim@timhatch.com>2012-08-27 00:14:25 -0700
commitafae5cb55704e3fa0ec16c9ba8c3fc0c88fe94da (patch)
treea5cdec2afd1aaf72947a715c30f8cb79f8ce4c3c
parent7c1a88061b3e70e00c99fff8b4e1ca5fb9236b61 (diff)
downloadpygments-afae5cb55704e3fa0ec16c9ba8c3fc0c88fe94da.tar.gz
Also escape regex metachars in unistring.
-rw-r--r--pygments/unistring.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/pygments/unistring.py b/pygments/unistring.py
index e79e143e..06cb9560 100644
--- a/pygments/unistring.py
+++ b/pygments/unistring.py
@@ -108,9 +108,12 @@ if __name__ == '__main__':
for code in range(65535):
c = unichr(code)
cat = unicodedata.category(c)
- # Hack to avoid combining this combining with the preceeding high
- # surrogate, 0xdbff, when doing a repr.
if ord(c) == 0xdc00:
+ # Hack to avoid combining this combining with the preceeding high
+ # surrogate, 0xdbff, when doing a repr.
+ c = u'\\' + c
+ elif ord(c) in (0x2d, 0x5c):
+ # Escape backslash itself and dash.
c = u'\\' + c
categories.setdefault(cat, []).append(c)