Class: Awestruct::Handlers::AsciidocHandler

Inherits:
BaseHandler
  • Object
show all
Defined in:
lib/awestruct/handlers/asciidoc_handler.rb

Constant Summary collapse

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

Instance Attribute Summary

Attributes inherited from BaseHandler

#delegate, #site

Instance Method Summary collapse

Methods inherited from BaseHandler

#content_line_offset, #dependencies, #execute_shell, #front_matter, #inherit_front_matter, #input_mtime, #output_path, #path, #raw_content, #relative_source_path, #stale?, #to_chain

Constructor Details

#initialize(site, delegate) ⇒ AsciidocHandler

Returns a new instance of AsciidocHandler.



21
22
23
# File 'lib/awestruct/handlers/asciidoc_handler.rb', line 21

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

Instance Method Details

#content_syntaxObject



38
39
40
# File 'lib/awestruct/handlers/asciidoc_handler.rb', line 38

def content_syntax
  :asciidoc
end

#output_extensionObject



34
35
36
# File 'lib/awestruct/handlers/asciidoc_handler.rb', line 34

def output_extension
  '.html' 
end

#output_filenameObject



30
31
32
# File 'lib/awestruct/handlers/asciidoc_handler.rb', line 30

def output_filename
  simple_name + output_extension
end

#rendered_content(context, with_layouts = true) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/awestruct/handlers/asciidoc_handler.rb', line 42

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

#simple_nameObject



25
26
27
28
# File 'lib/awestruct/handlers/asciidoc_handler.rb', line 25

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