Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeRay stylesheet

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?

like image 953
Dmitry Avatar asked Feb 21 '23 02:02

Dmitry


1 Answers

The coderay command installed along with the CodeRay gem can print out a stylesheet for you.

$ coderay stylesheet > coderay.css

Or you could do something with it in code maybe.

require 'coderay'

style = CodeRay::Encoders[:html]::CSS.new(:default).stylesheet
puts style
like image 187
Mike Steinert Avatar answered Feb 27 '23 05:02

Mike Steinert