eric6/ThirdParty/Pygments/pygments/util.py

changeset 7983
54c5cfbb1e29
parent 7701
25f42e208e08
equal deleted inserted replaced
7982:48d210e41c65 7983:54c5cfbb1e29
3 pygments.util 3 pygments.util
4 ~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~
5 5
6 Utility functions. 6 Utility functions.
7 7
8 :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2021 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
14 from io import TextIOWrapper 13 from io import TextIOWrapper
15 14
16 15
17 split_path_re = re.compile(r'[/\\ ]') 16 split_path_re = re.compile(r'[/\\ ]')
18 doctype_lookup_re = re.compile(r''' 17 doctype_lookup_re = re.compile(r'''
19 (<\?.*?\?>)?\s*
20 <!DOCTYPE\s+( 18 <!DOCTYPE\s+(
21 [a-zA-Z_][a-zA-Z0-9]* 19 [a-zA-Z_][a-zA-Z0-9]*
22 (?: \s+ # optional in HTML5 20 (?: \s+ # optional in HTML5
23 [a-zA-Z_][a-zA-Z0-9]*\s+ 21 [a-zA-Z_][a-zA-Z0-9]*\s+
24 "[^"]*")? 22 "[^"]*")?
175 eg: 'html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"' 173 eg: 'html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"'
176 """ 174 """
177 m = doctype_lookup_re.search(text) 175 m = doctype_lookup_re.search(text)
178 if m is None: 176 if m is None:
179 return False 177 return False
180 doctype = m.group(2) 178 doctype = m.group(1)
181 return re.compile(regex, re.I).match(doctype.strip()) is not None 179 return re.compile(regex, re.I).match(doctype.strip()) is not None
182 180
183 181
184 def html_doctype_matches(text): 182 def html_doctype_matches(text):
185 """Check if the file looks like it has a html doctype.""" 183 """Check if the file looks like it has a html doctype."""

eric ide

mercurial