Skip to content
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 committed
Showing with 12 additions and 5 deletions.
  1. +4 −1 lib/showoff.rb
  2. +8 −4 lib/showoff_utils.rb
View
5 lib/showoff.rb
@@ -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
12 lib/showoff_utils.rb
@@ -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))
+ 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.
Something went wrong with that request. Please try again.