slideshow 1.1.0.beta2 → 1.1.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -1
- data/lib/slideshow.rb +3 -1
- data/lib/slideshow/filters/text_filter.rb +19 -218
- metadata +29 -13
data/Rakefile
CHANGED
data/lib/slideshow.rb
CHANGED
@@ -34,6 +34,8 @@ class Env
|
|
34
34
|
end
|
35
35
|
end # class Env
|
36
36
|
|
37
|
+
require 'textutils' # text filters and helpers
|
38
|
+
|
37
39
|
|
38
40
|
# our own code
|
39
41
|
require 'slideshow/opts'
|
@@ -68,7 +70,7 @@ require 'slideshow/filters/slide_filter'
|
|
68
70
|
|
69
71
|
module Slideshow
|
70
72
|
|
71
|
-
VERSION = '1.1.0.
|
73
|
+
VERSION = '1.1.0.beta3'
|
72
74
|
|
73
75
|
def self.root
|
74
76
|
"#{File.expand_path( File.dirname(File.dirname(__FILE__)) )}"
|
@@ -8,6 +8,22 @@
|
|
8
8
|
module Slideshow
|
9
9
|
module TextFilter
|
10
10
|
|
11
|
+
include TextUtils::Filter # include comments_percent_style, skip_end_directive, etc. filters
|
12
|
+
|
13
|
+
alias_method :old_comments_percent_style, :comments_percent_style
|
14
|
+
|
15
|
+
def comments_percent_style( content )
|
16
|
+
|
17
|
+
# skip filter for pandoc
|
18
|
+
# - pandoc uses % for its own markdown extension
|
19
|
+
return content if @markup_type == :markdown && Markdown.lib == 'pandoc-ruby'
|
20
|
+
|
21
|
+
old_comments_percent_style( content )
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
11
27
|
def directives_bang_style_to_percent_style( content )
|
12
28
|
|
13
29
|
# for compatibility allow !SLIDE/!STYLE as an alternative to %slide/%style-directive
|
@@ -94,66 +110,11 @@ def directives_percent_style( content )
|
|
94
110
|
content2
|
95
111
|
end
|
96
112
|
|
113
|
+
######################
|
114
|
+
# todo: fix move to textutils gem (including helpers and config)
|
115
|
+
#
|
97
116
|
|
98
117
|
|
99
|
-
def comments_percent_style( content )
|
100
|
-
|
101
|
-
# skip filter for pandoc
|
102
|
-
# - pandoc uses % for its own markdown extension
|
103
|
-
|
104
|
-
return content if @markup_type == :markdown && Markdown.lib == 'pandoc-ruby'
|
105
|
-
|
106
|
-
# remove comments
|
107
|
-
# % comments
|
108
|
-
# %begin multiline comment
|
109
|
-
# %end multiline comment
|
110
|
-
|
111
|
-
# track statistics
|
112
|
-
comments_multi = 0
|
113
|
-
comments_single = 0
|
114
|
-
comments_end = 0
|
115
|
-
|
116
|
-
# remove multi-line comments
|
117
|
-
content.gsub!(/^%(begin|comment|comments).*?%end/m) do |match|
|
118
|
-
comments_multi += 1
|
119
|
-
""
|
120
|
-
end
|
121
|
-
|
122
|
-
# remove everyting starting w/ %end (note, can only be once in file)
|
123
|
-
content.sub!(/^%end.*/m) do |match|
|
124
|
-
comments_end += 1
|
125
|
-
""
|
126
|
-
end
|
127
|
-
|
128
|
-
# hack/note:
|
129
|
-
# note multi-line erb expressions/stmts might cause trouble
|
130
|
-
#
|
131
|
-
# %> gets escaped as special case (not treated as comment)
|
132
|
-
# <%
|
133
|
-
# whatever
|
134
|
-
# %> <!-- trouble here; would get removed as comment!
|
135
|
-
# todo: issue warning?
|
136
|
-
|
137
|
-
# remove single-line comments
|
138
|
-
content.gsub!(/(^%$)|(^%[^>].*)/ ) do |match|
|
139
|
-
comments_single += 1
|
140
|
-
""
|
141
|
-
end
|
142
|
-
|
143
|
-
puts " Removing %-comments (#{comments_single} lines, " +
|
144
|
-
"#{comments_multi} begin/end-blocks, #{comments_end} end-blocks)..."
|
145
|
-
|
146
|
-
content
|
147
|
-
end
|
148
|
-
|
149
|
-
def skip_end_directive( content )
|
150
|
-
# codex-style __SKIP__, __END__ directive
|
151
|
-
# ruby note: .*? is non-greedy (shortest-possible) regex match
|
152
|
-
content.gsub!(/__SKIP__.*?__END__/m, '')
|
153
|
-
content.sub!(/__END__.*/m, '')
|
154
|
-
content
|
155
|
-
end
|
156
|
-
|
157
118
|
def erb_rename_helper_hack( content )
|
158
119
|
# note: include is a ruby keyword; rename to s9_include so we can use it
|
159
120
|
|
@@ -173,166 +134,6 @@ def comments_percent_style( content )
|
|
173
134
|
content
|
174
135
|
end
|
175
136
|
|
176
|
-
# allow plugins/helpers; process source (including header) using erb
|
177
|
-
def erb( content )
|
178
|
-
puts " Running embedded Ruby (erb) code/helpers..."
|
179
|
-
|
180
|
-
content = ERB.new( content ).result( binding() )
|
181
|
-
content
|
182
|
-
end
|
183
|
-
|
184
|
-
def erb_simple_params( method, params )
|
185
|
-
|
186
|
-
# replace params to support html like attributes e.g.
|
187
|
-
# plus add comma separator
|
188
|
-
#
|
189
|
-
# class=part -> :class => 'part'
|
190
|
-
# 3rd/tutorial -> '3rd/tutorial'
|
191
|
-
# :css -> :css
|
192
|
-
|
193
|
-
return params if params.nil? || params.strip.empty?
|
194
|
-
|
195
|
-
params.strip!
|
196
|
-
## todo: add check for " ??
|
197
|
-
if params.include?( '=>' )
|
198
|
-
puts "** warning: skipping patching of params for helper '#{method}'; already includes '=>':"
|
199
|
-
puts " #{params}"
|
200
|
-
|
201
|
-
return params
|
202
|
-
end
|
203
|
-
|
204
|
-
before = params.clone
|
205
|
-
|
206
|
-
# 1) string-ify values and keys (that is, wrap in '')
|
207
|
-
# plus separate w/ commas
|
208
|
-
params.gsub!( /([:a-zA-Z0-9#][\w\/\-\.#()]*)|('[^'\n]*')/) do |match|
|
209
|
-
symbol = ( Regexp.last_match( 0 )[0,1] == ':' )
|
210
|
-
quoted = ( Regexp.last_match( 0 )[0,1] == "'" )
|
211
|
-
if symbol || quoted # return symbols or quoted string as is
|
212
|
-
"#{Regexp.last_match( 0 )},"
|
213
|
-
else
|
214
|
-
"'#{Regexp.last_match( 0 )}',"
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
# 2) symbol-ize hash keys
|
219
|
-
# change = to =>
|
220
|
-
# remove comma for key/value pairs
|
221
|
-
params.gsub!( /'(\w+)',[ \t]*=/ ) do |match|
|
222
|
-
":#{$1}=>"
|
223
|
-
end
|
224
|
-
|
225
|
-
# 3) remove trailing comma
|
226
|
-
params.sub!( /[ \t]*,[ \t]*$/, '' )
|
227
|
-
|
228
|
-
puts " Patching params for helper '#{method}' from '#{before}' to:"
|
229
|
-
puts " #{params}"
|
230
|
-
|
231
|
-
params
|
232
|
-
end
|
233
|
-
|
234
|
-
|
235
|
-
def erb_django_simple_params( code )
|
236
|
-
|
237
|
-
# split into method/directive and parms plus convert params
|
238
|
-
code.sub!( /^[ \t]([\w.]+)(.*)/ ) do |match|
|
239
|
-
directive = $1
|
240
|
-
params = $2
|
241
|
-
|
242
|
-
"#{directive} #{params ? erb_simple_params(directive,params) : ''}"
|
243
|
-
end
|
244
|
-
|
245
|
-
code
|
246
|
-
end
|
247
|
-
|
248
|
-
def erb_django_style( content )
|
249
|
-
|
250
|
-
# replace expressions (support for single lines only)
|
251
|
-
# {{ expr }} -> <%= expr %>
|
252
|
-
# {% stmt %} -> <% stmt %> !! add in do if missing (for convenience)
|
253
|
-
#
|
254
|
-
# use use {{{ or {{{{ to escape expr back to literal value
|
255
|
-
# and use {%% %} to escape stmts
|
256
|
-
|
257
|
-
erb_expr = 0
|
258
|
-
erb_stmt_beg = 0
|
259
|
-
erb_stmt_end = 0
|
260
|
-
|
261
|
-
content.gsub!( /(\{{2,4})([^{}\n]+?)(\}{2,4})/ ) do |match|
|
262
|
-
escaped = ($1.length > 2)
|
263
|
-
if escaped
|
264
|
-
"{{#{$2}}}"
|
265
|
-
else
|
266
|
-
erb_expr += 1
|
267
|
-
"<%= #{erb_django_simple_params($2)} %>"
|
268
|
-
end
|
269
|
-
end
|
270
|
-
|
271
|
-
content.gsub!( /(\{%{1,2})([ \t]*end[ \t]*)%\}/ ) do |match|
|
272
|
-
escaped = ($1.length > 2)
|
273
|
-
if escaped
|
274
|
-
"{%#{$2}%}"
|
275
|
-
else
|
276
|
-
erb_stmt_end += 1
|
277
|
-
"<% end %>"
|
278
|
-
end
|
279
|
-
end
|
280
|
-
|
281
|
-
content.gsub!( /(\{%{1,2})([^%\n]+?)%\}/ ) do |match|
|
282
|
-
escaped = ($1.length > 2)
|
283
|
-
if escaped
|
284
|
-
"{%#{$2}%}"
|
285
|
-
else
|
286
|
-
erb_stmt_beg += 1
|
287
|
-
"<% #{erb_django_simple_params($2)} do %>"
|
288
|
-
end
|
289
|
-
end
|
290
|
-
|
291
|
-
puts " Patching embedded Ruby (erb) code Django-style (#{erb_expr} {{-expressions," +
|
292
|
-
" #{erb_stmt_beg}/#{erb_stmt_end} {%-statements)..."
|
293
|
-
|
294
|
-
content
|
295
|
-
end
|
296
|
-
|
297
|
-
def code_block_curly_style( content )
|
298
|
-
# replace {{{ w/ <pre class='code'>
|
299
|
-
# replace }}} w/ </pre>
|
300
|
-
# use 4-6 { or } to escape back to literal value (e.g. {{{{ or {{{{{{ => {{{ )
|
301
|
-
# note: {{{ / }}} are anchored to beginning of line ( spaces and tabs before {{{/}}}allowed )
|
302
|
-
|
303
|
-
# track statistics
|
304
|
-
code_begin = 0
|
305
|
-
code_begin_esc = 0
|
306
|
-
code_end = 0
|
307
|
-
code_end_esc = 0
|
308
|
-
|
309
|
-
content.gsub!( /^[ \t]*(\{{3,6})/ ) do |match|
|
310
|
-
escaped = ($1.length > 3)
|
311
|
-
if escaped
|
312
|
-
code_begin_esc += 1
|
313
|
-
"{{{"
|
314
|
-
else
|
315
|
-
code_begin += 1
|
316
|
-
"<pre class='code'>"
|
317
|
-
end
|
318
|
-
end
|
319
|
-
|
320
|
-
content.gsub!( /^[ \t]*(\}{3,6})/ ) do |match|
|
321
|
-
escaped = ($1.length > 3)
|
322
|
-
if escaped
|
323
|
-
code_end_esc += 1
|
324
|
-
"}}}"
|
325
|
-
else
|
326
|
-
code_end += 1
|
327
|
-
"</pre>"
|
328
|
-
end
|
329
|
-
end
|
330
|
-
|
331
|
-
puts " Patching {{{/}}}-code blocks (#{code_begin}/#{code_end} blocks, " +
|
332
|
-
"#{code_begin_esc}/#{code_end_esc} escaped blocks)..."
|
333
|
-
|
334
|
-
content
|
335
|
-
end
|
336
137
|
|
337
138
|
end # module TextFilter
|
338
139
|
end # module Slideshow
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slideshow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1059591029
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
9
|
- 0
|
10
10
|
- beta
|
11
|
-
-
|
12
|
-
version: 1.1.0.
|
11
|
+
- 3
|
12
|
+
version: 1.1.0.beta3
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Gerald Bauer
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2012-06-
|
20
|
+
date: 2012-06-09 00:00:00 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: RedCloth
|
@@ -39,6 +39,22 @@ dependencies:
|
|
39
39
|
name: markdown
|
40
40
|
prerelease: false
|
41
41
|
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
hash: 19
|
47
|
+
segments:
|
48
|
+
- 0
|
49
|
+
- 3
|
50
|
+
- 0
|
51
|
+
version: 0.3.0
|
52
|
+
type: :runtime
|
53
|
+
version_requirements: *id002
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: textutils
|
56
|
+
prerelease: false
|
57
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
58
|
none: false
|
43
59
|
requirements:
|
44
60
|
- - ">="
|
@@ -50,11 +66,11 @@ dependencies:
|
|
50
66
|
- 0
|
51
67
|
version: 0.2.0
|
52
68
|
type: :runtime
|
53
|
-
version_requirements: *
|
69
|
+
version_requirements: *id003
|
54
70
|
- !ruby/object:Gem::Dependency
|
55
71
|
name: fetcher
|
56
72
|
prerelease: false
|
57
|
-
requirement: &
|
73
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
58
74
|
none: false
|
59
75
|
requirements:
|
60
76
|
- - ">="
|
@@ -66,11 +82,11 @@ dependencies:
|
|
66
82
|
- 0
|
67
83
|
version: 0.1.0
|
68
84
|
type: :runtime
|
69
|
-
version_requirements: *
|
85
|
+
version_requirements: *id004
|
70
86
|
- !ruby/object:Gem::Dependency
|
71
87
|
name: props
|
72
88
|
prerelease: false
|
73
|
-
requirement: &
|
89
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
74
90
|
none: false
|
75
91
|
requirements:
|
76
92
|
- - ">="
|
@@ -82,11 +98,11 @@ dependencies:
|
|
82
98
|
- 0
|
83
99
|
version: 0.1.0
|
84
100
|
type: :runtime
|
85
|
-
version_requirements: *
|
101
|
+
version_requirements: *id005
|
86
102
|
- !ruby/object:Gem::Dependency
|
87
103
|
name: rdoc
|
88
104
|
prerelease: false
|
89
|
-
requirement: &
|
105
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
90
106
|
none: false
|
91
107
|
requirements:
|
92
108
|
- - ~>
|
@@ -97,11 +113,11 @@ dependencies:
|
|
97
113
|
- 10
|
98
114
|
version: "3.10"
|
99
115
|
type: :development
|
100
|
-
version_requirements: *
|
116
|
+
version_requirements: *id006
|
101
117
|
- !ruby/object:Gem::Dependency
|
102
118
|
name: hoe
|
103
119
|
prerelease: false
|
104
|
-
requirement: &
|
120
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
105
121
|
none: false
|
106
122
|
requirements:
|
107
123
|
- - ~>
|
@@ -112,7 +128,7 @@ dependencies:
|
|
112
128
|
- 0
|
113
129
|
version: "3.0"
|
114
130
|
type: :development
|
115
|
-
version_requirements: *
|
131
|
+
version_requirements: *id007
|
116
132
|
description: |-
|
117
133
|
The Slide Show (S9) Ruby gem lets you create slide shows and author slides in plain text
|
118
134
|
using a wiki-style markup language that's easy-to-write and easy-to-read.
|