Class: Jekyll::MarkdownConverter
Constant Summary
Constants inherited
from Plugin
Plugin::PRIORITIES
Instance Method Summary
collapse
Methods inherited from Converter
#initialize, pygments_prefix, #pygments_prefix, pygments_suffix, #pygments_suffix
Methods inherited from Plugin
<=>, inherited, #initialize, priority, safe, subclasses
Instance Method Details
#convert(content) ⇒ Object
66
67
68
69
70
71
72
73
74
|
# File 'lib/jekyll/converters/markdown.rb', line 66
def convert(content)
setup
case @config['markdown']
when 'rdiscount'
RDiscount.new(content).to_html
when 'maruku'
Maruku.new(content).to_html
end
end
|
#matches(ext) ⇒ Object
58
59
60
|
# File 'lib/jekyll/converters/markdown.rb', line 58
def matches(ext)
ext =~ /(markdown|mkdn?|md)/i
end
|
#output_ext(ext) ⇒ Object
62
63
64
|
# File 'lib/jekyll/converters/markdown.rb', line 62
def output_ext(ext)
".html"
end
|
#setup ⇒ Object
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
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/jekyll/converters/markdown.rb', line 9
def setup
return if @setup
case @config['markdown']
when 'rdiscount'
begin
require 'rdiscount'
rescue LoadError
STDERR.puts 'You are missing a library required for Markdown. Please run:'
STDERR.puts ' $ [sudo] gem install rdiscount'
raise FatalException.new("Missing dependency: rdiscount")
end
when 'maruku'
begin
require 'maruku'
if @config['maruku']['use_divs']
require 'maruku/ext/div'
STDERR.puts 'Maruku: Using extended syntax for div elements.'
end
if @config['maruku']['use_tex']
require 'maruku/ext/math'
STDERR.puts "Maruku: Using LaTeX extension. Images in `#{@config['maruku']['png_dir']}`."
MaRuKu::Globals[:html_math_output_mathml] = false
MaRuKu::Globals[:html_math_engine] = 'none'
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
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
else
STDERR.puts "Invalid Markdown processor: #{@config['markdown']}"
STDERR.puts " Valid options are [ maruku | rdiscount ]"
raise FatalException.new("Invalid Markdown process: #{@config['markdown']}")
end
@setup = true
end
|