lib/asciidoctor/extensions.rb in asciidoctor-1.5.2 vs lib/asciidoctor/extensions.rb in asciidoctor-1.5.3

- old
+ new

@@ -108,11 +108,11 @@ # # Returns nothing #-- # QUESTION is parse_content the right method name? should we wrap in open block automatically? def parse_content parent, content, attributes = {} - reader = (content.is_a? Reader) ? reader : (Reader.new content) + reader = (content.is_a? Reader) ? content : (Reader.new content) while reader.has_more_lines? block = Parser.next_block reader, parent, attributes parent << block if block end nil @@ -256,11 +256,11 @@ class DocinfoProcessor < Processor attr_accessor :location def initialize config = {} super config - @config[:location] ||= :header + @config[:location] ||= :head end def process document raise ::NotImplementedError end @@ -421,12 +421,13 @@ #-- # TODO break this out into different pattern types # for example, FormalInlineMacro, ShortInlineMacro (no target) and other patterns # FIXME for inline passthrough, we need to have some way to specify the text as a passthrough class InlineMacroProcessor < MacroProcessor - def initialize name, config = {} - super + # Lookup the regexp option, resolving it first if necessary. + # Once this method is called, the regexp is considered frozen. + def regexp @config[:regexp] ||= (resolve_regexp @name, @config[:format]) end def resolve_regexp name, format # TODO memoize these regular expressions! @@ -794,11 +795,11 @@ add_document_processor :docinfo_processor, args, &block end # Public: Checks whether any {DocinfoProcessor} extensions have been registered. # - # location - A Symbol for selecting docinfo extensions at a given location (:header or :footer) (default: nil) + # location - A Symbol for selecting docinfo extensions at a given location (:head or :footer) (default: nil) # # Returns a [Boolean] indicating whether any DocinfoProcessor extensions are registered. def docinfo_processors? location = nil if @docinfo_processor_extensions if location @@ -812,11 +813,11 @@ end # Public: Retrieves the {Extension} proxy objects for all the # DocinfoProcessor instances stored in this registry. # - # location - A Symbol for selecting docinfo extensions at a given location (:header or :footer) (default: nil) + # location - A Symbol for selecting docinfo extensions at a given location (:head or :footer) (default: nil) # # Returns an [Array] of Extension proxy objects. def docinfo_processors location = nil if @docinfo_processor_extensions if location @@ -875,11 +876,11 @@ # ... # end # end # # # as a method block with an explicit block name - # register :shout do + # block :shout do # process |parent, reader, attrs| # ... # end # end # @@ -938,37 +939,37 @@ # If a name still cannot be determined, an error is raised. # # Examples # # # as a BlockMacroProcessor subclass - # block GistBlockMacro + # block_macro GistBlockMacro # # # as a BlockMacroProcessor subclass with an explicit macro name - # block GistBlockMacro, :gist + # block_macro GistBlockMacro, :gist # # # as an instance of a BlockMacroProcessor subclass - # block GistBlockMacro.new + # block_macro GistBlockMacro.new # # # as an instance of a BlockMacroProcessor subclass with an explicit macro name - # block GistBlockMacro.new, :gist + # block_macro GistBlockMacro.new, :gist # # # as a name of a BlockMacroProcessor subclass - # block 'GistBlockMacro' + # block_macro 'GistBlockMacro' # # # as a name of a BlockMacroProcessor subclass with an explicit macro name - # block 'GistBlockMacro', :gist + # block_macro 'GistBlockMacro', :gist # # # as a method block # block_macro do # named :gist # process |parent, target, attrs| # ... # end # end # # # as a method block with an explicit macro name - # register :gist do + # block_macro :gist do # process |parent, target, attrs| # ... # end # end # @@ -1027,36 +1028,36 @@ # If a name still cannot be determined, an error is raised. # # Examples # # # as an InlineMacroProcessor subclass - # block ChromeInlineMacro + # inline_macro ChromeInlineMacro # # # as an InlineMacroProcessor subclass with an explicit macro name - # block ChromeInineMacro, :chrome + # inline_macro ChromeInineMacro, :chrome # # # as an instance of an InlineMacroProcessor subclass - # block ChromeInlineMacro.new + # inline_macro ChromeInlineMacro.new # # # as an instance of an InlineMacroProcessor subclass with an explicit macro name - # block ChromeInlineMacro.new, :chrome + # inline_macro ChromeInlineMacro.new, :chrome # # # as a name of an InlineMacroProcessor subclass - # block 'ChromeInlineMacro' + # inline_macro 'ChromeInlineMacro' # # # as a name of an InlineMacroProcessor subclass with an explicit macro name - # block 'ChromeInineMacro', :chrome + # inline_macro 'ChromeInineMacro', :chrome # # # as a method block # inline_macro do # named :chrome # process |parent, target, attrs| # ... # end # end # # # as a method block with an explicit macro name - # register :chrome do + # inline_macro :chrome do # process |parent, target, attrs| # ... # end # end #