rouge-ruby / rouge

A pure Ruby code highlighter that is compatible with Pygments
https://rouge.jneen.net/
Other
3.3k stars 732 forks source link

Comments not highlighted correctly in Makefiles #2055

Open jwbargsten opened 2 weeks ago

jwbargsten commented 2 weeks ago

Name of the lexer make

Code sample

build: clean ## build the package
  python -m build

https://rouge.jneen.net/v4.3.0/make/YnVpbGQ6IGNsZWFuICMgYnVpbGQgdGhlIHBhY2thZ2UKCXB5dGhvbiAtbSBidWlsZAo

Additional context In the make.rb lexer, the Comment rule in the state :block_header block should be greedy

--- lib/rouge/lexers/make.rb    2024-06-16 12:56:19.968821924 +0200
+++ lib/rouge/lexers/make.fixed.rb  2024-06-16 12:56:32.721847441 +0200
@@ -81,7 +81,7 @@
       state :block_header do
         rule %r/[^,\\\n#]+/, Name::Function
         rule %r/,/, Punctuation
-        rule %r/#.*?/, Comment
+        rule %r/#.*/, Comment
         rule %r/\\\n/, Text
         rule %r/\\./, Text
         rule %r/\n/ do