summaryrefslogtreecommitdiff
path: root/pygments
diff options
context:
space:
mode:
authorThomas Aglassinger <roskakori@users.sourceforge.net>2020-08-23 16:36:14 +0200
committerGitHub <noreply@github.com>2020-08-23 16:36:14 +0200
commit2a762c5fe655a3b3ecc9c52422300b9430110758 (patch)
treef3497d0b95cb2f699182c67ea83dd73bb77d107b /pygments
parent90555f7e73ccf9858d0cda7cb31b9fb727bf5adf (diff)
downloadpygments-git-2a762c5fe655a3b3ecc9c52422300b9430110758.tar.gz
Fix cmake header (#1491)
* Fixed guessing of CMake by header. * Version number can have multiple digits. * Tabs are handled as white space. * Trailing comments are ignored. * Cleaned up regex to detect CMake header.
Diffstat (limited to 'pygments')
-rw-r--r--pygments/lexers/make.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/pygments/lexers/make.py b/pygments/lexers/make.py
index 121db1c2..5f65afcc 100644
--- a/pygments/lexers/make.py
+++ b/pygments/lexers/make.py
@@ -196,7 +196,12 @@ class CMakeLexer(RegexLexer):
}
def analyse_text(text):
- exp = r'^ *CMAKE_MINIMUM_REQUIRED *\( *VERSION *\d(\.\d)* *( FATAL_ERROR)? *\) *$'
+ exp = (
+ r'^[ \t]*CMAKE_MINIMUM_REQUIRED[ \t]*'
+ r'\([ \t]*VERSION[ \t]*\d+(\.\d+)*[ \t]*'
+ r'([ \t]FATAL_ERROR)?[ \t]*\)[ \t]*'
+ r'(#[^\n]*)?$'
+ )
if re.search(exp, text, flags=re.MULTILINE | re.IGNORECASE):
return 0.8
return 0.0