-
Notifications
You must be signed in to change notification settings - Fork 0
/
slides_converter.rb
59 lines (46 loc) · 1.6 KB
/
slides_converter.rb
1
2
3
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Copyright (c) 2017 Kevin Ottens <[email protected]>
# This file is licensed to you under the MIT license.
# See the LICENSE file in the project root for more information.
module Jekyll
require 'rdiscount'
class SlidesConverter < Converter
safe true
priority :low
def matches(ext)
ext =~ /slides/i
end
def output_ext(ext)
".html"
end
def convert(content)
@rdiscount_extensions = @config['rdiscount']['extensions'].map { |e| e.to_sym }
slides = content.split(/\n\*\*\*?\n/)
html = ""
slides.each { |slide|
(content, notes) = slide.split(/\n___?\n/)
if content == nil then
content = slide
end
content += "\n"
properties = content.slice!(/^@.*?\n/)
if properties != nil then
properties.slice!(/^@/)
properties.chomp!
html << "\n<section " << properties << ">\n"
else
html << "\n<section>\n"
end
rd = RDiscount.new(content, *@rdiscount_extensions)
html << rd.to_html
if notes != nil then
rd = RDiscount.new(notes, *@rdiscount_extensions)
html << "\n<aside class=\"notes\">\n"
html << rd.to_html
html << "\n</aside>"
end
html << "\n</section>\n\n"
}
return html
end
end
end