diff options
author | murphy <murphy@rubychan.de> | 2011-07-04 00:38:27 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2011-07-04 00:38:27 +0000 |
commit | 6a52b213edf1f146fb72a055466a35fe219e5a0d (patch) | |
tree | 2f0b49ff6ecbce2b24fc56d7eb9a2a883136bc5a /lib/coderay | |
parent | 498df2b7654c210c8f47e2757efc33cd94689b57 (diff) | |
download | coderay-6a52b213edf1f146fb72a055466a35fe219e5a0d.tar.gz |
cleanups: Page encoder is default for HTML, benchmark KB/s instead of tokens/s
Diffstat (limited to 'lib/coderay')
-rw-r--r-- | lib/coderay/duo.rb | 2 | ||||
-rw-r--r-- | lib/coderay/encoders/_map.rb | 15 | ||||
-rw-r--r-- | lib/coderay/encoders/div.rb | 17 | ||||
-rw-r--r-- | lib/coderay/encoders/html.rb | 2 | ||||
-rw-r--r-- | lib/coderay/encoders/html/output.rb | 2 | ||||
-rw-r--r-- | lib/coderay/encoders/page.rb | 4 | ||||
-rw-r--r-- | lib/coderay/encoders/span.rb | 19 | ||||
-rw-r--r-- | lib/coderay/helpers/file_type.rb | 11 |
8 files changed, 39 insertions, 33 deletions
diff --git a/lib/coderay/duo.rb b/lib/coderay/duo.rb index 171768c..cb3f8ee 100644 --- a/lib/coderay/duo.rb +++ b/lib/coderay/duo.rb @@ -21,7 +21,7 @@ module CodeRay # Create a new Duo, holding a lang and a format to highlight code. # # simple: - # CodeRay::Duo[:ruby, :page].highlight 'bla 42' + # CodeRay::Duo[:ruby, :html].highlight 'bla 42' # # with options: # CodeRay::Duo[:ruby, :html, :hint => :debug].highlight '????::??' diff --git a/lib/coderay/encoders/_map.rb b/lib/coderay/encoders/_map.rb index c9a20cc..24ada0a 100644 --- a/lib/coderay/encoders/_map.rb +++ b/lib/coderay/encoders/_map.rb @@ -2,15 +2,16 @@ module CodeRay module Encoders map \ - :loc => :lines_of_code, - :term => :terminal, - :tty => :terminal, - :plain => :text, - :plaintext => :text, + :loc => :lines_of_code, + :html => :page, + :plain => :text, + :plaintext => :text, :remove_comments => :comment_filter, - :stats => :statistic + :stats => :statistic, + :term => :terminal, + :tty => :terminal - # No default because Tokens#nonsense would not raise NoMethodError. + # No default because Tokens#nonsense should raise NoMethodError. end end diff --git a/lib/coderay/encoders/div.rb b/lib/coderay/encoders/div.rb index f9741e3..efd9435 100644 --- a/lib/coderay/encoders/div.rb +++ b/lib/coderay/encoders/div.rb @@ -1,22 +1,23 @@ module CodeRay module Encoders - + load :html # Wraps HTML output into a DIV element, using inline styles by default. # # See Encoders::HTML for available options. class Div < HTML - + FILE_EXTENSION = 'div.html' - + register_for :div - + DEFAULT_OPTIONS = HTML::DEFAULT_OPTIONS.merge \ - :css => :style, - :wrap => :div - + :css => :style, + :wrap => :div, + :line_numbers => false + end - + end end diff --git a/lib/coderay/encoders/html.rb b/lib/coderay/encoders/html.rb index 724f3eb..ec73d2c 100644 --- a/lib/coderay/encoders/html.rb +++ b/lib/coderay/encoders/html.rb @@ -91,7 +91,7 @@ module Encoders register_for :html - FILE_EXTENSION = 'html' + FILE_EXTENSION = 'snippet.html' DEFAULT_OPTIONS = { :tab_width => 8, diff --git a/lib/coderay/encoders/html/output.rb b/lib/coderay/encoders/html/output.rb index 5aa80a7..004351b 100644 --- a/lib/coderay/encoders/html/output.rb +++ b/lib/coderay/encoders/html/output.rb @@ -126,7 +126,7 @@ module Encoders TABLE = Template.new <<-TABLE <table class="CodeRay"><tr> <td class="line_numbers" title="double click to toggle" ondblclick="with (this.firstChild.style) { display = (display == '') ? 'none' : '' }"><pre><%LINE_NUMBERS%></pre></td> - <td class="code"><pre ondblclick="with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }"><%CONTENT%></pre></td> + <td class="code"><pre><%CONTENT%></pre></td> </tr></table> TABLE diff --git a/lib/coderay/encoders/page.rb b/lib/coderay/encoders/page.rb index 8db45cd..800e73f 100644 --- a/lib/coderay/encoders/page.rb +++ b/lib/coderay/encoders/page.rb @@ -14,8 +14,8 @@ module Encoders register_for :page DEFAULT_OPTIONS = HTML::DEFAULT_OPTIONS.merge \ - :css => :class, - :wrap => :page, + :css => :class, + :wrap => :page, :line_numbers => :table end diff --git a/lib/coderay/encoders/span.rb b/lib/coderay/encoders/span.rb index 1596044..da705bd 100644 --- a/lib/coderay/encoders/span.rb +++ b/lib/coderay/encoders/span.rb @@ -1,22 +1,23 @@ module CodeRay module Encoders - + load :html - + # Wraps HTML output into a SPAN element, using inline styles by default. # # See Encoders::HTML for available options. class Span < HTML - + FILE_EXTENSION = 'span.html' - + register_for :span - + DEFAULT_OPTIONS = HTML::DEFAULT_OPTIONS.merge \ - :css => :style, - :wrap => :span - + :css => :style, + :wrap => :span, + :line_numbers => false + end - + end end diff --git a/lib/coderay/helpers/file_type.rb b/lib/coderay/helpers/file_type.rb index 61f0049..19cc5ac 100644 --- a/lib/coderay/helpers/file_type.rb +++ b/lib/coderay/helpers/file_type.rb @@ -88,8 +88,8 @@ module CodeRay 'groovy' => :groovy, 'gvy' => :groovy, 'h' => :c, - 'htm' => :html, - 'html' => :html, + 'htm' => :page, + 'html' => :page, 'html.erb' => :rhtml, 'java' => :java, 'js' => :java_script, @@ -101,6 +101,7 @@ module CodeRay 'php3' => :php, 'php4' => :php, 'php5' => :php, + 'prawn' => :ruby, 'py' => :python, 'py3' => :python, 'pyw' => :python, @@ -111,11 +112,12 @@ module CodeRay 'rhtml' => :rhtml, 'rjs' => :ruby, 'rpdf' => :ruby, + 'ru' => :ruby, 'rxml' => :ruby, 'sch' => :scheme, 'sql' => :sql, 'ss' => :scheme, - 'xhtml' => :xhtml, + 'xhtml' => :page, 'xml' => :xml, 'yaml' => :yaml, 'yml' => :yaml, @@ -127,9 +129,10 @@ module CodeRay TypeFromShebang = /\b(?:ruby|perl|python|sh)\b/ TypeFromName = { - 'Capfile' => :ruby, + 'Capfile' => :ruby, 'Rakefile' => :ruby, 'Rantfile' => :ruby, + 'Gemfile' => :ruby, } end |