Skip to content

Commit

Permalink
#416 Don't eagerly convert Inline nodes during processing
Browse files Browse the repository at this point in the history
  • Loading branch information
pepijnve committed Jun 12, 2023
1 parent 332c220 commit 6787891
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

Bugfixes::

* Issue #416: Silence Asciidoctor warning when using inline macros
* Issue #417: Avoid reusing images when block type is different but source code is identical


Expand Down
7 changes: 6 additions & 1 deletion lib/asciidoctor-diagram/diagram_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,12 @@ def process(parent, reader_or_target, attributes)
block = generate_block(parent, reader_or_target, attributes)
attrs = block.attributes.dup
target = attrs.delete('target')
create_inline(parent, :image, nil, :type => 'image', :target => target, :attributes => attrs).convert

# Don't let the asciidoctor try to apply substitutions.
# The text of inline macros is nil which will cause an error
attrs.delete('subs')

create_inline(parent, :image, nil, :type => 'image', :target => target, :attributes => attrs)
end

def supported_formats(converter)
Expand Down
5 changes: 4 additions & 1 deletion spec/test_helper_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def find(&block)
module Asciidoctor
module Diagram
module TestHelpers
include ::Asciidoctor::Logging

def load_asciidoc(source, options = {})
options = options.dup
options[:trace] = true
Expand All @@ -71,7 +73,8 @@ def load_asciidoc(source, options = {})
options[:attributes]['diagram-on-error'] = 'abort'
end

::Asciidoctor.load(StringIO.new(source), options.merge({:trace => true}))
logger.level = ::Logger::Severity::DEBUG
::Asciidoctor.load(StringIO.new(source), options.merge({:trace => true, :verbose => 2}))
end
end
end
Expand Down

0 comments on commit 6787891

Please sign in to comment.