From 3fe23597ee70be1f5fef18bab85e2175a3222c73 Mon Sep 17 00:00:00 2001 From: Alexander Olofsson Date: Wed, 25 Apr 2018 13:11:19 +0200 Subject: [PATCH 1/2] ERB: Fix greedy comment matching Fixes #900 --- lib/rouge/lexers/erb.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rouge/lexers/erb.rb b/lib/rouge/lexers/erb.rb index b2883b097c..0757b87466 100644 --- a/lib/rouge/lexers/erb.rb +++ b/lib/rouge/lexers/erb.rb @@ -37,7 +37,7 @@ def initialize(opts={}) state :comment do rule close, Comment, :pop! - rule /.+(?=#{close})|.+/m, Comment + rule /.+?(?=#{close})|.+/m, Comment end state :ruby do From cce1bc66f14eef8fbf66329d441e2bc077d75eff Mon Sep 17 00:00:00 2001 From: "Alexander \"Ace\" Olofsson" Date: Thu, 14 Jun 2018 09:35:51 +0200 Subject: [PATCH 2/2] ERB: Add an example of broken comments --- spec/visual/samples/erb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/visual/samples/erb b/spec/visual/samples/erb index f29cde87bd..67ade6e4bb 100644 --- a/spec/visual/samples/erb +++ b/spec/visual/samples/erb @@ -13,6 +13,7 @@ <% end %> +<%# Sometimes you just need to use a variable or two %> <% header_tag = 'h1' %> <<%= header_tag %>>