slideshow 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
data/History.rdoc CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.9.3 / 2010-07-13
2
+
3
+ * Added support for pandoc-ruby (for Markdown processing); skip %-filters; break slides using div/h1 rule [Thanks David Sanson]
4
+
1
5
  === 0.9.2 / 2010-07-11
2
6
 
3
7
  * Change default template pack from s6gradients to s6blank
data/Manifest.txt CHANGED
@@ -9,6 +9,7 @@ lib/slideshow.rb
9
9
  lib/slideshow/config.rb
10
10
  lib/slideshow/filters/debug_filter.rb
11
11
  lib/slideshow/filters/headers_filter.rb
12
+ lib/slideshow/filters/slide_filter.rb
12
13
  lib/slideshow/filters/text_filter.rb
13
14
  lib/slideshow/gen.rb
14
15
  lib/slideshow/helpers/analytics_helper.rb
@@ -16,7 +16,7 @@ filters:
16
16
  - skip-end-directive
17
17
  - directives_bang_style_to_percent_style
18
18
  - directives_percent_style
19
- - comments-percent-style
19
+ - comments-percent-style
20
20
  - leading-headers
21
21
  - erb-django-style
22
22
  - erb-rename-helper-hack
@@ -42,6 +42,7 @@ markdown:
42
42
  # the search order is first come, first serve, that is: rdiscount, rpeg-markdown, maruku, bluecloth, kramdown (fallback, always present)
43
43
 
44
44
  libs:
45
+ - pandoc-ruby
45
46
  - rdiscount
46
47
  - rpeg-markdown
47
48
  - maruku
@@ -48,7 +48,7 @@ class Config
48
48
 
49
49
  def known_markdown_libs
50
50
  # returns an array of known markdown engines e.g.
51
- # [ rdiscount, rpeg-markdown, maruku, bluecloth, kramdown ]
51
+ # [ pandoc-ruby, rdiscount, rpeg-markdown, maruku, bluecloth, kramdown ]
52
52
 
53
53
  (@hash[ 'markdown' ][ 'libs' ] || []) + @hash[ 'builtin' ][ 'markdown' ][ 'libs' ]
54
54
  end
@@ -18,6 +18,23 @@ def dump_content_to_file_debug_text_erb( content )
18
18
  content
19
19
  end
20
20
 
21
+ # use it to dump content before html post processing
22
+
23
+ def dump_content_to_file_debug_html( content )
24
+
25
+ return content unless logger.level == Logger::DEBUG
26
+
27
+ outname = "#{@name}.debug.html"
28
+
29
+ puts " Dumping content before html post processing to #{outname}..."
30
+
31
+ File.open( outname, 'w' ) do |f|
32
+ f.write( content )
33
+ end
34
+
35
+ content
36
+ end
37
+
21
38
  # use it to dump content before text-to-html conversion
22
39
 
23
40
  def dump_content_to_file_debug_text( content )
@@ -0,0 +1,60 @@
1
+ module Slideshow
2
+ module SlideFilter
3
+
4
+ # add slide directive before h1 (tells slideshow gem where to break slides)
5
+ #
6
+ # e.g. changes:
7
+ # <h1 id='optional' class='optional'>
8
+ # to
9
+ # <!-- _S9SLIDE_ -->
10
+ # <h1 id='optional' class='optional'>
11
+
12
+ def add_slide_directive_before_h1( content )
13
+
14
+ # mark h1 for getting wrapped into slide divs
15
+ # note: use just <h1 since some processors add ids e.g. <h1 id='x'>
16
+
17
+ slide_count = 0
18
+
19
+ content.gsub!( /<h1/ ) do |match|
20
+ slide_count += 1
21
+ "\n<!-- _S9SLIDE_ -->\n#{Regexp.last_match(0)}"
22
+ end
23
+
24
+ puts " Adding #{slide_count} slide breaks (using h1 rule)..."
25
+
26
+ content
27
+ end
28
+
29
+ # add slide directive before div h1 (for pandoc-generated html)
30
+ #
31
+ # e.g. changes:
32
+ # <div id='header'>
33
+ # <h1 id='optional' class='optional'>
34
+ # to
35
+ # <!-- _S9SLIDE_ -->
36
+ # <div id='header'>
37
+ # <h1 id='optional' class='optional'>
38
+
39
+
40
+ def add_slide_directive_before_div_h1( content )
41
+
42
+ slide_count = 0
43
+
44
+ content.gsub!( /<div[^>]*>\s*<h1/ ) do |match|
45
+ slide_count += 1
46
+ "\n<!-- _S9SLIDE_ -->\n#{Regexp.last_match(0)}"
47
+ end
48
+
49
+ puts " Adding #{slide_count} slide breaks (using div_h1 rule)..."
50
+
51
+ content
52
+ end
53
+
54
+
55
+ end # module SlideFilter
56
+ end # module Slideshow
57
+
58
+ class Slideshow::Gen
59
+ include Slideshow::SlideFilter
60
+ end
@@ -15,9 +15,9 @@ def directives_bang_style_to_percent_style( content )
15
15
  # get unparsed helpers e.g. SLIDE|STYLE
