diff options
author | Kornelius Kalnbach <murphy@rubychan.de> | 2013-08-30 17:11:54 +0200 |
---|---|---|
committer | Kornelius Kalnbach <murphy@rubychan.de> | 2013-08-30 17:11:54 +0200 |
commit | 3fc55739f9f4710f13c33ec1ea7e8046a20af611 (patch) | |
tree | 8ed60f88ce13c52e743ee5a5dd8c6a05e599e176 /lib/coderay/encoders/html.rb | |
parent | cc3185f6864ed2e8d537ec4100d7fcc4abc8f312 (diff) | |
parent | 718c0ac901eef189a1dad36f57a78f36d9d0ba11 (diff) | |
download | coderay-3fc55739f9f4710f13c33ec1ea7e8046a20af611.tar.gz |
Merge branch 'master' into ruby-skip
Diffstat (limited to 'lib/coderay/encoders/html.rb')
-rw-r--r-- | lib/coderay/encoders/html.rb | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/coderay/encoders/html.rb b/lib/coderay/encoders/html.rb index 20f2409..d2ebb5a 100644 --- a/lib/coderay/encoders/html.rb +++ b/lib/coderay/encoders/html.rb @@ -197,13 +197,15 @@ module Encoders @last_opened = nil end - @out.extend Output - @out.css = @css - if options[:line_numbers] - Numbering.number! @out, options[:line_numbers], options + if @out.respond_to? :to_str + @out.extend Output + @out.css = @css + if options[:line_numbers] + Numbering.number! @out, options[:line_numbers], options + end + @out.wrap! options[:wrap] + @out.apply_title! options[:title] end - @out.wrap! options[:wrap] - @out.apply_title! options[:title] if defined?(@real_out) && @real_out @real_out << @out @@ -285,7 +287,7 @@ module Encoders def make_span_for_kinds method, hint Hash.new do |h, kinds| - h[kinds.is_a?(Symbol) ? kinds : kinds.dup] = begin + begin css_class = css_class_for_kinds(kinds) title = HTML.token_path_to_hint hint, kinds if hint @@ -297,6 +299,9 @@ module Encoders "<span#{title}#{" class=\"#{css_class}\"" if css_class}>" end end + end.tap do |span| + h.clear if h.size >= 100 + h[kinds] = span end end end @@ -309,8 +314,8 @@ module Encoders def break_lines text, style reopen = '' - @opened.each_with_index do |k, index| - reopen << (@span_for_kinds[index > 0 ? [k, *@opened[0...index]] : k] || '<span>') + @opened.each_with_index do |kind, index| + reopen << (@span_for_kinds[index > 0 ? [kind, *@opened[0...index]] : kind] || '<span>') end text.gsub("\n", "#{'</span>' * @opened.size}#{'</span>' if style}\n#{reopen}#{style}") end |