lib/asciidoctor/extensions.rb in asciidoctor-2.0.15 vs lib/asciidoctor/extensions.rb in asciidoctor-2.0.16

- old
+ new

@@ -132,18 +132,18 @@ if special sect.special = true if opts.fetch :numbered, (style == 'appendix') sect.numbered = true elsif !(opts.key? :numbered) && (doc.attr? 'sectnums', 'all') - sect.numbered = book && level == 1 ? :chapter : true + sect.numbered = (book && level == 1 ? :chapter : true) end elsif level > 0 if opts.fetch :numbered, (doc.attr? 'sectnums') sect.numbered = sect.special ? parent.numbered && true : true end - else - sect.numbered = true if opts.fetch :numbered, (book && (doc.attr? 'partnums')) + elsif opts.fetch :numbered, (book && (doc.attr? 'partnums')) + sect.numbered = true end if (id = attrs['id']) == false attrs.delete 'id' else sect.id = attrs['id'] = id || ((doc.attr? 'sectids') ? (Section.generate_id sect.title, doc) : nil) @@ -227,11 +227,11 @@ # # Returns a Hash of parsed attributes def parse_attributes block, attrlist, opts = {} return {} if attrlist ? attrlist.empty? : true attrlist = block.sub_attributes attrlist if opts[:sub_attributes] && (attrlist.include? ATTR_REF_HEAD) - (AttributeList.new attrlist).parse (opts[:positional_attributes] || []) + (AttributeList.new attrlist).parse opts[:positional_attributes] || [] end # TODO fill out remaining methods [ [:create_paragraph, :create_block, :paragraph], @@ -1197,11 +1197,11 @@ # to handle a block macro with the specified name. # # name - the String or Symbol (coersed to a Symbol) macro name # # Returns the [Extension] object stored in the registry that proxies the - # cooresponding BlockMacroProcessor or nil if a match is not found. + # corresponding BlockMacroProcessor or nil if a match is not found. def find_block_macro_extension name @block_macro_extensions[name.to_sym] end # Public: Registers a {InlineMacroProcessor} with the extension registry to @@ -1284,11 +1284,11 @@ # to handle an inline macro with the specified name. # # name - the String or Symbol (coersed to a Symbol) macro name # # Returns the [Extension] object stored in the registry that proxies the - # cooresponding InlineMacroProcessor or nil if a match is not found. + # corresponding InlineMacroProcessor or nil if a match is not found. def find_inline_macro_extension name @inline_macro_extensions[name.to_sym] end # Public: Retrieves the {Extension} proxy objects for all @@ -1326,11 +1326,11 @@ kind_class_symbol = kind_name.split.map {|it| it.capitalize }.join.to_sym kind_class = Extensions.const_get kind_class_symbol, false kind_java_class = (defined? ::AsciidoctorJ) ? (::AsciidoctorJ::Extensions.const_get kind_class_symbol, false) : nil kind_store = instance_variable_get(%(@#{kind}_extensions).to_sym) || instance_variable_set(%(@#{kind}_extensions).to_sym, []) # style 1: specified as block - extension = if block_given? + if block_given? config = resolve_args args, 1 (processor = kind_class.new config).singleton_class.enable_dsl if block.arity == 0 processor.instance_exec(&block) else @@ -1338,25 +1338,25 @@ end unless processor.process_block_given? raise ::ArgumentError, %(No block specified to process #{kind_name} extension at #{block.source_location}) end processor.freeze - ProcessorExtension.new kind, processor + extension = ProcessorExtension.new kind, processor else processor, config = resolve_args args, 2 # style 2: specified as Class or String class name if (processor_class = Helpers.resolve_class processor) unless processor_class < kind_class || (kind_java_class && processor_class < kind_java_class) raise ::ArgumentError, %(Invalid type for #{kind_name} extension: #{processor}) end processor_instance = processor_class.new config processor_instance.freeze - ProcessorExtension.new kind, processor_instance + extension = ProcessorExtension.new kind, processor_instance # style 3: specified as instance elsif kind_class === processor || (kind_java_class && kind_java_class === processor) processor.update_config config processor.freeze - ProcessorExtension.new kind, processor + extension = ProcessorExtension.new kind, processor else raise ::ArgumentError, %(Invalid arguments specified for registering #{kind_name} extension: #{args}) end end