diff options
author | murphy <murphy@rubychan.de> | 2011-05-21 02:59:16 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2011-05-21 02:59:16 +0000 |
commit | c5a193f08ddef1ba1cb5e1f9b0789b2f587022c4 (patch) | |
tree | 9f4589fd94a5b4a3b9878e9db24e282a45a79600 /lib/coderay/encoders/html.rb | |
parent | ee832fcfbec96c7532fc60dcb31b4928c1373e3f (diff) | |
download | coderay-c5a193f08ddef1ba1cb5e1f9b0789b2f587022c4.tar.gz |
#299 fix transparent tokens
Diffstat (limited to 'lib/coderay/encoders/html.rb')
-rw-r--r-- | lib/coderay/encoders/html.rb | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/coderay/encoders/html.rb b/lib/coderay/encoders/html.rb index d6dfb9e..67d487c 100644 --- a/lib/coderay/encoders/html.rb +++ b/lib/coderay/encoders/html.rb @@ -147,18 +147,14 @@ module Encoders # # +hint+ may be :info, :info_long or :debug. def self.token_path_to_hint hint, kinds - # FIXME: TRANSPARENT_TOKEN_KINDS? - # if TRANSPARENT_TOKEN_KINDS.include? kinds.first - # kinds = kinds[1..-1] - # else - # kinds = kinds[1..-1] + kinds.first - # end + kinds = Array kinds title = case hint when :info - TOKEN_KIND_TO_INFO[Array(kinds).first] + kinds = kinds[1..-1] if TRANSPARENT_TOKEN_KINDS.include? kinds.first + TOKEN_KIND_TO_INFO[kinds.first] when :info_long - kinds.map { |kind| TOKEN_KIND_TO_INFO[kind] }.join('/') + kinds.reverse.map { |kind| TOKEN_KIND_TO_INFO[kind] }.join('/') when :debug kinds.inspect end @@ -178,7 +174,7 @@ module Encoders hint = options[:hint] if hint && ![:debug, :info, :info_long].include?(hint) raise ArgumentError, "Unknown value %p for :hint; \ - expected :info, :debug, false, or nil." % hint + expected :info, :info_long, :debug, false, or nil." % hint end css_classes = TokenKinds @@ -212,6 +208,8 @@ module Encoders else raise ArgumentError, "Unknown value %p for :css." % options[:css] end + + @set_last_opened = options[:hint] || options[:css] == :style end def finish options @@ -249,7 +247,7 @@ module Encoders def begin_group kind @out << (@span_for_kind[@last_opened ? [kind, *@opened] : kind] || '<span>') @opened << kind - @last_opened = kind if @options[:css] == :style + @last_opened = kind if @set_last_opened end def end_group kind |