summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.adoc1
-rw-r--r--lib/asciidoctor/parser.rb2
-rw-r--r--test/links_test.rb10
3 files changed, 12 insertions, 1 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index fd0667de..00a359b3 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -33,6 +33,7 @@ Compliance::
Bug Fixes::
+ * Catalog inline ref defined using anchor macro even when resolved reftext is empty
* Use while loop rather than recursion to locate next line to process; prevents stack limit error (#4368)
* Avoid matching numeric character references when searching for # in xref target (#4393)
* Use correct selector to collapse margin on first and last child of sidebar
diff --git a/lib/asciidoctor/parser.rb b/lib/asciidoctor/parser.rb
index 8026770f..84bf9406 100644
--- a/lib/asciidoctor/parser.rb
+++ b/lib/asciidoctor/parser.rb
@@ -1169,7 +1169,7 @@ class Parser
reftext = reftext.gsub '\]', ']'
reftext = document.sub_attributes reftext if reftext.include? ATTR_REF_HEAD
elsif reftext.include? ATTR_REF_HEAD
- next if (reftext = document.sub_attributes reftext).empty?
+ reftext = nil if (reftext = document.sub_attributes reftext).empty?
end
end
end
diff --git a/test/links_test.rb b/test/links_test.rb
index d0e1c8bc..58f5f18c 100644
--- a/test/links_test.rb
+++ b/test/links_test.rb
@@ -396,6 +396,16 @@ context 'Links' do
assert_includes output, (input.sub '{empty}', '')
end
+ test 'reftext of macro inline ref can resolve to empty' do
+ input = 'anchor:id-only[{empty}]text\n\nsee <<id-only>>'
+ doc = document_from_string input
+ assert doc.catalog[:refs].key? 'id-only'
+ output = doc.convert standalone: false
+ assert_xpath '//a[@id="id-only"]', output, 1
+ assert_xpath '//a[@href="#id-only"]', output, 1
+ assert_xpath '//a[@href="#id-only"][text()="[id-only]"]', output, 1
+ end
+
test 'inline ref with reftext' do
%w([[tigers,Tigers]] anchor:tigers[Tigers]).each do |anchor|
doc = document_from_string %(Here you can read about tigers.#{anchor})