revealize 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/revealize/slide.rb +22 -19
- data/lib/revealize/version.rb +1 -1
- data/spec/revealize/slide_spec.rb +38 -12
- metadata +4 -4
data/lib/revealize/slide.rb
CHANGED
@@ -9,31 +9,34 @@ module Revealize
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
12
|
class MarkdownSlide < Struct.new(:raw_content)
|
14
13
|
def render
|
15
|
-
|
16
|
-
Haml::Engine.new("%section#{section_options}\n =rendered_markdown").render(self)
|
14
|
+
raw_content.split($/ * 4).map { |e| Slide.new(e).render }.join
|
17
15
|
end
|
18
16
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
class Slide < Struct.new(:raw_content)
|
18
|
+
attr_reader :rendered_markdown
|
19
|
+
def render
|
20
|
+
render_markdown
|
21
|
+
Haml::Engine.new("%section#{section_options}\n =rendered_markdown").render(self)
|
22
|
+
end
|
25
23
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
24
|
+
def render_markdown
|
25
|
+
@rendered_markdown = Kramdown::Document.new(content_without_preamble, :auto_ids => false).to_html
|
26
|
+
end
|
27
|
+
|
28
|
+
def content_without_preamble
|
29
|
+
return raw_content unless raw_content.start_with?("---")
|
30
|
+
raw_content = self.raw_content.sub("---\n", '')
|
31
|
+
pre_amble, content = raw_content.split("---\n")
|
32
|
+
@options = YAML.load(pre_amble)
|
33
|
+
return content
|
34
|
+
end
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
-
|
36
|
+
def section_options
|
37
|
+
return '' unless @options
|
38
|
+
return %Q{(#{@options.to_a.map {|option| "data-#{ option.first }='#{option.last}'" }.join(' ')})}
|
39
|
+
end
|
37
40
|
end
|
38
41
|
end
|
39
42
|
end
|
data/lib/revealize/version.rb
CHANGED
@@ -4,7 +4,7 @@ require 'revealize/slide'
|
|
4
4
|
module Revealize
|
5
5
|
module HamlHelper
|
6
6
|
def haml(content)
|
7
|
-
Haml::Engine.new(content).render
|
7
|
+
Haml::Engine.new(content.gsub(/^ */, '').gsub('.', ' ')).render
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -20,26 +20,52 @@ module Revealize
|
|
20
20
|
describe MarkdownSlide do
|
21
21
|
include HamlHelper
|
22
22
|
describe "#render" do
|
23
|
-
let(:slide) { MarkdownSlide.new(markdown_content) }
|
23
|
+
let(:slide) { MarkdownSlide.new(markdown_content.gsub(/^ */, '') ) }
|
24
24
|
let(:markdown_content) { "# Cool presentation" }
|
25
25
|
subject { slide.render }
|
26
26
|
|
27
|
-
|
27
|
+
context "containing a single slide" do
|
28
|
+
it { should == haml("%section\n..%h1 Cool presentation") }
|
28
29
|
|
29
|
-
|
30
|
-
|
30
|
+
context "with an empty preamble" do
|
31
|
+
let(:markdown_content) { %Q{---
|
31
32
|
---
|
32
|
-
# Cool presentation}
|
33
|
-
|
34
|
-
|
33
|
+
# Cool presentation}}
|
34
|
+
it { should == haml("%section\n..%h1 Cool presentation") }
|
35
|
+
end
|
35
36
|
|
36
|
-
|
37
|
-
|
37
|
+
context "with a preamble with attributes" do
|
38
|
+
let(:markdown_content) { %Q{---
|
38
39
|
transition : flow
|
39
40
|
state : blackout
|
40
41
|
---
|
41
|
-
# Cool presentation}
|
42
|
-
|
42
|
+
# Cool presentation} }
|
43
|
+
it { should == haml("%section(data-state='blackout' data-transition='flow')\n..%h1 Cool presentation") }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "containing multiple slides" do
|
48
|
+
let(:markdown_content) { %Q{# slide one
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
# slide two} }
|
53
|
+
it { should == haml(%Q{%section
|
54
|
+
..%h1 slide one
|
55
|
+
%section
|
56
|
+
..%h1 slide two}) }
|
57
|
+
end
|
58
|
+
|
59
|
+
context "containing nested slides", :broken => true do
|
60
|
+
let(:markdown_content) { %Q{# slide one
|
61
|
+
|
62
|
+
|
63
|
+
# slide two} }
|
64
|
+
it { should == haml(%Q{%section
|
65
|
+
..%section
|
66
|
+
....%h1 slide one
|
67
|
+
..%section
|
68
|
+
....%h1 slide two}) }
|
43
69
|
end
|
44
70
|
end
|
45
71
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: revealize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -220,7 +220,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
220
220
|
version: '0'
|
221
221
|
segments:
|
222
222
|
- 0
|
223
|
-
hash:
|
223
|
+
hash: 894907823
|
224
224
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
225
225
|
none: false
|
226
226
|
requirements:
|
@@ -229,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
229
229
|
version: '0'
|
230
230
|
segments:
|
231
231
|
- 0
|
232
|
-
hash:
|
232
|
+
hash: 894907823
|
233
233
|
requirements: []
|
234
234
|
rubyforge_project:
|
235
235
|
rubygems_version: 1.8.23
|