class Jekyll::Converters::DyndocConverter

Public Class Methods

new(config) click to toggle source
# File lib/jekyll-dyndoc.rb, line 9
def initialize(config)
  @config = config
  config['dyndoc'] ||= 'dyndoc-server'
  dyndoc_ext = (config['dyndoc_ext'] ||= 'dyn')
  config['dyndoc_ext_re'] = Regexp.new("\.(#{dyndoc_ext.tr ',', '|'})$", Regexp::IGNORECASE)
  config['dyndoc_page_attribute_prefix'] ||= 'page'
  # unless (dyndoc_config = (config['dyndoc'] ||= {})).frozen?
  #   # NOTE convert keys to symbols
  #   dyndoc_config.keys.each do |key|
  #     dyndoc_config[key.to_sym] = dyndoc_config.delete(key)
  #   end
  #   dyndoc_config[:safe] ||= 'safe'
  #   (dyndoc_config[:attributes] ||= []).tap do |attributes|
  #     attributes.unshift('notitle', 'hardbreaks', 'idprefix', 'idseparator=-', 'linkattrs')
  #     attributes.concat(IMPLICIT_ATTRIBUTES)
  #   end
  #   dyndoc_config.freeze
  # end
end

Public Instance Methods

convert(content) click to toggle source
# File lib/jekyll-dyndoc.rb, line 56
def convert(content)
  setup
  p [:config,@config]
  case @config['dyndoc']
  when 'dyndoc'
    res=Dyndoc.convert(content, @config['dyndoc'])
    p [:res,res]
    res || ""
  when 'dyndoc-server'
    p [:content,content]
    res=Dyndoc.cli_convert(content, @config['dyndoc'])
    p [:res,res]
    res || ""
  else
    warn 'Unknown Dyndoc converter. Passing through raw content.'
    content
  end
end
matches(ext) click to toggle source
# File lib/jekyll-dyndoc.rb, line 48
def matches(ext)
  ext =~ @config['dyndoc_ext_re']
end
output_ext(ext) click to toggle source
# File lib/jekyll-dyndoc.rb, line 52
def output_ext(ext)
  '.html'
end
setup() click to toggle source
# File lib/jekyll-dyndoc.rb, line 29
def setup
  return if @setup
  @setup = true
  case @config['dyndoc']
  when 'dyndoc','dyndoc-server'
    begin
      require 'dyndoc-convert' unless defined? ::Dyndoc
    rescue LoadError
      STDERR.puts 'You are missing a library required to convert Dyndoc files. Please run:'
      STDERR.puts '  $ [sudo] gem install dyndoc-ruby'
      raise FatalException.new('Missing dependency: dyndoc')
    end
  else
    STDERR.puts "Invalid Dyndoc processor: #{@config['dyndoc']}"
    STDERR.puts '  Valid options are [ dyndoc ]'
    raise FatalException.new("Invalid Dyndoc processor: #{@config['dyndoc']}")
  end
end