summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.adoc1
-rw-r--r--lib/asciidoctor/parser.rb3
-rw-r--r--test/lists_test.rb22
3 files changed, 25 insertions, 1 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index d59660fc..ed9530d0 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -29,6 +29,7 @@ Fixes::
* use ::File.open instead of ::IO.binread in Reader for Asciidoctor.js compatibility
* add fallback for timezone when setting doctime
* fix formatting of quote block (indentation) in manpage output (#2792)
+ * catalog inline anchors in ordered list items (#2812)
Improvements::
diff --git a/lib/asciidoctor/parser.rb b/lib/asciidoctor/parser.rb
index 6e41826a..3713d983 100644
--- a/lib/asciidoctor/parser.rb
+++ b/lib/asciidoctor/parser.rb
@@ -1309,6 +1309,9 @@ class Parser
end
elsif list_type == :olist
list_item.marker = (sibling_trait ||= resolve_ordered_list_marker(match[1], list_block.items.size, true, reader))
+ if item_text.start_with?('[[') && LeadingInlineAnchorRx =~ item_text
+ catalog_inline_anchor $1, $2, list_item, reader
+ end
else # :colist
list_item.marker = (sibling_trait ||= '<1>')
end
diff --git a/test/lists_test.rb b/test/lists_test.rb
index ce421447..483d819a 100644
--- a/test/lists_test.rb
+++ b/test/lists_test.rb
@@ -766,7 +766,7 @@ B. And it ends here.
assert_xpath '//ol/li', output, 2
end
- test 'should discover anchor at start of list item text and register it as a reference' do
+ test 'should discover anchor at start of unordered list item text and register it as a reference' do
input = <<-EOS
The highest peak in the Front Range is <<grays-peak>>, which tops <<mount-evans>> by just a few feet.
@@ -785,6 +785,26 @@ Grays Peak rises to 14,278 feet, making it the highest summit in the Front Range
assert_xpath '(//p)[1]/a[@href="#grays-peak"][text()="Grays Peak"]', output, 1
assert_xpath '(//p)[1]/a[@href="#mount-evans"][text()="Mount Evans"]', output, 1
end
+
+ test 'should discover anchor at start of ordered list item text and register it as a reference' do
+ input = <<-EOS
+This is a cross-reference to <<step-2>>.
+This is a cross-reference to <<step-4>>.
+
+. Ordered list, item 1, without anchor
+. [[step-2,Step 2]]Ordered list, item 2, with anchor
+. Ordered list, item 3, without anchor
+. [[step-4,Step 4]]Ordered list, item 4, with anchor
+ EOS
+
+ doc = document_from_string input
+ refs = doc.catalog[:refs]
+ assert refs.key?('step-2')
+ assert refs.key?('step-4')
+ output = doc.convert :header_footer => false
+ assert_xpath '(//p)[1]/a[@href="#step-2"][text()="Step 2"]', output, 1
+ assert_xpath '(//p)[1]/a[@href="#step-4"][text()="Step 4"]', output, 1
+ end
end
context "Nested lists" do