Sha256: 4842a9729418560635d9b2f2373455dfe703d332357e2d7623f4dbd5c53802dc

Contents?: true

Size: 1.73 KB

Versions: 17

Compression:

Stored size: 1.73 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'

module Awestruct
  module Handlers
    class AsciidocHandler < BaseHandler

      CHAIN = Awestruct::HandlerChain.new( /\.(adoc|asciidoc)$/,
        Awestruct::Handlers::FileHandler,
        Awestruct::Handlers::FrontMatterHandler,
        Awestruct::Handlers::InterpolationHandler,
        Awestruct::Handlers::AsciidocHandler,
        Awestruct::Handlers::LayoutHandler
      )

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

      def simple_name
        p = File.basename( relative_source_path )
        File.basename( p, File.extname( p ) )
      end

      def output_filename
        simple_name + output_extension
      end

      def output_extension
        '.html' 
      end

      def content_syntax
        :asciidoc
      end

      def rendered_content(context, with_layouts=true)
        content = delegate.rendered_content( context, with_layouts )
        imagesdir = site.config.images_dir
        iconsdir = File.join(imagesdir, 'icons')
        conffile = File.join(site.config.config_dir, 'asciidoc.conf')
        confopt = File.exist?(conffile) ? '-f ' + conffile : ''
        content = execute_shell( [ "asciidoc -s -b html5 -a pygments -a icons",
                                   "-a iconsdir='#{iconsdir}'",
                                   "-a imagesdir='#{imagesdir}'",
                                   "#{confopt} -o - -" ].join( ' ' ),
                                 content)
        content.gsub( "\r", '' )
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
awestruct-0.4.7 lib/awestruct/handlers/asciidoc_handler.rb
awestruct-0.4.6 lib/awestruct/handlers/asciidoc_handler.rb
awestruct-0.4.5 lib/awestruct/handlers/asciidoc_handler.rb
awestruct-0.4.4 lib/awestruct/handlers/asciidoc_handler.rb
awestruct-0.4.3 lib/awestruct/handlers/asciidoc_handler.rb
awestruct-0.4.2 lib/awestruct/handlers/asciidoc_handler.rb
awestruct-0.4.2.x10 lib/awestruct/handlers/asciidoc_handler.rb
awestruct-0.4.2.x9 lib/awestruct/handlers/asciidoc_handler.rb
awestruct-0.4.2.x8 lib/awestruct/handlers/asciidoc_handler.rb
awestruct-0.4.2.x7 lib/awestruct/handlers/asciidoc_handler.rb
awestruct-0.4.2.x6 lib/awestruct/handlers/asciidoc_handler.rb
awestruct-0.4.2.x5 lib/awestruct/handlers/asciidoc_handler.rb
awestruct-0.4.2.x4 lib/awestruct/handlers/asciidoc_handler.rb
awestruct-0.4.2.x3 lib/awestruct/handlers/asciidoc_handler.rb
awestruct-0.4.2.x2 lib/awestruct/handlers/asciidoc_handler.rb
awestruct-0.4.2.x1 lib/awestruct/handlers/asciidoc_handler.rb
awestructx-0.4.1.x1 lib/awestruct/handlers/asciidoc_handler.rb