From 8202ba2f3c34607a752ee9e68257fe1e70a05df0 Mon Sep 17 00:00:00 2001 From: David Ã…berg <434309+freke@users.noreply.github.com> Date: Wed, 15 Apr 2020 18:18:45 +0200 Subject: Fix resolving xrefs inside nested documents Only top parent have the :@_interdoc_reftext_resolver variable. Fixes #3 Co-Authored-By: Jakub Jirutka --- lib/asciidoctor/interdoc_reftext/inline_node_mixin.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib') 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 -- cgit v1.2.3