Class: Kramdown::Parser::Slider

Inherits:
Kramdown
  • Object
show all
Defined in:
lib/slideshift/tool/render/markdown.rb

Overview

ToDo: clean up!

Instance Method Summary collapse

Constructor Details

#initialize(source, options) ⇒ Slider

Returns a new instance of Slider.



9
10
11
12
13
# File 'lib/slideshift/tool/render/markdown.rb', line 9

def initialize(source, options)
  super
  @block_parsers.unshift(:syntax_tag)
  @block_parsers.unshift(:slide_tag)
end

Instance Method Details

#parse_slide_tagObject



24
25
26
27
# File 'lib/slideshift/tool/render/markdown.rb', line 24

def parse_slide_tag
  @src.pos += @src.matched_size
  @tree.children << Element.new(:raw, '</section><section class="slide">')
end

#parse_syntax_tagObject



15
16
17
18
19
20
21
22
# File 'lib/slideshift/tool/render/markdown.rb', line 15

def parse_syntax_tag
  match = /^```(\w+)\n(.*)\n```$/m.match(@src.matched)
  @src.pos += @src.matched_size
  code = Pygments.highlight(match[2], :lexer => match[1], :options => {
      :encoding => 'utf-8'
  })
  @tree.children << Element.new(:raw, code)
end