Permalink
Browse files

Added support for passing options hash from showoff config file to re…

…ndering engine via Tilt.

Previously, some options were handled manually for the Maruku engine, but not for any of the others. The markdown engine wrappers in Tilt allow the passing of options to the various libraries through a hash given with the renderer is instantiated. The special handling in Showoff for the Maruku engine have been left unchanged for now, but it might be possible to migrate the code to use the same mechanism in the future. (I haven't used Maruku yet myself, so I didn't want to mess with the config code.)
  • Loading branch information...
1 parent 3d96631 commit ed095345862f7aaf28fb175aaf619aefae18d77d @MichaelHackett MichaelHackett committed Sep 13, 2012
Showing with 12 additions and 5 deletions.
  1. +4 −1 lib/showoff.rb
  2. +8 −4 lib/showoff_utils.rb
View
@@ -150,6 +150,9 @@ def process_markdown(name, content, static=false, pdf=false)
if settings.encoding and content.respond_to?(:force_encoding)
content.force_encoding(settings.encoding)
end
+ engine_options = ShowOffUtils.showoff_renderer_options(settings.pres_dir)
+ @logger.debug "renderer: #{Tilt[:markdown].name}"
+ @logger.debug "render options: #{engine_options.inspect}"
# if there are no !SLIDE markers, then make every H1 define a new slide
unless content =~ /^\<?!SLIDE/m
@@ -216,7 +219,7 @@ def process_markdown(name, content, static=false, pdf=false)
else
content += "<div class=\"#{content_classes.join(' ')}\" ref=\"#{name}\">\n"
end
- sl = Tilt[:markdown].new { slide.text }.render
+ sl = Tilt[:markdown].new(nil, nil, engine_options) { slide.text }.render
sl = update_image_paths(name, sl, static, pdf)
content += sl
content += "</div>\n"
View
@@ -314,6 +314,10 @@ def self.showoff_markdown(dir = ".")
get_config_option(dir, "markdown", "redcarpet")
end
+ def self.showoff_renderer_options(dir = '.', default_options = {})
+ opts = get_config_option(dir, showoff_markdown(dir))
@binford2k

binford2k Dec 27, 2013

Where did the default_options go?

@MichaelHackett

MichaelHackett Dec 30, 2013

Contributor

Very good question! :-) I can't test at the moment, but it looks default_options should be added as the third arg to get_config_option. I guess I must have been using an actual config file, and didn't notice that the defaults were gone.

@binford2k

binford2k Dec 30, 2013

That's what I did when I incorporated your fixes into the Puppet Labs fork. We're now upstream, so you should take a look at our fork when you get a chance. I'd love it if you tested my integration with your existing use case, as well.

+ end
+
def self.get_config_option(dir, option, default = nil)
index = File.join(dir, ShowOffUtils.presentation_config_file)
if File.exists?(index)
@@ -408,10 +412,10 @@ def self.setup(dir_name)
require 'maruku/ext/math'
# Load maruku options
- opts = ShowOffUtils.get_config_option(dir_name, 'maruku',
- { 'use_tex' => false,
- 'png_dir' => 'images',
- 'html_png_url' => '/file/images/'})
+ opts = ShowOffUtils.showoff_renderer_options(dir_name,
+ { 'use_tex' => false,
+ 'png_dir' => 'images',
+ 'html_png_url' => '/file/images/'})
if opts['use_tex']
MaRuKu::Globals[:html_math_output_mathml] = false

0 comments on commit ed09534

Please sign in to comment.