module Slideshow ## fix:/todo: move generation code out of command into its own class ## not residing/depending on cli class Gen include ManifestHelper ### fix: remove opts, use config (wrapped!!) def initialize( logger, opts, config, headers ) @logger = logger @opts = opts @config = config @headers = headers end attr_reader :logger, :opts, :config, :headers attr_reader :session # give helpers/plugins a session-like hash attr_reader :markup_type # :textile, :markdown, :rest # uses configured markup processor (textile,markdown,rest) to generate html def text_to_html( content ) content = case @markup_type when :markdown markdown_to_html( content ) when :textile textile_to_html( content ) when :rest rest_to_html( content ) end content end def guard_text( text ) # todo/fix 2: note for Textile we need to differentiate between blocks and inline # thus, to avoid runs - use guard_block (add a leading newline to avoid getting include in block that goes before) # todo/fix: remove wrap_markup; replace w/ guard_text # why: text might be css, js, not just html wrap_markup( text ) end def guard_block( text ) if markup_type == :textile # saveguard with notextile wrapper etc./no further processing needed # note: add leading newlines to avoid block-runons "\n\n\n#{text}\n\n" else text end end def guard_inline( text ) wrap_markup( text ) end def wrap_markup( text ) if markup_type == :textile # saveguard with notextile wrapper etc./no further processing needed "\n#{text}\n" else text end end ## fix:/todo: check if these get called ## from helpers ## fix: cleanup and remove def load_template( path ) puts " Loading template #{path}..." return File.read( path ) end def render_template( content, the_binding ) ERB.new( content ).result( the_binding ) end # move into a filter?? def post_processing_slides( content ) # 1) add slide break if (@markup_type == :markdown && Markdown.lib == 'pandoc-ruby') || @markup_type == :rest content = add_slide_directive_before_div_h1( content ) else if config.header_level == 2 content = add_slide_directive_before_h2( content ) else # assume level 1 content = add_slide_directive_before_h1( content ) end end dump_content_to_file_debug_html( content ) # 2) use generic slide break processing instruction to # split content into slides slide_counter = 0 slides = [] slide_source = "" content.each_line do |line| if line.include?( '