5712:f0d08bdeacf4 | 5713:6762afd9f963 |
---|---|
3 pygments.modeline | 3 pygments.modeline |
4 ~~~~~~~~~~~~~~~~~ | 4 ~~~~~~~~~~~~~~~~~ |
5 | 5 |
6 A simple modeline parser (based on pymodeline). | 6 A simple modeline parser (based on pymodeline). |
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 | 13 |
33 lines = buf.splitlines() | 33 lines = buf.splitlines() |
34 for l in lines[-1:-max_lines-1:-1]: | 34 for l in lines[-1:-max_lines-1:-1]: |
35 ret = get_filetype_from_line(l) | 35 ret = get_filetype_from_line(l) |
36 if ret: | 36 if ret: |
37 return ret | 37 return ret |
38 for l in lines[max_lines:-1:-1]: | 38 for i in range(max_lines, -1, -1): |
39 ret = get_filetype_from_line(l) | 39 if i < len(lines): |
40 if ret: | 40 ret = get_filetype_from_line(lines[i]) |
41 return ret | 41 if ret: |
42 return ret | |
42 | 43 |
43 return None | 44 return None |