3 pygments.util |
3 pygments.util |
4 ~~~~~~~~~~~~~ |
4 ~~~~~~~~~~~~~ |
5 |
5 |
6 Utility functions. |
6 Utility functions. |
7 |
7 |
8 :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS. |
8 :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS. |
9 :license: BSD, see LICENSE for details. |
9 :license: BSD, see LICENSE for details. |
10 """ |
10 """ |
11 |
11 |
12 import re |
12 import re |
13 import sys |
13 import sys |
14 |
14 |
15 |
15 |
16 split_path_re = re.compile(r'[/\\ ]') |
16 split_path_re = re.compile(r'[/\\ ]') |
17 doctype_lookup_re = re.compile(r'''(?smx) |
17 doctype_lookup_re = re.compile(r''' |
18 (<\?.*?\?>)?\s* |
18 (<\?.*?\?>)?\s* |
19 <!DOCTYPE\s+( |
19 <!DOCTYPE\s+( |
20 [a-zA-Z_][a-zA-Z0-9]* |
20 [a-zA-Z_][a-zA-Z0-9]* |
21 (?: \s+ # optional in HTML5 |
21 (?: \s+ # optional in HTML5 |
22 [a-zA-Z_][a-zA-Z0-9]*\s+ |
22 [a-zA-Z_][a-zA-Z0-9]*\s+ |
23 "[^"]*")? |
23 "[^"]*")? |
24 ) |
24 ) |
25 [^>]*> |
25 [^>]*> |
26 ''') |
26 ''', re.DOTALL | re.MULTILINE | re.VERBOSE) |
27 tag_re = re.compile(r'<(.+?)(\s.*?)?>.*?</.+?>(?uism)') |
27 tag_re = re.compile(r'<(.+?)(\s.*?)?>.*?</.+?>', |
|
28 re.UNICODE | re.IGNORECASE | re.DOTALL | re.MULTILINE) |
28 xml_decl_re = re.compile(r'\s*<\?xml[^>]*\?>', re.I) |
29 xml_decl_re = re.compile(r'\s*<\?xml[^>]*\?>', re.I) |
29 |
30 |
30 |
31 |
31 class ClassNotFound(ValueError): |
32 class ClassNotFound(ValueError): |
32 """Raised if one of the lookup functions didn't find a matching class.""" |
33 """Raised if one of the lookup functions didn't find a matching class.""" |