Skip to content

Commit

Permalink
Added support for passing options hash from showoff config file to re…
Browse files Browse the repository at this point in the history
…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
MichaelHackett committed Sep 13, 2012
1 parent 3d96631 commit ed09534
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 4 additions & 1 deletion lib/showoff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
12 changes: 8 additions & 4 deletions lib/showoff_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ed09534

Please sign in to comment.