Commits

Anonymous committed 59aff1b

FIX 873 Ruby 1.9 hash syntax, symbol with underscore as key not highlighted properly

Bugreport: https://bitbucket.org/birkenfeld/pygments-main/issue/873/ruby-19-hash-syntax-symbol-with-underscore
Example: https://gist.github.com/rmetzler/7833554

  • Participants
  • Parent commits 9246d7a

Comments (0)

Files changed (2)

pygments/lexers/agile.py

             (r":'(\\\\|\\'|[^'])*'", String.Symbol),
             (r"'(\\\\|\\'|[^'])*'", String.Single),
             (r':"', String.Symbol, 'simple-sym'),
-            (r'([a-zA-Z_][a-zA-Z0-9]*)(:)(?!:)',
+            (r'([a-zA-Z_][a-zA-Z0-9_]*)(:)(?!:)',
              bygroups(String.Symbol, Punctuation)),  # Since Ruby 1.9
             (r'"', String.Double, 'simple-string'),
             (r'(?<!\.)`', String.Backtick, 'simple-backtick'),

tests/examplefiles/hash_syntax.rb

+{ :old_syntax => 'ok' }
+{ 'stings as key' => 'should be ok' }
+{ new_syntax: 'broken until now' }
+{ withoutunderscore: 'should be ok' }
+{ _underscoreinfront: 'might be ok, if I understand the pygments code correct' }