Class: Kramdown::Parser::Slider

Inherits:
Kramdown
  • Object
show all
Defined in:
lib/slider/markdown.rb

Instance Method Summary collapse

Constructor Details

#initialize(source, options) ⇒ Slider

Returns a new instance of Slider.



7
8
9
10
11
# File 'lib/slider/markdown.rb', line 7

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

Instance Method Details

#parse_slide_tagObject



22
23
24
25
# File 'lib/slider/markdown.rb', line 22

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

#parse_syntax_tagObject



13
14
15
16
17
18
19
20
# File 'lib/slider/markdown.rb', line 13

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