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
|
# File 'lib/asciidoctor/pdf/ext/asciidoctor/section.rb', line 4
def numbered_title opts = {}
@cached_numbered_title ||= nil
unless @cached_numbered_title
doc = @document
if @numbered && !@caption && (slevel = @level) <= (doc.attr 'sectnumlevels', 3).to_i
@is_numbered = true
if doc.doctype == 'book'
case slevel
when 0
@cached_numbered_title = %(#{sectnum nil, ':'} #{title})
signifier = doc.attributes['part-signifier'] || ((doc.attr_unspecified? 'part-signifier') ? 'Part' : '')
@cached_formal_numbered_title = %(#{signifier}#{signifier.empty? ? '' : ' '}#{@cached_numbered_title})
when 1
@cached_numbered_title = %(#{sectnum} #{title})
signifier = doc.attributes['chapter-signifier'] || ((doc.attr_unspecified? 'chapter-signifier') ? 'Chapter' : '')
@cached_formal_numbered_title = %(#{signifier}#{signifier.empty? ? '' : ' '}#{@cached_numbered_title})
else
@cached_formal_numbered_title = @cached_numbered_title = %(#{sectnum} #{title})
end
else
@cached_formal_numbered_title = @cached_numbered_title = %(#{sectnum} #{title})
end
elsif @level == 0
@is_numbered = false
@cached_numbered_title = @cached_formal_numbered_title = title
else
@is_numbered = false
@cached_numbered_title = @cached_formal_numbered_title = captioned_title
end
end
opts[:formal] ? @cached_formal_numbered_title : @cached_numbered_title
end
|