Module: Codnar::Configuration::Highlighting
- Included in:
- Codnar::Configuration
- Defined in:
- lib/codnar/configuration/highlighting.rb
Overview
Configurations for highlighting source code lines.
Constant Summary collapse
- FORMAT_CODE_GVIM_HTML =
Format code using GVim’s syntax highlighting, using explicit HTML constructs. Assumes some previous configuration already classified the code lines.
lambda do |syntax| return Highlighting.klass_code_format('GVim', syntax, "[]") end
- FORMAT_CODE_GVIM_CSS =
Format code using GVim’s syntax highlighting, using CSS classes instead of explicit font and color styles. Assumes some previous configuration already classified the code lines.
lambda do |syntax| return Highlighting.klass_code_format('GVim', syntax, "[ '+:let html_use_css=1' ]") end
- FORMAT_CODE_CODERAY_HTML =
Format code using CodeRay’s syntax highlighting, using explicit HTML constructs. Assumes some previous configuration already classified the code lines.
lambda do |syntax| return Highlighting.klass_code_format('CodeRay', syntax, "{}") end
- FORMAT_CODE_CODERAY_CSS =
Format code using CodeRay’s syntax highlighting, using CSS classes instead of explicit font and color styles. Assumes some previous configuration already classified the code lines.
lambda do |syntax| return Highlighting.klass_code_format('CodeRay', syntax, "{ :css => :class }") end
- FORMAT_CODE_SUNLIGHT =
Format code using Sunlight’s syntax highlighting. This assumes the HTML will include and invoke Sunlight’s Javascript file which does the highlighting on the fly inside the DOM, instead of pre-computing it when splitting the file.
lambda do |syntax| return Highlighting.sunlight_code_format(syntax) end
- CHUNK_BY_VIM_REGIONS =
Group lines into chunks using VIM-style “{{”/“}}” region designations. Assumes other configurations handle the actual content lines.
{ "formatters" => { "begin_chunk" => "[]", "end_chunk" => "[]", "nested_chunk" => "Formatter.nested_chunk_lines_to_html(lines)", }, "syntax" => { "patterns" => { "begin_chunk" => { "regexp" => "^(\\s*)\\W*\\{\\{\\{\\s*(.*?)\\s*$" }, "end_chunk" => { "regexp" => "^(\\s*)\\W*\\}\\}\\}\\s*(.*?)\\s*$" }, }, "states" => { "start" => { "transitions" => [ { "pattern" => "begin_chunk" }, { "pattern" => "end_chunk" }, [], ], }, }, }, }
Class Method Summary collapse
-
.klass_code_format(klass, syntax, options) ⇒ Object
Return a configuration for highlighting a specific syntax using GVim.
-
.sunlight_code_format(syntax) ⇒ Object
Return a configuration for highlighting a specific syntax using Sunlight.
Class Method Details
.klass_code_format(klass, syntax, options) ⇒ Object
Return a configuration for highlighting a specific syntax using GVim.
25 26 27 28 29 30 31 |
# File 'lib/codnar/configuration/highlighting.rb', line 25 def self.klass_code_format(klass, syntax, ) return { "formatters" => { "#{syntax}_code" => "#{klass}.lines_to_html(lines, '#{syntax}', #{})", }, } end |
.sunlight_code_format(syntax) ⇒ Object
Return a configuration for highlighting a specific syntax using Sunlight.
64 65 66 67 68 69 70 |
# File 'lib/codnar/configuration/highlighting.rb', line 64 def self.sunlight_code_format(syntax) return { "formatters" => { "#{syntax}_code" => "Sunlight.lines_to_html(lines, '#{syntax}')", }, } end |