slideshow 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/slideshow.rb +34 -10
  2. metadata +2 -2
data/lib/slideshow.rb CHANGED
@@ -111,8 +111,13 @@ def Slideshow.create_slideshow( fn )
111
111
  # run pre-filters (built-in macros)
112
112
  # o replace {{{ w/ <pre class='code'>
113
113
  # o replace }}} w/ </pre>
114
+ content.gsub!( "{{{{{{", "<pre class='code'>_S9BEGIN_" )
115
+ content.gsub!( "}}}}}}", "_S9END_</pre>" )
114
116
  content.gsub!( "{{{", "<pre class='code'>" )
115
117
  content.gsub!( "}}}", "</pre>" )
118
+ # restore escaped {{{}}} I'm sure there's a better way! Rubyize this! Anyone?
119
+ content.gsub!( "_S9BEGIN_", "{{{" )
120
+ content.gsub!( "_S9END_", "}}}" )
116
121
 
117
122
  set_default_options()
118
123
  params = Params.new( basename, $options )
@@ -130,7 +135,7 @@ def Slideshow.create_slideshow( fn )
130
135
 
131
136
  if known_markdown_extnames.include?( extname )
132
137
  content = Maruku.new( content, {:on_error => :raise} ).to_html
133
- # content = BlueCloth.new( content ).to_html
138
+ # old code: content = BlueCloth.new( content ).to_html
134
139
  else
135
140
  content = RedCloth.new( content ).to_html
136
141
  end
@@ -152,20 +157,39 @@ def Slideshow.create_slideshow( fn )
152
157
  }
153
158
  content2 << "\n\n</div>" if slide_counter > 0
154
159
 
160
+ ## todo: run syntax highlighting before markup/textilize? lets us add textile to highlighted code?
161
+ ## avoid undoing escaped entities?
162
+
155
163
  include_code_stylesheet = false
156
164
  # syntax highlight code
157
- # todo: can the code handle escaped entities? e.g. &gt;
165
+ # todo: can the code handle escaped entities? e.g. &gt;
158
166
  doc = Hpricot(content2)
159
167
  doc.search("pre.code, pre > code").each do |e|
160
168
  if e.inner_html =~ /^\s*#!(\w+)/
161
169
  lang = $1.downcase
162
- logger.debug " syntax highlighting using lang=#{lang}"
163
- if Uv.syntaxes.include?(lang)
164
- # e.inner_html = Uv.parse( e.inner_html.sub(/^\s*#!\w+/, '').strip, "xhtml", lang, get_boolean_option( 'code-line-numbers', true ), get_option( 'code-theme', 'amy' ))
165
- # todo: is it ok to replace the pre.code enclosing element to avoid duplicates?
166
- html = Uv.parse( e.inner_html.sub(/^\s*#!\w+/, '').strip, "xhtml", lang, get_boolean_option( 'code-line-numbers', true ), get_option( 'code-theme', 'amy' ))
167
- e.swap( html )
168
- include_code_stylesheet = true
170
+ if e.inner_html =~ /^\{\{\{/ # {{{ assumes escape/literal #!lang
171
+ # do nothing; next
172
+ logger.debug " skipping syntax highlighting using lang=#{lang}; assumimg escaped literal"
173
+ else
174
+ logger.debug " syntax highlighting using lang=#{lang}"
175
+ if Uv.syntaxes.include?(lang)
176
+ code = e.inner_html.sub(/^\s*#!\w+/, '').strip
177
+
178
+ code.gsub!( "&lt;", "<" )
179
+ code.gsub!( "&gt;", ">" )
180
+ code.gsub!( "&amp;", "&" )
181
+ # todo: missing any other entities? use CGI::unescapeHTML?
182
+ logger.debug "code=>#{code}<"
183
+
184
+ # get options using headers
185
+ code_line_numbers = get_boolean_option( 'code-line-numbers', true )
186
+ code_theme = get_option( 'code-theme', 'amy' )
187
+ code_highlighted = Uv.parse( code, "xhtml", lang, code_line_numbers, code_theme )
188
+ # old code: e.inner_html = code_highlighted
189
+ # todo: is it ok to replace the pre.code enclosing element to avoid duplicates?
190
+ e.swap( code_highlighted )
191
+ include_code_stylesheet = true
192
+ end
169
193
  end
170
194
  end
171
195
  end
@@ -306,7 +330,7 @@ def Slideshow.main
306
330
 
307
331
  opt.parse!
308
332
 
309
- puts "Slide Show (S9) Version: 0.4.1 on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
333
+ puts "Slide Show (S9) Version: 0.4.2 on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
310
334
 
311
335
  ARGV.each { |fn| Slideshow.create_slideshow( fn ) }
312
336
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slideshow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-05-18 00:00:00 -07:00
12
+ date: 2008-05-20 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency