Module: Ruco::SyntaxParser
- Defined in:
- lib/ruco/syntax_parser.rb
Constant Summary collapse
- TEXTPOW_CONVERT =
textpow only offers certain syntax
{ 'html+erb' => 'text.html.ruby', 'rhtml' => 'text.html.ruby', }
Class Method Summary collapse
- .syntax_for_line(line, languages) ⇒ Object
- .syntax_for_lines(lines, languages) ⇒ Object
- .syntax_node(languages) ⇒ Object
Class Method Details
.syntax_for_line(line, languages) ⇒ Object
9 10 11 |
# File 'lib/ruco/syntax_parser.rb', line 9 def self.syntax_for_line(line, languages) syntax_for_lines([line], languages).first end |
.syntax_for_lines(lines, languages) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ruco/syntax_parser.rb', line 14 def self.syntax_for_lines(lines, languages) if syntax = syntax_node(languages) begin processor = syntax.parse(lines.join("\n"), Ruco::ArrayProcessor.new) processor.lines rescue RegexpError, ArgumentError $stderr.puts $! [] end else [] end end |
.syntax_node(languages) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ruco/syntax_parser.rb', line 28 def self.syntax_node(languages) found = nil fallbacks = languages.map{|l| TEXTPOW_CONVERT[l] }.compact (languages + fallbacks).detect do |language| found = Textpow.syntax(language) end found end |