Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
RI Rouge
# Usage:
#
# RUBYOPT='-r ./to_rouge' RI_ROUGE=monokai.sublime \
# ri --format=rouge Class.methods
require 'rdoc'
require 'rouge'
module RDoc
class Markup
class ToRouge < Markup::ToAnsi
def initialize(*)
super
theme = Rouge::Theme.find(ENV['RI_ROUGE'] || 'thankful_eyes').new
@rouge_lexer = Rouge::Lexer.find('ruby')
@rouge_formatter = Rouge::Formatters::Terminal256.new(theme)
end
def rougify(string)
@rouge_formatter.format(@rouge_lexer.lex(string))
end
def accept_verbatim(verbatim)
indent = ' ' * (@indent + 2)
verbatim.parts.each do |part|
@res << indent unless part == "\n"
@res << rougify(part)
end
@res << "\n" unless @res =~ /\n\z/
end
end
end
end
Owner

arika commented Nov 14, 2017

ri-rouge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment