slideshow-models 3.1.1 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e7c495dbff4118e7db27edcc657493e04f0da5c9
4
- data.tar.gz: 2b4f190a814eb0cfbdf42f846d50e974e2e06487
3
+ metadata.gz: b621853de6619c00eb51f0ec88ad1ae89c9ddecb
4
+ data.tar.gz: b552e40f59f0524fde019ee3c85e8f1d5835aa38
5
5
  SHA512:
6
- metadata.gz: 5daad9297ada4ec336eac0ac4bfe80a4bc3b300479c9ccca1cf11c42ac60bd3a38309a3ea61c77807b4cf0848963c74ff16ce8d0410814717c5d4299dfd5a95c
7
- data.tar.gz: ce799acaa508fc3a185c6352b00718c5f030bbb1bbb0429b7eca9554530c831546f392ff17a346f9c5d6b454ffc1d4b2f3c26a47e53b26b8927d43dc863960b4
6
+ metadata.gz: 15234f03210c70adae3370017077e80fab96cba607b9476f0e5b100c73bcfda81a8a26d4046195525f31e9a96d8f4f63d31ed47a4ae0ebbe4eb3591a92f5eb0a
7
+ data.tar.gz: 90d8e8ab65594cf2b340ca9656aec522c695ce2d445c268bc09acf18019e939859d60b2135f8b0a9bd685d465f8b311c46829595f1451f3892ea7a316aed2a51
@@ -44,6 +44,7 @@ test/templates/test/test.html
44
44
  test/templates/test/test.txt
45
45
  test/test_build.rb
46
46
  test/test_build_deck.rb
47
+ test/test_filter.rb
47
48
  test/test_kramdown.rb
48
49
  test/test_slide.rb
49
50
  test/test_version.rb
@@ -5,6 +5,14 @@ module Slideshow
5
5
 
6
6
  module DeckFilter
7
7
 
8
+
9
+ ##
10
+ ## note/todo: more alternatives/options for slide breaks
11
+ ##
12
+ ## add a simple slide break rule for two or more blank lines
13
+
14
+
15
+
8
16
  # add slide directive before h1 (tells slideshow gem where to break slides)
9
17
  #
10
18
  # e.g. changes:
@@ -45,31 +53,23 @@ def add_slide_directive_before_h2( content )
45
53
  end
46
54
 
47
55
 
48
-
49
- # add slide directive before div h1 (for pandoc-generated html)
50
- #
51
- # e.g. changes:
52
- # <div id='header'>
53
- # <h1 id='optional' class='optional'>
54
- # to
55
- # html comment -> _S9SLIDE_
56
- # <div id='header'>
57
- # <h1 id='optional' class='optional'>
58
-
59
-
60
- def add_slide_directive_before_div_h1( content )
56
+ def add_slide_directive_for_hr( content )
61
57
 
62
58
  slide_count = 0
63
59
 
64
- content = content.gsub( /<div[^>]*>\s*<h1/ ) do |match|
60
+ ## replace <hr> or <hr /> with slide directive/comment
61
+ ## note: hr gets **replaced/removed**
62
+
63
+ content = content.gsub( /<hr(\s*\/)?>/ ) do |match|
65
64
  slide_count += 1
66
- "\n<!-- _S9SLIDE_ -->\n#{Regexp.last_match(0)}"
65
+ "\n<!-- _S9SLIDE_ -->\n"
67
66
  end
68
-
69
- puts " Adding #{slide_count} slide breaks (using div_h1 rule)..."
70
-
67
+
68
+ puts " Adding #{slide_count} slide breaks (using hr rule)..."
69
+
71
70
  content
72
71
  end
72
+
73
73
 
74
74
  end # module DeckFilter
75
75
 
@@ -85,7 +85,7 @@ class Deck
85
85
  attr_accessor :slides
86
86
 
87
87
 
88
- def initialize( source, header_level: 1, use_slide: false )
88
+ def initialize( source, header_level: 2, use_slide: false )
89
89
  @source = source ## keep a copy of the original source (input)
90
90
 
91
91
  @header_level = header_level # e.g. 1 or 2 -- todo/fix: allow more options e.g. 1..2 etc.
@@ -107,10 +107,17 @@ class Deck
107
107
  if @use_slide # only allow !SLIDE directives fo slide breaks?
108
108
  # do nothing (no extra automagic slide breaks wanted)
109
109
  else
110
- if @header_level == 2
111
- @content = add_slide_directive_before_h2( @content )
112
- else # assume level 1
110
+
111
+ ## default rule for horizontal line/rule <hr> - gets replaced by slide directive
112
+ ## - for now alway on/used (use !SLIDE only if not wanted for now)
113
+ @content = add_slide_directive_for_hr( @content )
114
+
115
+ if @header_level == 1
113
116
  @content = add_slide_directive_before_h1( @content )
117
+ else # assume level 2
118
+ ## note: level 2 also turns level 1 into slide breaks
119
+ @content = add_slide_directive_before_h1( @content )
120
+ @content = add_slide_directive_before_h2( @content )
114
121
  end
115
122
  end
116
123
 
@@ -17,7 +17,7 @@ module Slideshow
17
17
 
18
18
  ### def to_drop() SlideDrop.new( self ); end -- add - why? why not??
19
19
 
20
- def initialize( content, header_level: 1 )
20
+ def initialize( content, header_level: 2 )
21
21
  ## options
22
22
  @header_level = header_level
23
23
 
@@ -66,16 +66,17 @@ module Slideshow
66
66
  # tip test regex online at rubular.com
67
67
  # note/fix: needs to get improved to also handle case for h1 wrapped into div
68
68
 
69
- if @header_level == 2
70
- pattern = /^(.*?)(<h2.*?>.*?<\/h2>)(.*)/m
71
- else # assume header level 1
69
+ if @header_level == 1
72
70
  pattern = /^(.*?)(<h1.*?>.*?<\/h1>)(.*)/m
71
+ else # assume header level 2
72
+ ## note: header_level 2 also incl. header_level 1 slides
73
+ pattern = /^(.*?)(<(?:h1|h2).*?>.*?<\/(?:h1|h2)>)(.*)/m
73
74
  end
74
75
 
75
76
  if @content =~ pattern
76
77
  @header = $2
77
78
  @content_without_header = ($1 ? $1 : '') + ($3 ? $3 : '')
78
- logger.debug " adding slide with header (h1):\n#{@header}"
79
+ logger.debug " adding slide with header:\n#{@header}"
79
80
  else
80
81
  @header = nil # todo: set to '' empty string? why not?
81
82
  @content_without_header = @content
@@ -11,7 +11,7 @@ class Opts
11
11
 
12
12
  def header_level
13
13
  ## todo: check 0 is not nil?
14
- @header_level || 1
14
+ @header_level || 2 ## note: (new) default is 2 -- note: 2 also breaks on 1
15
15
  end
16
16
 
17
17
  def slide=(boolean)
@@ -3,8 +3,8 @@
3
3
  module Slideshow
4
4
 
5
5
  MAJOR = 3
6
- MINOR = 1
7
- PATCH = 1
6
+ MINOR = 2
7
+ PATCH = 0
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_filter.rb
6
+
7
+
8
+ require 'helper'
9
+
10
+
11
+ class TestFilter < MiniTest::Test
12
+
13
+ include Slideshow::DeckFilter
14
+
15
+ def test_slide_breaks_for_hr
16
+
17
+ content =<<EOS
18
+
19
+ <p>some text</p>
20
+ <hr />
21
+ <p>some text</p>
22
+ <hr>
23
+ <p>some text</p>
24
+
25
+ EOS
26
+
27
+ content_expected =<<EOS
28
+
29
+ <p>some text</p>
30
+
31
+ <!-- _S9SLIDE_ -->
32
+
33
+ <p>some text</p>
34
+
35
+ <!-- _S9SLIDE_ -->
36
+
37
+ <p>some text</p>
38
+
39
+ EOS
40
+
41
+
42
+ assert_equal content_expected, add_slide_directive_for_hr( content )
43
+
44
+ end # method test_slide_breaks_for_hr
45
+
46
+
47
+
48
+ end # class TestFilter
49
+
@@ -37,7 +37,37 @@ EOS
37
37
  assert_equal nil, slide.classes
38
38
  assert_equal nil, slide.data_attributes
39
39
 
40
- end # method test_slide
40
+ end # method test_slide1
41
+
42
+
43
+ def test_slide2
44
+
45
+ content =<<EOS
46
+ <h2 id="test-header-2">test header 2</h2>
47
+
48
+ <p>test content 2</p>
49
+ EOS
50
+
51
+ slide = Slideshow::Slide.new( content, header_level: 2 )
52
+
53
+ puts "header:"
54
+ pp slide.header
55
+ puts "content:"
56
+ pp slide.content
57
+ puts "content_without_header:"
58
+ pp slide.content_without_header
59
+ puts "classes:"
60
+ pp slide.classes
61
+ puts "data_attributes:"
62
+ pp slide.data_attributes
63
+
64
+ assert_equal %Q{<h2 id="test-header-2">test header 2</h2>}, slide.header
65
+ assert_equal content, slide.content
66
+ assert_equal nil, slide.classes
67
+ assert_equal nil, slide.data_attributes
68
+
69
+ end # method test_slide2
70
+
41
71
 
42
72
 
43
73
  end # class TestSlide
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slideshow-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-08 00:00:00.000000000 Z
11
+ date: 2016-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: props
@@ -177,6 +177,7 @@ files:
177
177
  - test/templates/test/test.txt
178
178
  - test/test_build.rb
179
179
  - test/test_build_deck.rb
180
+ - test/test_filter.rb
180
181
  - test/test_kramdown.rb
181
182
  - test/test_slide.rb
182
183
  - test/test_version.rb