Module: Slideshow::MarkdownEngines

Included in:
Gen
Defined in:
lib/slideshow/markup/markdown.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) bluecloth_to_html(content)



45
46
47
# File 'lib/slideshow/markup/markdown.rb', line 45

def bluecloth_to_html( content )
  BlueCloth.new( content ).to_html
end

- (Object) kramdown_to_html(content)



49
50
51
# File 'lib/slideshow/markup/markdown.rb', line 49

def kramdown_to_html( content )
  Kramdown::Document.new( content ).to_html
end

- (Object) load_markdown_libs

# code for managing multiple markdown libs



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/slideshow/markup/markdown.rb', line 56

def load_markdown_libs
  # check for available markdown libs/gems
  # try to require each lib and remove any not installed
  @markdown_libs = []

  config.known_markdown_libs.each do |lib|
    begin
      require lib
      @markdown_libs << lib
    rescue LoadError => ex
      logger.debug "Markdown library #{lib} not found. Use gem install #{lib} to install."
    end
  end

  puts "  Found #{@markdown_libs.length} Markdown libraries: #{@markdown_libs.join(', ')}"
end

- (Object) markdown_to_html(content)



74
75
76
77
78
79
80
81
82
83
84
# File 'lib/slideshow/markup/markdown.rb', line 74

def markdown_to_html( content )
  # call markdown filter; turn markdown lib name into method_name (mn)
  # eg. rpeg-markdown =>  rpeg_markdown_to_html

  # lets you use differnt options/converters for a single markdown lib
  mn = config.markdown_to_html_method( @markdown_libs.first )    
  
  puts "  Converting Markdown-text (#{content.length} bytes) to HTML using library '#{@markdown_libs.first}' calling '#{mn}'..."
  
  send mn, content   # call 1st configured markdown engine e.g. kramdown_to_html( content )
end

- (Object) maruku_to_html(content)



41
42
43
# File 'lib/slideshow/markup/markdown.rb', line 41

def maruku_to_html( content )
  Maruku.new( content, {:on_error => :raise} ).to_html
end

- (Object) pandoc_ruby_to_html(content)



4
5
6
# File 'lib/slideshow/markup/markdown.rb', line 4

def pandoc_ruby_to_html( content )
  content = PandocRuby.new( content, :from => :markdown, :to => :html ).convert
end

- (Object) pandoc_ruby_to_html_incremental(content)



8
9
10
11
12
13
14
# File 'lib/slideshow/markup/markdown.rb', line 8

def pandoc_ruby_to_html_incremental( content )
  content = PandocRuby.new( content, :from => :markdown, :to => :html ).convert
  content = content.gsub(/<(ul|ol)/) do |match|
    "#{Regexp.last_match(0)} class='step'"
  end
  content
end

- (Object) pandoc_ruby_to_s5(content)

sample how to use your own converter configure in slideshow.yml pandoc-ruby:

converter: pandoc-ruby-to-s5


21
22
23
24
25
# File 'lib/slideshow/markup/markdown.rb', line 21

def pandoc_ruby_to_s5( content )
  content = PandocRuby.new( content, {:from => :markdown, :to => :s5}, :smart ).convert
  content = content.gsub(/class="incremental"/,'class="step"')
  content = content.to_a[13..-1].join # remove the layout div
end

- (Object) pandoc_ruby_to_s5_incremental(content)



27
28
29
30
31
# File 'lib/slideshow/markup/markdown.rb', line 27

def pandoc_ruby_to_s5_incremental( content )
  content = PandocRuby.new( content, {:from => :markdown, :to => :s5 }, :incremental, :smart ).convert
  content = content.gsub(/class="incremental"/,'class="step"')
  content = content.to_a[13..-1].join # remove the layout div
end

- (Object) rdiscount_to_html(content)



33
34
35
# File 'lib/slideshow/markup/markdown.rb', line 33

def rdiscount_to_html( content )
  RDiscount.new( content ).to_html
end

- (Object) rpeg_markdown_to_html(content)



37
38
39
# File 'lib/slideshow/markup/markdown.rb', line 37

def rpeg_markdown_to_html( content )
  PEGMarkdown.new( content ).to_html
end