summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2022-02-27 23:46:09 -0700
committerDan Allen <dan.j.allen@gmail.com>2022-02-28 00:36:27 -0700
commite8c909cf2f6e696eb42d08ef49100df4132f0b0e (patch)
tree29208a0105141eda6167cc8dfff626282ca0176b /test
parent5206b40fcd8dc8f79e2097a307ef530b8b82d789 (diff)
if path is included both partially and fully, store it with true value (included fully) in includes table of document catalog
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/other-chapters.adoc2
-rw-r--r--test/links_test.rb24
2 files changed, 26 insertions, 0 deletions
diff --git a/test/fixtures/other-chapters.adoc b/test/fixtures/other-chapters.adoc
index b0962f14..f8d12dda 100644
--- a/test/fixtures/other-chapters.adoc
+++ b/test/fixtures/other-chapters.adoc
@@ -1,8 +1,10 @@
// tag::ch2[]
[#ch2]
+// tag::ch2-noid[]
== Chapter 2
The plot thickens.
+// end::ch2-noid[]
// end::ch2[]
[#ch3]
diff --git a/test/links_test.rb b/test/links_test.rb
index 5cb85ded..426d0142 100644
--- a/test/links_test.rb
+++ b/test/links_test.rb
@@ -940,6 +940,30 @@ context 'Links' do
assert_xpath '//a[@href="other-chapters.html#ch2"][text()="the next chapter"]', output, 1
end
+ test 'should produce an internal anchor for inter-document xref to file included fully and partially' do
+ input = <<~'EOS'
+ = Book Title
+ :doctype: book
+
+ [#ch1]
+ == Chapter 1
+
+ So it begins.
+
+ Read <<other-chapters.adoc#ch2,the next chapter>> to find out what happens next!
+
+ include::other-chapters.adoc[]
+
+ include::other-chapters.adoc[tag=ch2-noid]
+ EOS
+
+ doc = document_from_string input, safe: :safe, base_dir: fixturedir
+ assert doc.catalog[:includes].key?('other-chapters')
+ assert doc.catalog[:includes]['other-chapters']
+ output = doc.convert
+ assert_xpath '//a[@href="#ch2"][text()="the next chapter"]', output, 1
+ end
+
test 'should warn and create link if debug mode is enabled, inter-document xref points to current doc, and reference not found' do
input = <<~'EOS'
[#foobar]