require 'coderay'
puts CodeRay.scan('puts "Hello, world!"', :ruby).page
This code will print full HTML page with CSS(classes).
I may print only colored code using CodeRay.scan('puts "Hello, world!"', :ruby).div
How can I print only CSS part?
There is stylesheet method in CodeRay::Encoders::HTML::Output, but how can I call it?
The
coderaycommand installed along with the CodeRay gem can print out a stylesheet for you.Or you could do something with it in code maybe.