Skip to content

Commit 71d1962

Browse files
committed
whoops. forgot about pypy.
1 parent 8938421 commit 71d1962

1 file changed

Lines changed: 31 additions & 12 deletions

File tree

textile/regex_strings.py

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,37 @@
33

44
import six
55

6-
import regex as re
7-
upper_re_s = r'\p{Lu}'
8-
regex_snippets = {
9-
'acr': r'\p{Lu}\p{Nd}',
10-
'abr': r'\p{Lu}',
11-
'nab': r'\p{Ll}',
12-
'wrd': r'(?:\p{L}|\p{M}|\p{N}|\p{Pc})',
13-
'cur': r'\p{Sc}',
14-
'digit': r'\p{N}',
15-
'space': r'(?:\p{Zs}|\v)',
16-
'char': r'(?:[^\p{Zs}\v])',
17-
}
6+
try:
7+
# Use regex module for matching uppercase characters if installed,
8+
# otherwise fall back to finding all the uppercase chars in a loop.
9+
import regex as re
10+
upper_re_s = r'\p{Lu}'
11+
regex_snippets = {
12+
'acr': r'\p{Lu}\p{Nd}',
13+
'abr': r'\p{Lu}',
14+
'nab': r'\p{Ll}',
15+
'wrd': r'(?:\p{L}|\p{M}|\p{N}|\p{Pc})',
16+
'cur': r'\p{Sc}',
17+
'digit': r'\p{N}',
18+
'space': r'(?:\p{Zs}|\v)',
19+
'char': r'(?:[^\p{Zs}\v])',
20+
}
21+
except ImportError:
22+
import re
23+
from sys import maxunicode
24+
upper_re_s = "".join(
25+
[six.unichr(c) for c in six.moves.range(maxunicode) if six.unichr(
26+
c).isupper()])
27+
regex_snippets = {
28+
'acr': r'{0}0-9'.format(upper_re_s),
29+
'abr': r'{0}'.format(upper_re_s),
30+
'nab': r'a-z',
31+
'wrd': r'\w',
32+
'cur': r'',
33+
'digit': r'\d',
34+
'space': r'(?:\s|\v)',
35+
'char': r'\S',
36+
}
1837

1938
halign_re_s = r'(?:\<(?!>)|(?<!<)\>|\<\>|\=|[()]+(?! ))'
2039
valign_re_s = r'[\-^~]'

0 commit comments

Comments
 (0)