diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2021-12-31 23:50:22 -0700 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2022-01-01 04:34:50 -0700 |
| commit | de1ba697bdbc8da1a6598269f4b0093c83887f5b (patch) | |
| tree | 961fed2fe83687cbf336aff7744cde8f4e997543 /lib | |
| parent | 56440ab73f6227634f3866f34d171095c26aa2d5 (diff) | |
handle return value of process method for block and block macro extension properly
* don't crash if value is an abstract block with context :compound that isn't of type Block (e.g., a list)
* ignore value if it matches parent argument
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/asciidoctor/parser.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/asciidoctor/parser.rb b/lib/asciidoctor/parser.rb index ad9d34cc..ccfee715 100644 --- a/lib/asciidoctor/parser.rb +++ b/lib/asciidoctor/parser.rb @@ -660,7 +660,7 @@ class Parser if (default_attrs = ext_config[:default_attrs]) attributes.update(default_attrs) {|_, old_v| old_v } end - if (block = extension.process_method[parent, target, attributes]) + if (block = extension.process_method[parent, target, attributes]) && block != parent attributes.replace block.attributes break else @@ -1050,12 +1050,12 @@ class Parser if (extension = options[:extension]) # QUESTION do we want to delete the style? attributes.delete 'style' - return unless (block = extension.process_method[parent, block_reader || (Reader.new lines), attributes.merge]) + return unless (block = extension.process_method[parent, block_reader || (Reader.new lines), attributes.merge]) && block != parent attributes.replace block.attributes # FIXME if the content model is set to compound, but we only have simple in this context, then # forcefully set the content_model to simple to prevent parsing blocks from children # TODO document this behavior!! - if block.content_model == :compound && !(lines = block.lines).empty? + if block.content_model == :compound && Block === block && !(lines = block.lines).empty? content_model = :compound block_reader = Reader.new lines end |
