Module: Jekyll::Engines

Defined in:
lib/jekyll/engines.rb

Class Method Summary collapse

Class Method Details

.haml(content) ⇒ Object



63
64
65
66
# File 'lib/jekyll/engines.rb', line 63

def self.haml(content)
  require "haml"
  Haml::Engine.new(content, :suppress_eval => true).render
end

.markdown(content) ⇒ Object



51
52
53
# File 'lib/jekyll/engines.rb', line 51

def self.markdown(content)
  @@config['markdown'] == "maruku" ? self.maruku(content) : self.rdiscount(content)
end

.maruku(content) ⇒ Object



55
56
57
# File 'lib/jekyll/engines.rb', line 55

def self.maruku(content)
  Maruku.new(content).to_html
end

.rdiscount(content) ⇒ Object



59
60
61
# File 'lib/jekyll/engines.rb', line 59

def self.rdiscount(content)
  RDiscount.new(content).to_html
end

.setup(config) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/jekyll/engines.rb', line 4

def self.setup(config)
  # Set the Markdown interpreter (and Maruku self.config, if necessary)
  @@config = config
  case config['markdown']
  when 'rdiscount'
    begin
      require 'rdiscount'
    rescue LoadError
      puts 'You must have the rdiscount gem installed first'
    end
  when 'maruku'
    begin
      require 'maruku'

      if config['maruku']['use_divs']
        require 'maruku/ext/div'
        puts 'Maruku: Using extended syntax for div elements.'
      end

      if config['maruku']['use_tex']
        require 'maruku/ext/math'
        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
    rescue LoadError
      puts 'The maruku gem is required for markdown support!'
    end
  else
    raise "Invalid Markdown processor: '#{config['markdown']}' -- " +
          "did you mean 'maruku' or 'rdiscount'? "
  end
end

.textile(content) ⇒ Object



47
48
49
# File 'lib/jekyll/engines.rb', line 47

def self.textile(content)
  RedCloth.new(content).to_html
end