Sha256: a30dedf52a4bdacbf856406de1fee7276b55753475d5af9359a9934236634c10
Contents?: true
Size: 842 Bytes
Versions: 3
Compression:
Stored size: 842 Bytes
Contents
module Ruco module SyntaxParser # textpow only offers certain syntax TEXTPOW_CONVERT = { 'scss' => 'sass', 'html+erb' => 'html_rails', } def self.syntax_for_lines(lines, languages) if syntax = syntax_node(languages) processor = syntax.parse(lines.join("\n"), Ruco::ArrayProcessor.new) processor.lines else [] end end def self.syntax_node(languages) @@syntax_node ||= {} @@syntax_node[languages] ||= begin found = nil fallbacks = languages.map{|l| TEXTPOW_CONVERT[l] }.compact (languages + fallbacks).detect do |language| syntax = File.join(Textpow.syntax_path, "#{language}.syntax") found = Textpow::SyntaxNode.load(syntax) if File.exist?(syntax) end found end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ruco-0.2.0.beta11 | lib/ruco/syntax_parser.rb |
ruco-0.2.0.beta10 | lib/ruco/syntax_parser.rb |
ruco-0.2.0.beta9 | lib/ruco/syntax_parser.rb |