lib/linguist/strategy/modeline.rb in github-linguist-6.1.0 vs lib/linguist/strategy/modeline.rb in github-linguist-6.2.0

- old
+ new

@@ -34,11 +34,11 @@ VIM_MODELINE = / # Start modeline. Could be `vim:`, `vi:` or `ex:` (?: - (?:\s|^) + (?:[ \t]|^) vi (?:m[<=>]?\d+|m)? # Version-specific modeline | [\t\x20] # `ex:` requires whitespace, because "ex:" might be short for "example:" ex @@ -47,50 +47,50 @@ # If the option-list begins with `set ` or `se `, it indicates an alternative # modeline syntax partly-compatible with older versions of Vi. Here, the colon # serves as a terminator for an option sequence, delimited by whitespace. (?= # So we have to ensure the modeline ends with a colon - : (?=\s* set? \s [^\n:]+ :) | + : (?=[ \t]* set? [ \t] [^\n:]+ :) | # Otherwise, it isn't valid syntax and should be ignored - : (?!\s* set? \s) + : (?![ \t]* set? [ \t]) ) # Possible (unrelated) `option=value` pairs to skip past (?: # Option separator. Vim uses whitespace or colons to separate options (except if # the alternate "vim: set " form is used, where only whitespace is used) (?: - \s + [ \t] | - \s* : \s* # Note that whitespace around colons is accepted too: - ) # vim: noai : ft=ruby:noexpandtab + [ \t]* : [ \t]* # Note that whitespace around colons is accepted too: + ) # vim: noai : ft=ruby:noexpandtab # Option's name. All recognised Vim options have an alphanumeric form. \w* # Possible value. Not every option takes an argument. (?: # Whitespace between name and value is allowed: `vim: ft =ruby` - \s*= + [ \t]*= # Option's value. Might be blank; `vim: ft= ` says "use no filetype". (?: - [^\\\s] # Beware of escaped characters: titlestring=\ ft=ruby - | # will be read by Vim as { titlestring: " ft=ruby" }. + [^\\[ \t]] # Beware of escaped characters: titlestring=\ ft=ruby + | # will be read by Vim as { titlestring: " ft=ruby" }. \\. )* )? )* # The actual filetype declaration - [\s:] (?:filetype|ft|syntax) \s*= + [[ \t]:] (?:filetype|ft|syntax) [ \t]*= # Language's name (\w+) # Ensure it's followed by a legal separator - (?=\s|:|$) + (?=[ \t]|:|$) /xi MODELINES = [EMACS_MODELINE, VIM_MODELINE] # Scope of the search for modelines