require 'coderay'
puts CodeRay.scan('puts "Hello, world!"', :ruby).page这段代码将打印整个带有CSS(类)的HTML页面。
我只能使用CodeRay.scan('puts "Hello, world!"', :ruby).div打印彩色代码
如何仅打印CSS部件?
CodeRay::Encoders::HTML::Output中有stylesheet方法,但如何调用呢?
发布于 2012-06-28 07:34:40
与CodeRay gem一起安装的coderay命令可以打印出一个样式表。
$ coderay stylesheet > coderay.css或者你可以在代码中用它做点什么。
require 'coderay'
style = CodeRay::Encoders[:html]::CSS.new(:default).stylesheet
puts stylehttps://stackoverflow.com/questions/11157105
复制相似问题