blob: f82e08212468035e6a5710bdc272e7f63621bfc0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# frozen_string_literal: true
require_relative 'spec_helper'
describe 'Asciidoctor::Epub3::Converter - Xref' do
context 'inter-chapter' do
it 'resolves xref to top of chapter' do
book, = to_epub 'inter-chapter-xref/book.adoc'
chapter_a = book.item_by_href 'chapter-a.xhtml'
expect(chapter_a).not_to be_nil
expect(chapter_a.content).to include '<a id="xref--chapter-b" href="chapter-b.xhtml" class="xref">Chapter B</a>'
end
it 'resolves xref to section inside chapter' do
book, = to_epub 'inter-chapter-xref-to-subsection/book.adoc'
chapter_a = book.item_by_href 'chapter-a.xhtml'
expect(chapter_a).not_to be_nil
expect(chapter_a.content).to include '<a id="xref--chapter-b--getting-started" href="chapter-b.xhtml#getting-started" class="xref">Getting Started</a>'
end
it 'resolves xref between subchapter include files' do
book, = to_epub 'inter-subchapter-xref/book.adoc'
chapter_a = book.item_by_href 'chapter-a.xhtml'
expect(chapter_a).not_to be_nil
expect(chapter_a.content).to include '<a id="xref--chapter-b--anchor" href="chapter-b.xhtml#anchor" class="xref">label</a>'
end
it 'resolves xref to inline anchor' do
book, = to_epub 'inline-anchor-xref/book.adoc'
chapter = book.item_by_href 'chapter.xhtml'
expect(chapter).not_to be_nil
expect(chapter.content).to include '<a id="item1"></a>foo::bar'
expect(chapter.content).to include '<a id="xref-item1" href="#item1" class="xref">[item1]</a>'
end
it 'resolves xref to bibliography anchor' do
book, = to_epub 'bibliography-xref/book.adoc'
chapter = book.item_by_href 'chapter.xhtml'
expect(chapter).not_to be_nil
expect(chapter.content).to include '<a id="item1"></a>[item1] foo::bar'
expect(chapter.content).to include '<a id="xref-item1" href="#item1" class="xref">[item1]</a>'
end
it 'resolves xref to bibliography chapter' do
book, = to_epub 'bibliography-chapter/book.adoc'
chapter = book.item_by_href 'chapter.xhtml'
expect(chapter).not_to be_nil
expect(chapter.content).to include '<a id="xref--bibliography--pp" href="bibliography.xhtml#pp" class="xref">[pp]</a>'
end
end
end
|