class Jekyll::AsciiDoc::Converter
Constants
- AttributeReferenceRx
- DefaultAttributes
- DefaultFileExtensions
- DefaultPageAttributePrefix
- HeaderBoundaryRx
- HeaderLineRx
- ImplicitAttributes
- MessageTopic
- NewLine
Public Class Methods
new(config)
click to toggle source
# File lib/jekyll-asciidoc/converter.rb, line 34 def initialize config @config = config @logger = ::Jekyll.logger @page_context = {} # NOTE jekyll-watch reinitializes plugins using a shallow clone of config, so no need to reconfigure # NOTE check for Configured only works if value of key is defined in _config.yml as Hash unless Configured === (asciidoc_config = (config['asciidoc'] ||= {})) if ::String === asciidoc_config @logger.warn MessageTopic, 'The AsciiDoc configuration should be defined using Hash on asciidoc key instead of discrete entries.' asciidoc_config = config['asciidoc'] = { 'processor' => asciidoc_config } else asciidoc_config['processor'] ||= 'asciidoctor' end old_asciidoc_ext = config.delete 'asciidoc_ext' asciidoc_ext = (asciidoc_config['ext'] ||= (old_asciidoc_ext || (DefaultFileExtensions * ','))) asciidoc_ext_re = asciidoc_config['ext_re'] = /^\.(?:#{asciidoc_ext.tr ',', '|'})$/ix old_page_attr_prefix_def = config.key? 'asciidoc_page_attribute_prefix' old_page_attr_prefix_val = config.delete 'asciidoc_page_attribute_prefix' unless (page_attr_prefix = asciidoc_config['page_attribute_prefix']) page_attr_prefix = old_page_attr_prefix_def ? old_page_attr_prefix_val || '' : (asciidoc_config.key? 'page_attribute_prefix') ? '' : DefaultPageAttributePrefix end asciidoc_config['page_attribute_prefix'] = (page_attr_prefix = page_attr_prefix.chomp '-').empty? ? '' : %(#{page_attr_prefix}-) asciidoc_config['require_front_matter_header'] = !!asciidoc_config['require_front_matter_header'] asciidoc_config.extend Configured if asciidoc_config['require_front_matter_header'] unless (::Jekyll::Utils.method :has_yaml_header?).owner == ::Jekyll::Utils # NOTE restore original method ::Jekyll::Utils.extend (::Module.new do define_method :has_yaml_header?, &(Utils.method :has_yaml_header?) end) end else ::Jekyll::Utils.extend (::Module.new do define_method :has_yaml_header?, (Utils.method :has_front_matter?).curry[Utils.method :has_yaml_header?][asciidoc_ext_re] end) end