Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-doc
Path: blob/main/shared/lib/sectnumoffset-treeprocessor.rb
18081 views
1
require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'
2
3
include Asciidoctor
4
5
Extensions.register do
6
treeprocessor do
7
process do |document|
8
if (document.attr? 'sectnumoffset') && (book = (document.attr 'book', false)) == false
9
sectnumoffset = (document.attr 'sectnumoffset', '0').to_s
10
document.find_by(context: :section) {|sect| sect.level == 1 }.each do |sect|
11
sect.numeral = sectnumoffset.to_s + '.' + sect.numeral.to_s
12
end
13
end
14
end
15
end
16
end
17
18