summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Ã…berg <434309+freke@users.noreply.github.com>2020-04-15 18:18:45 +0200
committerJakub Jirutka <jakub@jirutka.cz>2020-04-16 00:26:10 +0200
commit8202ba2f3c34607a752ee9e68257fe1e70a05df0 (patch)
tree9d7b17187d8dd6c26bc6a8180dccec08daf07fc9
parentd37db4c06caab2ab417cb54406a6d679a46fd6e5 (diff)
Fix resolving xrefs inside nested documents
Only top parent have the :@_interdoc_reftext_resolver variable. Fixes #3 Co-Authored-By: Jakub Jirutka <jakub@jirutka.cz>
-rw-r--r--lib/asciidoctor/interdoc_reftext/inline_node_mixin.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/asciidoctor/interdoc_reftext/inline_node_mixin.rb b/lib/asciidoctor/interdoc_reftext/inline_node_mixin.rb
index 17370b0..248b697 100644
--- a/lib/asciidoctor/interdoc_reftext/inline_node_mixin.rb
+++ b/lib/asciidoctor/interdoc_reftext/inline_node_mixin.rb
@@ -39,8 +39,14 @@ module Asciidoctor::InterdocReftext
# If this node is not an inter-document cross reference...
return if @node_name != 'inline_anchor' || @attributes['path'].nil?
+ # Only the top most document has the `@_interdoc_reftext_resolver` variable.
+ doc = @document
+ while doc.parent_document do
+ doc = doc.parent_document
+ end
+
# This variable is injected into the document by {Processor}.
- if (resolver = @document.instance_variable_get(Processor::RESOLVER_VAR_NAME))
+ if (resolver = doc.instance_variable_get(Processor::RESOLVER_VAR_NAME))
@text = resolver.call(@attributes['refid'])
end
end