Class | CodeRay::Encoders::HTML |
In: |
lib/coderay/encoders/html.rb
lib/coderay/encoders/html/output.rb lib/coderay/encoders/html/numbering.rb lib/coderay/encoders/html/css.rb |
Parent: | Encoder |
This is CodeRay‘s most important highlighter: It provides save, fast XHTML generation and CSS support.
require 'coderay' puts CodeRay.scan('Some /code/', :ruby).html #-> a HTML page puts CodeRay.scan('Some /code/', :ruby).html(:wrap => :span) #-> <span class="CodeRay"><span class="co">Some</span> /code/</span> puts CodeRay.scan('Some /code/', :ruby).span #-> the same puts CodeRay.scan('Some code', :ruby).html( :wrap => nil, :line_numbers => :inline, :css => :style )
Convert \t characters to n spaces (a number.)
Default: 8
How to include the styles; can be :class or :style.
Default: :class
Wrap in :page, :div, :span or nil.
You can also use Encoders::Div and Encoders::Span.
Default: nil
The title of the HTML page (works only when :wrap is set to :page.)
Default: ‘CodeRay output‘
Include line numbers in :table, :inline, or nil (no line numbers)
Default: nil
Adds anchors and links to the line numbers. Can be false (off), true (on), or a prefix string that will be prepended to the anchor name.
The prefix must consist only of letters, digits, and underscores.
Default: true, default prefix name: "line"
Where to start with line number counting.
Default: 1
Make every n-th number appear bold.
Default: 10
Highlights certain line numbers. Can be any Enumerable, typically just an Array or Range, of numbers.
Bolding is deactivated when :highlight_lines is set. It only makes sense in combination with :line_numbers.
Default: nil
Include some information into the output using the title attribute. Can be :info (show token kind on mouse-over), :info_long (with full path) or :debug (via inspect).
Default: false
FILE_EXTENSION | = | 'snippet.html' | ||
DEFAULT_OPTIONS | = | { :tab_width => 8, :css => :class, :style => :alpha, :wrap => nil, :title => 'CodeRay output', :line_numbers => nil, :line_number_anchors => 'n', :line_number_start => 1, :bold_every => 10, :highlight_lines => nil, :hint => false, } | ||
HTML_ESCAPE | = | { #:nodoc: '&' => '&', '"' => '"', '>' => '>', '<' => '<', } | ||
HTML_ESCAPE_PATTERN | = | /[\t"&><\0-\x8\xB-\x1f]/ |
ansi_chars = Array(0x7f..0xff) ansi_chars.each { |i| HTML_ESCAPE = ’&#%d;’ % i }
\x9 (\t) and \xA (\n) not included HTML_ESCAPE_PATTERN = /[\t&"><\0-\x8\xB-\x1f\x7f-\xff]/ |
|
TOKEN_KIND_TO_INFO | = | Hash.new do |h, kind| h[kind] = kind.to_s.gsub(/_/, ' ').gsub(/\b\w/) { $&.capitalize } |
css | [R] |