Class: Jekyll::Converters::Markdown::MarukuParser
- Inherits:
-
Object
- Object
- Jekyll::Converters::Markdown::MarukuParser
- Defined in:
- lib/jekyll/converters/markdown/maruku_parser.rb
Instance Method Summary collapse
- #convert(content) ⇒ Object
-
#initialize(config) ⇒ MarukuParser
constructor
A new instance of MarukuParser.
- #load_blahtext_library ⇒ Object
- #load_divs_library ⇒ Object
- #print_errors_and_fail ⇒ Object
Constructor Details
#initialize(config) ⇒ MarukuParser
Returns a new instance of MarukuParser.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/jekyll/converters/markdown/maruku_parser.rb', line 5 def initialize(config) require 'maruku' @config = config @errors = [] load_divs_library if @config['maruku']['use_divs'] load_blahtext_library if @config['maruku']['use_tex'] rescue LoadError STDERR.puts 'You are missing a library required for Markdown. Please run:' STDERR.puts ' $ [sudo] gem install maruku' raise FatalException.new("Missing dependency: maruku") end |
Instance Method Details
#convert(content) ⇒ Object
43 44 45 46 47 |
# File 'lib/jekyll/converters/markdown/maruku_parser.rb', line 43 def convert(content) converted = Maruku.new(content, :error_stream => @errors).to_html.strip print_errors_and_fail unless @errors.empty? converted end |
#load_blahtext_library ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/jekyll/converters/markdown/maruku_parser.rb', line 22 def load_blahtext_library require 'maruku/ext/math' STDERR.puts "Maruku: Using LaTeX extension. Images in `#{@config['maruku']['png_dir']}`." # Switch off MathML output MaRuKu::Globals[:html_math_output_mathml] = false MaRuKu::Globals[:html_math_engine] = 'none' # Turn on math to PNG support with blahtex # Resulting PNGs stored in `images/latex` MaRuKu::Globals[:html_math_output_png] = true MaRuKu::Globals[:html_png_engine] = @config['maruku']['png_engine'] MaRuKu::Globals[:html_png_dir] = @config['maruku']['png_dir'] MaRuKu::Globals[:html_png_url] = @config['maruku']['png_url'] end |
#load_divs_library ⇒ Object
17 18 19 20 |
# File 'lib/jekyll/converters/markdown/maruku_parser.rb', line 17 def load_divs_library require 'maruku/ext/div' STDERR.puts 'Maruku: Using extended syntax for div elements.' end |
#print_errors_and_fail ⇒ Object
38 39 40 41 |
# File 'lib/jekyll/converters/markdown/maruku_parser.rb', line 38 def print_errors_and_fail print @errors.join raise MaRuKu::Exception, "MaRuKu encountered problem(s) while converting your markup." end |