Rouge in Rails v6 CSS failing

40 Views Asked by At

Here are the steps I've taken to setup Rouge in my Ruby on Rails app (following the steps listed here and here).

Added gem 'rouge' to Gemfile.

bundle in terminal.

Added @import "rouge"; to app/assets/stylesheets/application.css

Created the helper app/helpers/rouge_helper.rb with the following contents.

module RougeHelper
  def rouge(text, language)
    formatter = Rouge::Formatters::HTML.new(css_class: 'highlight')
    lexer = Rouge::Lexer.find(language)
    formatter.format(lexer.lex(text))
  end
end

Added <%= raw rouge("def rouge_me\n puts 'hey!'\nend", "ruby") %> to my view.

The page loads with no errors and the HTML of the text is formatted as follows. However inspect isn't revealing any styles being applied by the generated classes ("k", "nf", "nb" and "s1").

<span class="k">def</span> 
<span class="nf">rouge_me</span>
  <span class="nb">puts</span> 
<span class="s1">'hey!'</span>
<span class="k">end</span>

How do I get these styles applied?

0

There are 0 best solutions below