Sha256: f6fa95aa08c96c9bd8eec23ea8e376f0bf4c3642cec175c522ba1944423f9d47

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

require 'awestruct/handler_chain'
require 'awestruct/handlers/base_handler'
require 'awestruct/handlers/file_handler'
require 'awestruct/handlers/front_matter_handler'
require 'awestruct/handlers/interpolation_handler'
require 'awestruct/handlers/layout_handler'
require 'rdiscount'

module Awestruct
  module Handlers
    class MarkdownHandler < BaseHandler


      CHAIN = Awestruct::HandlerChain.new( /\.md$/,
        Awestruct::Handlers::FileHandler,
        Awestruct::Handlers::FrontMatterHandler,
        Awestruct::Handlers::InterpolationHandler,
        Awestruct::Handlers::MarkdownHandler,
        Awestruct::Handlers::LayoutHandler
      )

      def initialize(site, delegate)
        super( site, delegate )
      end

      def simple_name
        File.basename( relative_source_path, '.md' ) 
      end

      def output_filename
        File.basename( relative_source_path, '.md' ) + '.html'
      end

      def output_extension
        '.html'
      end

      def content_syntax
        :markdown
      end

      def rendered_content(context, with_layouts=true)
        doc = RDiscount.new( raw_content )
        doc.to_html
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
awestruct-0.4.2.x2 lib/awestruct/handlers/markdown_handler.rb
awestruct-0.4.2.x1 lib/awestruct/handlers/markdown_handler.rb
awestructx-0.4.1.x1 lib/awestruct/handlers/markdown_handler.rb