16
16
  unparsed = config.helper_unparsed.map { |item| item.upcase }.join( '|' )
17
17
 
18
- content.gsub!(/^!(#{unparsed})/) do |match|
18
+ content.gsub!(/^!(#{unparsed})(.*)$/) do |match|
19
19
  bang_count += 1
20
- "%#{$1.downcase}"
20
+ "<%= #{$1.downcase} '#{$2}' %>"
21
21
  end
22
22
 
23
23
  puts " Patching !-directives (#{bang_count} #{config.helper_unparsed.join('/')}-directives)..."
@@ -27,6 +27,13 @@ end
27
27
 
28
28
  def directives_percent_style( content )
29
29
 
30
+ # skip filter for pandoc
31
+ # - pandoc uses % for its own markdown extension
32
+ # - don't process % pass it along/through to pandoc
33
+
34
+ return content if @markup_type == :markdown && @markdown_libs.first == 'pandoc-ruby'
35
+
36
+
30
37
  directive_unparsed = 0
31
38
  directive_expr = 0
32
39
  directive_block_beg = 0
@@ -88,6 +95,11 @@ end
88
95
 
89
96
 
90
97
  def comments_percent_style( content )
98
+
99
+ # skip filter for pandoc
100
+ # - pandoc uses % for its own markdown extension
101
+
102
+ return content if @markup_type == :markdown && @markdown_libs.first == 'pandoc-ruby'
91
103
 
92
104
  # remove comments
93
105
  # % comments
data/lib/slideshow/gen.rb CHANGED
@@ -519,78 +519,93 @@ class Gen
519
519
  end
520
520
 
521
521
  # convert light-weight markup to hypertext
522
-
522
+
523
523
  content = text_to_html( content )
524
-
524
+
525
525
  # post-processing
526
526
 
527
- slide_counter = 0
527
+ # 1) add slide break
528
+
529
+ if @markup_type == :markdown && @markdown_libs.first == 'pandoc-ruby'
530
+ content = add_slide_directive_before_div_h1( content )
531
+ else
532
+ content = add_slide_directive_before_h1( content )
533
+ end
534
+
535
+ dump_content_to_file_debug_html( content )
536
+
537
+ # 2) use generic slide break processing instruction to
538
+ # split content into slides
528
539
 
529
- slides = []
530
- slide_source = ""
540
+ slide_counter = 0
541
+
542
+ slides = []
543
+ slide_source = ""
531
544
 
532
- # wrap h1's in slide divs; note: use just <h1 since some processors add ids e.g. <h1 id='x'>
533
- content.each_line do |line|
534
- if line.include?( '<h1' ) || line.include?( '<!-- _S9SLIDE_' ) then
535
- if slide_counter > 0 then # found start of new slide (and, thus, end of last slide)
536
- slides << slide_source # add slide to slide stack
537
- slide_source = "" # reset slide source buffer
538
- end
539
- slide_counter += 1
540
- end
541
- slide_source << line
542
- end
545
+ content.each_line do |line|
546
+ if line.include?( '<!-- _S9SLIDE_' ) then
547
+ if slide_counter > 0 then # found start of new slide (and, thus, end of last slide)
548
+ slides << slide_source # add slide to slide stack
549
+ slide_source = "" # reset slide source buffer
550
+ end
551
+ slide_counter += 1
552
+ end
553
+ slide_source << line
554
+ end
543
555
 
544
- if slide_counter > 0 then
545
- slides << slide_source # add slide to slide stack
546
- slide_source = "" # reset slide source buffer
547
- end
556
+ if slide_counter > 0 then
557
+ slides << slide_source # add slide to slide stack
558
+ slide_source = "" # reset slide source buffer
559
+ end
548
560
 
549
- ## split slide source into header (optional) and content/body
550
- ## plus check for (css style) classes
561
+ ## split slide source into header (optional) and content/body
562
+ ## plus check for (css style) classes
551
563
 
552
- slides2 = []
553
- slides.each do |slide_source|
554
- slide = Slide.new
564
+ slides2 = []
565
+ slides.each do |slide_source|
566
+ slide = Slide.new
555
567
 
556
- ## check for css style classes
557
- from = 0
558
- while (pos = slide_source.index( /<!-- _S9(SLIDE|STYLE)_(.*?)-->/m, from ))
559
- logger.debug " adding css classes from pi #{$1.downcase}: #{$2.strip}"
568
+ ## check for css style classes
569
+ from = 0
570
+ while (pos = slide_source.index( /<!-- _S9(SLIDE|STYLE)_(.*?)-->/m, from ))
571
+ logger.debug " adding css classes from pi #{$1.downcase}: #{$2.strip}"
560
572
 
561
- if slide.classes.nil?
562
- slide.classes = $2.strip
563
- else
564
- slide.classes << " #{$2.strip}"
565
- end
573
+ if slide.classes.nil?
574
+ slide.classes = $2.strip
575
+ else
576
+ slide.classes << " #{$2.strip}"
577
+ end
566
578
 
567
- from = Regexp.last_match.end(0)
568
- end
579
+ from = Regexp.last_match.end(0)
580
+ end
569
581
 
570
- if slide_source =~ /^\s*(<h1.*?>.*?<\/h\d>)\s*(.*)/m # try to cut off header using non-greedy .+? pattern; tip test regex online at rubular.com
571
- slide.header = $1
572
- slide.content = ($2 ? $2 : "")
573
- logger.debug " adding slide with header:\n#{slide.header}"
574
- else
575
- slide.content = slide_source
576
- logger.debug " adding slide with *no* header:\n#{slide.content}"
582
+ # try to cut off header using non-greedy .+? pattern; tip test regex online at rubular.com
583
+ # note/fix: needs to get improved to also handle case for h1 wrapped into div
584
+ # (e.g. extract h1 - do not assume it starts slide source)
585
+ if slide_source =~ /^\s*(<h1.*?>.*?<\/h\d>)\s*(.*)/m
586
+ slide.header = $1
587
+ slide.content = ($2 ? $2 : "")
588
+ logger.debug " adding slide with header:\n#{slide.header}"
589
+ else
590
+ slide.content = slide_source
591
+ logger.debug " adding slide with *no* header:\n#{slide.content}"
592
+ end
593
+ slides2 << slide
577
594
  end
578
- slides2 << slide
579
- end
580
595
 
581
- # for convenience create a string w/ all in-one-html
582
- # no need to wrap slides in divs etc.
596
+ # for convenience create a string w/ all in-one-html
597
+ # no need to wrap slides in divs etc.
583
598
 
584
- content2 = ""
585
- slides2.each do |slide|
586
- content2 << slide.to_classic_html
587
- end
599
+ content2 = ""
600
+ slides2.each do |slide|
601
+ content2 << slide.to_classic_html
602
+ end
588
603
 
589
- # make content2 and slide2 available to erb template
590
- # -- todo: cleanup variable names and use attr_readers for content and slide
604
+ # make content2 and slide2 available to erb template
605
+ # -- todo: cleanup variable names and use attr_readers for content and slide
591
606
 
592
- @slides = slides2 # strutured content
593
- @content = content2 # content all-in-one
607
+ @slides = slides2 # strutured content
608
+ @content = content2 # content all-in-one
594
609
 
595
610
 
596
611
  manifest.each do |entry|
@@ -1,6 +1,11 @@
1
1
  module Slideshow
2
2
  module MarkdownEngines
3
3
 
4
+ def pandoc_ruby_to_html( content )
5
+ content = PandocRuby.new( content, :from => :markdown, :to => :html ).convert
6
+ content.gsub( /class="incremental"/, 'class="step"' )
7
+ end
8
+
4
9
  def rdiscount_to_html( content )
5
10
  RDiscount.new( content ).to_html
6
11
  end
data/lib/slideshow.rb CHANGED
@@ -46,11 +46,12 @@ require 'slideshow/helpers/syntax/sh_helper'
46
46
  require 'slideshow/filters/headers_filter'
47
47
  require 'slideshow/filters/text_filter'
48
48
  require 'slideshow/filters/debug_filter'
49
+ require 'slideshow/filters/slide_filter'
49
50
 
50
51
 
51
52
  module Slideshow
52
53
 
53
- VERSION = '0.9.2'
54
+ VERSION = '0.9.3'
54
55
 
55
56
  # version string for generator meta tag (includes ruby version)
56
57
  def Slideshow.generator
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slideshow
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
4
+ hash: 61
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 2
10
- version: 0.9.2
9
+ - 3
10
+ version: 0.9.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gerald Bauer
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-11 00:00:00 +02:00
18
+ date: 2010-07-13 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -107,6 +107,7 @@ files:
107
107
  - lib/slideshow/config.rb
108
108
  - lib/slideshow/filters/debug_filter.rb
109
109
  - lib/slideshow/filters/headers_filter.rb
110
+ - lib/slideshow/filters/slide_filter.rb
110
111
  - lib/slideshow/filters/text_filter.rb
111
112
  - lib/slideshow/gen.rb
112
113
  - lib/slideshow/helpers/analytics_helper.rb