diff options
author | Kornelius Kalnbach <murphy@rubychan.de> | 2012-04-01 00:28:15 +0200 |
---|---|---|
committer | Kornelius Kalnbach <murphy@rubychan.de> | 2012-04-01 00:28:15 +0200 |
commit | df4e2bc7f7d8238f56e2d823aea707bfd860ad8f (patch) | |
tree | 30a7b7ef3f7ce47aeac0d8e0318525d52fb7bf15 /lib/coderay/encoders | |
parent | d68749d4473e3bafb88365cb27728cb61d28ca1d (diff) | |
download | coderay-df4e2bc7f7d8238f56e2d823aea707bfd860ad8f.tar.gz |
here come the white-space nazis
Diffstat (limited to 'lib/coderay/encoders')
-rw-r--r-- | lib/coderay/encoders/html.rb | 23 | ||||
-rw-r--r-- | lib/coderay/encoders/html/numbering.rb | 2 |
2 files changed, 13 insertions, 12 deletions
diff --git a/lib/coderay/encoders/html.rb b/lib/coderay/encoders/html.rb index 0d91cdf..2ec0f37 100644 --- a/lib/coderay/encoders/html.rb +++ b/lib/coderay/encoders/html.rb @@ -48,7 +48,7 @@ module Encoders # Default: 'CodeRay output' # # === :independent_lines - # Split multilines blocks into line-wide blocks. + # Split multiline blocks at line breaks. # Forced to true if :line_numbers option is set to :inline. # # Default: false @@ -105,8 +105,9 @@ module Encoders :style => :alpha, :wrap => nil, :title => 'CodeRay output', - - :independent_lines => false, + + :independent_lines => false, + :line_numbers => nil, :line_number_anchors => 'n', :line_number_start => 1, @@ -174,11 +175,11 @@ module Encoders @real_out = @out @out = '' end - + options[:independent_lines] = true if options[:line_numbers] == :inline - + @independent_lines = (options[:independent_lines] == true) - + @HTML_ESCAPE = HTML_ESCAPE.dup @HTML_ESCAPE["\t"] = ' ' * options[:tab_width] @@ -256,9 +257,9 @@ module Encoders if text =~ /#{HTML_ESCAPE_PATTERN}/o text = text.gsub(/#{HTML_ESCAPE_PATTERN}/o) { |m| @HTML_ESCAPE[m] } end - + style = @span_for_kind[@last_opened ? [kind, *@opened] : kind] - + if @independent_lines && (i = text.index("\n")) && (c = @opened.size + (style ? 1 : 0)) > 0 close = '</span>' * c reopen = '' @@ -267,14 +268,14 @@ module Encoders end text[i .. -1] = text[i .. -1].gsub("\n", "#{close}\n#{reopen}#{style}") end - + if style @out << style << text << '</span>' else @out << text end end - + # token groups, eg. strings def begin_group kind @out << (@span_for_kind[@last_opened ? [kind, *@opened] : kind] || '<span>') @@ -322,4 +323,4 @@ module Encoders end end -end
\ No newline at end of file +end diff --git a/lib/coderay/encoders/html/numbering.rb b/lib/coderay/encoders/html/numbering.rb index 904a64f..8bc6259 100644 --- a/lib/coderay/encoders/html/numbering.rb +++ b/lib/coderay/encoders/html/numbering.rb @@ -100,4 +100,4 @@ module Encoders end end -end
\ No newline at end of file +end |