Module: Emerald
- Defined in:
- lib/emerald.rb,
lib/emerald/version.rb,
lib/emerald/preprocessor.rb
Overview
Parses a context free grammar from the preprocessed emerald and generates html associated with corresponding abstract syntax tree.
Defined Under Namespace
Classes: CLI, PreProcessor
Constant Summary collapse
- VERSION =
"1.0.0"
Class Method Summary collapse
- .convert(input, context = {}) ⇒ Object
-
.write_html(html_output, file_name, beautify) ⇒ Object
Write html to file and beautify it if the beautify global option is set to true.
Class Method Details
.convert(input, context = {}) ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/emerald.rb', line 55 def self.convert(input, context = {}) preprocessed_emerald, source_map = PreProcessor.new.process_emerald(input) abstract_syntax_tree = Grammar.parse_grammar( preprocessed_emerald, input, source_map ) return abstract_syntax_tree.to_html(context) end |
.write_html(html_output, file_name, beautify) ⇒ Object
Write html to file and beautify it if the beautify global option is set to true.
68 69 70 71 72 73 74 |
# File 'lib/emerald.rb', line 68 def self.write_html(html_output, file_name, beautify) File.open(file_name + '.html', 'w') do |emerald_file| html_output = HtmlBeautifier.beautify(html_output) if beautify emerald_file.write(html_output) end puts "Wrote #{file_name + '.html'}" end |