<c=rrggbb>
in your string and it will be parsed in color.
html = CodeRay.scan(text, language).span(line_numbers: :inline)
# remove unsupported properties
html.gsub! '<span class="CodeRay">', ''
html.gsub! /<\/span>\z/, ''
html.gsub! /font-weight:bold/, ''
# convert inline styles to Gosu compatible color tags
html.gsub! /<span style="background-color:hsla.*?">/, '<c=FFFFFF>'
html.gsub! /<span class="line-numbers">(?<space> )?(<strong>)?<a href="#n\d+?" name="n\d+?">(?<number>\d+?)<\/a>(<\/strong>)?(<\/span>)?/, '\k<space>\k<number> '
html.gsub! /<span style="color:#([0-9a-fA-F]{3});?">/ do |m|
color = $1.chars.map{|s|s*2}.join
"<c=#{color}>"
end
html.gsub! '</span>', '</c>'
html.gsub! '"', '"'
Image#from_text
and Font#draw
? rdoc/yard are not exactly helpful for this kind of stuff. :( I agree though, it's just hard to get started with all the documentation that's stlll pending...
Image#from_text
and Font#draw
) are suitable for this. Small note that it allows the use of XML's <c>,<u>,<i> and what else
tags. Definitely better than no information at all, I'd say.
Font#draw
; add a "see also" to Image#from_text
with a note saying that that method supports the same formatting codes.<b>bold <i>bold-italic</b> italic</i>
is perfectly valid.
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill