Module: JamScriptHighlighter
- Defined in:
- lib/jam_script_highlighter/version.rb,
lib/jam_script_highlighter.rb,
lib/jam_script_highlighter/html.rb,
lib/jam_script_highlighter/line.rb,
lib/jam_script_highlighter/html/tag_helpers.rb,
lib/jam_script_highlighter/line_types/note_line.rb,
lib/jam_script_highlighter/line_types/empty_line.rb,
lib/jam_script_highlighter/line_types/other_line.rb,
lib/jam_script_highlighter/line_types/title_line.rb,
lib/jam_script_highlighter/line_types/control_line.rb,
lib/jam_script_highlighter/line_types/section_line.rb,
lib/jam_script_highlighter/line_types/metadata_line.rb,
lib/jam_script_highlighter/line_types/variation_line.rb
Overview
:nodoc:
Defined Under Namespace
Modules: Html, LineTypes, TagHelpers, VERSION Classes: Line
Constant Summary collapse
- CONTROL =
'#'
- NOTE =
'!'
- SECTION =
'*'
- VARIATION =
'-'
Class Method Summary collapse
Class Method Details
.highlight(string) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/jam_script_highlighter.rb', line 12 def highlight(string) @index = 0 @ctrl_char_set = false result = [] lines = string.split "\n" lines.each_with_index do |line, index| @index = index result << process(line) end result end |
.process(line) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/jam_script_highlighter.rb', line 27 def process line type = type_of line if [:control, :note, :section, :variation].include?(type) line = line[1..line.length].strip @ctrl_char_set = true elsif type == :empty @ctrl_char_set = true else unless @ctrl_char_set type = (@index == 0) ? :title : :metadata end end {:type => type, :line => line} end |