Class: Tilt::PandocTemplate
Overview
Pandoc markdown implementation. See: pandoc.org/
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Template
Instance Method Summary collapse
- #allows_script? ⇒ Boolean
- #evaluate(scope, locals, &block) ⇒ Object
-
#pandoc_options ⇒ Object
turn options hash into an array Map tilt options to pandoc options Replace hash keys with value true with symbol for key Remove hash keys with value false Leave other hash keys untouched.
- #prepare ⇒ Object
- #tilt_to_pandoc_mapping ⇒ Object
Methods inherited from Template
#basename, default_mime_type, default_mime_type=, #eval_file, #initialize, metadata, #metadata, #name, #render
Constructor Details
This class inherits a constructor from Tilt::Template
Instance Method Details
#allows_script? ⇒ Boolean
45 46 47 |
# File 'lib/tilt/pandoc.rb', line 45 def allows_script? false end |
#evaluate(scope, locals, &block) ⇒ Object
41 42 43 |
# File 'lib/tilt/pandoc.rb', line 41 def evaluate(scope, locals, &block) @output ||= @engine.to_html.strip end |
#pandoc_options ⇒ Object
turn options hash into an array Map tilt options to pandoc options Replace hash keys with value true with symbol for key Remove hash keys with value false Leave other hash keys untouched
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/tilt/pandoc.rb', line 23 def .reduce([]) do |sum, (k,v)| case v when true sum << (tilt_to_pandoc_mapping[k] || k) when false sum else sum << { k => v } end end end |
#prepare ⇒ Object
36 37 38 39 |
# File 'lib/tilt/pandoc.rb', line 36 def prepare @engine = PandocRuby.new(data, *) @output = nil end |
#tilt_to_pandoc_mapping ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/tilt/pandoc.rb', line 10 def tilt_to_pandoc_mapping { :smartypants => :smart, :escape_html => { :f => 'markdown-raw_html' }, :commonmark => { :f => 'commonmark' }, :markdown_strict => { :f => 'markdown_strict' } } end |