metanorma-standoc 1.8.4 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +11 -41
- data/.gitignore +2 -0
- data/.rubocop.yml +5 -1
- data/Gemfile.devel +0 -0
- data/lib/asciidoctor/standoc/base.rb +13 -1
- data/lib/asciidoctor/standoc/biblio.rng +4 -6
- data/lib/asciidoctor/standoc/blocks.rb +26 -12
- data/lib/asciidoctor/standoc/cleanup_block.rb +49 -12
- data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +24 -15
- data/lib/asciidoctor/standoc/cleanup_maths.rb +1 -1
- data/lib/asciidoctor/standoc/cleanup_section.rb +16 -15
- data/lib/asciidoctor/standoc/cleanup_terms.rb +2 -2
- data/lib/asciidoctor/standoc/converter.rb +3 -1
- data/lib/asciidoctor/standoc/inline.rb +6 -1
- data/lib/asciidoctor/standoc/isodoc.rng +153 -2
- data/lib/asciidoctor/standoc/macros.rb +40 -13
- data/lib/asciidoctor/standoc/ref_sect.rb +12 -12
- data/lib/asciidoctor/standoc/terms.rb +10 -6
- data/lib/metanorma/standoc/version.rb +5 -5
- data/metanorma-standoc.gemspec +12 -12
- data/spec/asciidoctor/base_spec.rb +18 -1
- data/spec/asciidoctor/blocks_spec.rb +10 -0
- data/spec/asciidoctor/cleanup_sections_spec.rb +14 -14
- data/spec/asciidoctor/cleanup_spec.rb +1868 -1865
- data/spec/asciidoctor/inline_spec.rb +273 -272
- data/spec/asciidoctor/macros_spec.rb +8 -2
- data/spec/asciidoctor/refs_spec.rb +134 -6
- data/spec/asciidoctor/section_spec.rb +670 -687
- data/spec/assets/html-override.css +1 -0
- data/spec/assets/word-override.css +1 -0
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +65 -65
- data/spec/vcr_cassettes/isobib_get_123.yml +16 -16
- data/spec/vcr_cassettes/isobib_get_123_1.yml +31 -31
- data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +38 -38
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +16 -16
- data/spec/vcr_cassettes/isobib_get_124.yml +17 -17
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +14 -14
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +73 -89
- metadata +73 -73
- data/.rubocop.ribose.yml +0 -66
- data/.rubocop.tb.yml +0 -650
- data/spec/asciidoctor/macros_lutaml_spec.rb +0 -80
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cd6e66873fc1d0b703e0fee76f1ed3a56de06684135f142e3be3865bb7c21fa
|
4
|
+
data.tar.gz: ec666e930ce8ad73f39563050aaf052ddc0ed31a1778dec88cd1bf7308ddef12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65062d39f1c2bd1c33ceaf3bc0d55f5be7c34728c4b9027c7b7192c5ddf8a4b3cc3e37705070b471aac7c20117946a6dae150a5e31613d36afff59bb3ab5aa39
|
7
|
+
data.tar.gz: e1ca0ba1c31ad442c6359d30ca338fecb840dd86839d01cf697e314b365f72da424a6f93eecb1906eafdc34e2f489f2afd9f264ce1762cd1bc2e7524711ac653
|
data/.github/workflows/rake.yml
CHANGED
@@ -16,17 +16,17 @@ jobs:
|
|
16
16
|
strategy:
|
17
17
|
fail-fast: false
|
18
18
|
matrix:
|
19
|
-
ruby: [ '2.6', '2.5', '2.4' ]
|
19
|
+
ruby: [ '2.7', '2.6', '2.5', '2.4' ]
|
20
20
|
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
21
21
|
experimental: [ false ]
|
22
22
|
include:
|
23
|
-
- ruby: '
|
23
|
+
- ruby: '3.0'
|
24
24
|
os: 'ubuntu-latest'
|
25
25
|
experimental: true
|
26
|
-
- ruby: '
|
26
|
+
- ruby: '3.0'
|
27
27
|
os: 'windows-latest'
|
28
28
|
experimental: true
|
29
|
-
- ruby: '
|
29
|
+
- ruby: '3.0'
|
30
30
|
os: 'macos-latest'
|
31
31
|
experimental: true
|
32
32
|
steps:
|
@@ -35,49 +35,19 @@ jobs:
|
|
35
35
|
- uses: ruby/setup-ruby@v1
|
36
36
|
with:
|
37
37
|
ruby-version: ${{ matrix.ruby }}
|
38
|
+
bundler-cache: true
|
38
39
|
|
39
|
-
-
|
40
|
-
run: brew install autoconf automake libtool
|
41
|
-
|
42
|
-
- uses: actions/cache@v2
|
43
|
-
with:
|
44
|
-
path: vendor/bundle
|
45
|
-
key: bundle-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}
|
46
|
-
restore-keys: bundle-${{ matrix.os }}-${{ matrix.ruby }}
|
47
|
-
|
48
|
-
- run: bundle config set path 'vendor/bundle'
|
49
|
-
|
50
|
-
- run: bundle install --jobs 4 --retry 3
|
51
|
-
|
52
|
-
- name: install plantuml ubuntu
|
53
|
-
if: matrix.os == 'ubuntu-latest'
|
54
|
-
uses: nick-invision/retry@v1
|
55
|
-
with:
|
56
|
-
polling_interval_seconds: 5
|
57
|
-
timeout_minutes: 5
|
58
|
-
max_attempts: 3
|
59
|
-
command: >
|
60
|
-
sudo apt-get update -y && sudo bash -c
|
61
|
-
"curl -L https://github.com/metanorma/plantuml-install/raw/master/ubuntu.sh | bash"
|
62
|
-
|
63
|
-
- if: matrix.os == 'macos-latest'
|
64
|
-
run: brew install plantuml
|
65
|
-
|
66
|
-
- if: matrix.os == 'windows-latest'
|
67
|
-
run: cinst -y plantuml
|
40
|
+
- uses: metanorma/metanorma-build-scripts/plantuml-setup-action@master
|
68
41
|
|
69
42
|
- run: bundle exec rake
|
70
43
|
|
71
44
|
tests-passed:
|
72
45
|
needs: rake
|
73
46
|
runs-on: ubuntu-latest
|
74
|
-
continue-on-error: true
|
75
47
|
steps:
|
76
|
-
-
|
77
|
-
uses: Sibz/github-status-action@v1
|
48
|
+
- uses: peter-evans/repository-dispatch@v1
|
78
49
|
with:
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
sha: ${{ github.event.pull_request.head.sha || github.sha }}
|
50
|
+
token: ${{ secrets.METANORMA_CI_PAT_TOKEN || secrets.GITHUB_TOKEN }}
|
51
|
+
repository: ${{ github.repository }}
|
52
|
+
event-type: notify
|
53
|
+
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
# This project follows the Ribose OSS style guide.
|
2
2
|
# https://github.com/riboseinc/oss-guides
|
3
3
|
# All project-specific additions and overrides should be specified in this file.
|
4
|
-
|
5
4
|
inherit_from:
|
6
5
|
- https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
|
6
|
+
|
7
|
+
# local repo-specific modifications
|
8
|
+
|
7
9
|
AllCops:
|
10
|
+
DisplayCopNames: false
|
11
|
+
StyleGuideCopsOnly: false
|
8
12
|
TargetRubyVersion: 2.4
|
9
13
|
Rails:
|
10
14
|
Enabled: true
|
data/Gemfile.devel
ADDED
File without changes
|
@@ -8,6 +8,7 @@ require "isodoc"
|
|
8
8
|
require "relaton"
|
9
9
|
require "fileutils"
|
10
10
|
require "metanorma-utils"
|
11
|
+
require "isodoc/xslfo_convert"
|
11
12
|
|
12
13
|
module Asciidoctor
|
13
14
|
module Standoc
|
@@ -43,6 +44,7 @@ module Asciidoctor
|
|
43
44
|
i18nyaml: node.attr("i18nyaml"),
|
44
45
|
scope: node.attr("scope"),
|
45
46
|
htmlstylesheet: node.attr("htmlstylesheet"),
|
47
|
+
htmlstylesheet_override: node.attr("htmlstylesheet-override"),
|
46
48
|
htmlcoverpage: node.attr("htmlcoverpage"),
|
47
49
|
htmlintropage: node.attr("htmlintropage"),
|
48
50
|
scripts: node.attr("scripts"),
|
@@ -51,6 +53,7 @@ module Asciidoctor
|
|
51
53
|
htmltoclevels: node.attr("htmltoclevels") || node.attr("toclevels"),
|
52
54
|
doctoclevels: node.attr("doctoclevels") || node.attr("toclevels"),
|
53
55
|
break_up_urls_in_tables: node.attr("break-up-urls-in-tables"),
|
56
|
+
sectionsplit: node.attr("sectionsplit"),
|
54
57
|
}
|
55
58
|
end
|
56
59
|
|
@@ -59,7 +62,7 @@ module Asciidoctor
|
|
59
62
|
end
|
60
63
|
|
61
64
|
def doc_extract_attributes(node)
|
62
|
-
{
|
65
|
+
attrs = {
|
63
66
|
script: node.attr("script"),
|
64
67
|
bodyfont: node.attr("body-font"),
|
65
68
|
headerfont: node.attr("header-font"),
|
@@ -67,6 +70,7 @@ module Asciidoctor
|
|
67
70
|
i18nyaml: node.attr("i18nyaml"),
|
68
71
|
scope: node.attr("scope"),
|
69
72
|
wordstylesheet: node.attr("wordstylesheet"),
|
73
|
+
wordstylesheet_override: node.attr("wordstylesheet-override"),
|
70
74
|
standardstylesheet: node.attr("standardstylesheet"),
|
71
75
|
header: node.attr("header"),
|
72
76
|
wordcoverpage: node.attr("wordcoverpage"),
|
@@ -77,6 +81,14 @@ module Asciidoctor
|
|
77
81
|
doctoclevels: node.attr("doctoclevels") || node.attr("toclevels"),
|
78
82
|
break_up_urls_in_tables: node.attr("break-up-urls-in-tables"),
|
79
83
|
}
|
84
|
+
|
85
|
+
if font_manifest_file = node.attr("mn2pdf-font-manifest-file")
|
86
|
+
attrs[IsoDoc::XslfoPdfConvert::MN2PDF_OPTIONS] = {
|
87
|
+
IsoDoc::XslfoPdfConvert::MN2PDF_FONT_MANIFEST => font_manifest_file,
|
88
|
+
}
|
89
|
+
end
|
90
|
+
|
91
|
+
attrs
|
80
92
|
end
|
81
93
|
|
82
94
|
def doc_converter(node)
|
@@ -124,7 +124,7 @@
|
|
124
124
|
<value>application/tei+xml</value>
|
125
125
|
<value>text/x-asciidoc</value>
|
126
126
|
<value>text/markdown</value>
|
127
|
-
<value>application/x-
|
127
|
+
<value>application/x-metanorma+xml</value>
|
128
128
|
<text/>
|
129
129
|
</choice>
|
130
130
|
</attribute>
|
@@ -452,6 +452,7 @@
|
|
452
452
|
<attribute name="type">
|
453
453
|
<choice>
|
454
454
|
<value>isni</value>
|
455
|
+
<value>orcid</value>
|
455
456
|
<value>uri</value>
|
456
457
|
</choice>
|
457
458
|
</attribute>
|
@@ -461,10 +462,7 @@
|
|
461
462
|
<define name="org-identifier">
|
462
463
|
<element name="identifier">
|
463
464
|
<attribute name="type">
|
464
|
-
<
|
465
|
-
<value>orcid</value>
|
466
|
-
<value>uri</value>
|
467
|
-
</choice>
|
465
|
+
<data type="string" datatypeLibrary=""/>
|
468
466
|
</attribute>
|
469
467
|
<text/>
|
470
468
|
</element>
|
@@ -1106,7 +1104,7 @@
|
|
1106
1104
|
<value>complementOf</value>
|
1107
1105
|
<value>obsoletes</value>
|
1108
1106
|
<value>obsoletedBy</value>
|
1109
|
-
<value>
|
1107
|
+
<value>cites</value>
|
1110
1108
|
<value>isCitedIn</value>
|
1111
1109
|
</choice>
|
1112
1110
|
</define>
|
@@ -45,8 +45,9 @@ module Asciidoctor
|
|
45
45
|
noko do |xml|
|
46
46
|
xml.figure **literal_attrs(node) do |f|
|
47
47
|
figure_title(node, f)
|
48
|
-
f.pre node.lines.join("\n"),
|
49
|
-
|
48
|
+
f.pre node.lines.join("\n"),
|
49
|
+
**attr_code(id: Metanorma::Utils::anchor_or_uuid,
|
50
|
+
alt: node.attr("alt"))
|
50
51
|
end
|
51
52
|
end
|
52
53
|
end
|
@@ -78,9 +79,19 @@ module Asciidoctor
|
|
78
79
|
example_proper(node)
|
79
80
|
end
|
80
81
|
|
82
|
+
def svgmap_attrs(node)
|
83
|
+
attr_code( { id: node.id,
|
84
|
+
unnumbered: node.option?("unnumbered") ? "true" : nil,
|
85
|
+
number: node.attr("number"),
|
86
|
+
subsequence: node.attr("subsequence") }.
|
87
|
+
merge(keep_attrs(node)))
|
88
|
+
end
|
89
|
+
|
81
90
|
def svgmap_example(node)
|
82
91
|
noko do |xml|
|
83
|
-
xml.svgmap **attr_code(
|
92
|
+
xml.svgmap **attr_code(svgmap_attrs(node).merge(
|
93
|
+
src: node.attr("src"), alt: node.attr("alt"))) do |ex|
|
94
|
+
figure_title(node, ex)
|
84
95
|
ex << node.content
|
85
96
|
end
|
86
97
|
end.join("\n")
|
@@ -129,8 +140,9 @@ module Asciidoctor
|
|
129
140
|
end
|
130
141
|
|
131
142
|
def para_attrs(node)
|
132
|
-
attr_code(keep_attrs(node).
|
133
|
-
|
143
|
+
attr_code(keep_attrs(node).
|
144
|
+
merge(align: node.attr("align"),
|
145
|
+
id: Metanorma::Utils::anchor_or_uuid(node)))
|
134
146
|
end
|
135
147
|
|
136
148
|
def paragraph(node)
|
@@ -143,8 +155,9 @@ module Asciidoctor
|
|
143
155
|
end
|
144
156
|
|
145
157
|
def quote_attrs(node)
|
146
|
-
attr_code(keep_attrs(node).
|
147
|
-
|
158
|
+
attr_code(keep_attrs(node).
|
159
|
+
merge(align: node.attr("align"),
|
160
|
+
id: Metanorma::Utils::anchor_or_uuid(node)))
|
148
161
|
end
|
149
162
|
|
150
163
|
def quote_attribution(node, out)
|
@@ -168,11 +181,12 @@ module Asciidoctor
|
|
168
181
|
end
|
169
182
|
|
170
183
|
def listing_attrs(node)
|
171
|
-
attr_code(keep_attrs(node).
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
184
|
+
attr_code(keep_attrs(node).
|
185
|
+
merge(lang: node.attr("language"),
|
186
|
+
id: Metanorma::Utils::anchor_or_uuid(node),
|
187
|
+
unnumbered: node.option?("unnumbered") ? "true" : nil,
|
188
|
+
number: node.attr("number"),
|
189
|
+
filename: node.attr("filename")))
|
176
190
|
end
|
177
191
|
|
178
192
|
# NOTE: html escaping is performed by Nokogiri
|
@@ -29,7 +29,7 @@ module Asciidoctor
|
|
29
29
|
def dl2_table_cleanup(xmldoc)
|
30
30
|
q = "//table/following-sibling::*[1][self::p]"
|
31
31
|
xmldoc.xpath(q).each do |s|
|
32
|
-
if s.text =~ /^\s*key[^a-z]*$/i &&
|
32
|
+
if s.text =~ /^\s*key[^a-z]*$/i && s&.next_element&.name == "dl"
|
33
33
|
s.next_element["key"] = "true"
|
34
34
|
s.previous_element << s.next_element.remove
|
35
35
|
s.remove
|
@@ -95,7 +95,7 @@ module Asciidoctor
|
|
95
95
|
def formula_cleanup_where2(x)
|
96
96
|
q = "//formula/following-sibling::*[1][self::p]"
|
97
97
|
x.xpath(q).each do |s|
|
98
|
-
if s.text =~ /^\s*where[^a-z]*$/i &&
|
98
|
+
if s.text =~ /^\s*where[^a-z]*$/i && s&.next_element&.name == "dl"
|
99
99
|
s.next_element["key"] = "true"
|
100
100
|
s.previous_element << s.next_element.remove
|
101
101
|
s.remove
|
@@ -114,7 +114,7 @@ module Asciidoctor
|
|
114
114
|
def figure_dl_cleanup2(xmldoc)
|
115
115
|
q = "//figure/following-sibling::*[self::p]"
|
116
116
|
xmldoc.xpath(q).each do |s|
|
117
|
-
if s.text =~ /^\s*key[^a-z]*$/i &&
|
117
|
+
if s.text =~ /^\s*key[^a-z]*$/i && s&.next_element&.name == "dl"
|
118
118
|
s.next_element["key"] = "true"
|
119
119
|
s.previous_element << s.next_element.remove
|
120
120
|
s.remove
|
@@ -125,7 +125,9 @@ module Asciidoctor
|
|
125
125
|
# examples containing only figures become subfigures of figures
|
126
126
|
def subfigure_cleanup(xmldoc)
|
127
127
|
xmldoc.xpath("//example[figure]").each do |e|
|
128
|
-
next unless e.elements.map { |m| m.name }.reject
|
128
|
+
next unless e.elements.map { |m| m.name }.reject do |m|
|
129
|
+
%w(name figure).include? m
|
130
|
+
end.empty?
|
129
131
|
e.name = "figure"
|
130
132
|
end
|
131
133
|
end
|
@@ -140,7 +142,8 @@ module Asciidoctor
|
|
140
142
|
ELEMS_ALLOW_NOTES = %w[p formula ul ol dl figure].freeze
|
141
143
|
|
142
144
|
# if a note is at the end of a section, it is left alone
|
143
|
-
# if a note is followed by a non-note block,
|
145
|
+
# if a note is followed by a non-note block,
|
146
|
+
# it is moved inside its preceding block if it is not delimited
|
144
147
|
# (so there was no way of making that block include the note)
|
145
148
|
def note_cleanup(xmldoc)
|
146
149
|
q = "//note[following-sibling::*[not(local-name() = 'note')]]"
|
@@ -150,8 +153,10 @@ module Asciidoctor
|
|
150
153
|
prev = n.previous_element || next
|
151
154
|
n.parent = prev if ELEMS_ALLOW_NOTES.include? prev.name
|
152
155
|
end
|
153
|
-
xmldoc.xpath("//note[@keep-separate]
|
154
|
-
|
156
|
+
xmldoc.xpath("//note[@keep-separate] | "\
|
157
|
+
"//termnote[@keep-separate]").each do |n|
|
158
|
+
n.delete("keep-separate")
|
159
|
+
end
|
155
160
|
end
|
156
161
|
|
157
162
|
def requirement_cleanup(x)
|
@@ -184,18 +189,50 @@ module Asciidoctor
|
|
184
189
|
end
|
185
190
|
|
186
191
|
def requirement_cleanup1(r)
|
187
|
-
while d = r.at("./description[following-sibling::*[1]
|
192
|
+
while d = r.at("./description[following-sibling::*[1]"\
|
193
|
+
"[self::description]]")
|
188
194
|
n = d.next.remove
|
189
195
|
d << n.children
|
190
196
|
end
|
191
|
-
r.xpath("./description[normalize-space(.)='']").each
|
197
|
+
r.xpath("./description[normalize-space(.)='']").each do |d|
|
198
|
+
d.replace("\n")
|
199
|
+
end
|
192
200
|
end
|
193
201
|
|
194
202
|
def svgmap_cleanup(xmldoc)
|
203
|
+
svgmap_moveattrs(xmldoc)
|
195
204
|
svgmap_populate(xmldoc)
|
196
205
|
Metanorma::Utils::svgmap_rewrite(xmldoc, @localdir)
|
197
206
|
end
|
198
207
|
|
208
|
+
def guid?(x)
|
209
|
+
/^_[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i.
|
210
|
+
match(x)
|
211
|
+
end
|
212
|
+
|
213
|
+
def svgmap_moveattrs(xmldoc)
|
214
|
+
xmldoc.xpath("//svgmap").each do |s|
|
215
|
+
f = s.at(".//figure") or next
|
216
|
+
if t = s.at("./name") and !f.at("./name")
|
217
|
+
f.children.first.previous = t.remove
|
218
|
+
end
|
219
|
+
if s["id"] && guid?(f["id"])
|
220
|
+
f["id"] = s["id"]
|
221
|
+
s.delete("id")
|
222
|
+
end
|
223
|
+
svgmap_moveattrs1(s, f)
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
def svgmap_moveattrs1(s, f)
|
228
|
+
%w(unnumbered number subsequence keep-with-next
|
229
|
+
keep-lines-together).each do |a|
|
230
|
+
next if f[a] || !s[a]
|
231
|
+
f[a] = s[a]
|
232
|
+
s.delete(a)
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
199
236
|
def svgmap_populate(xmldoc)
|
200
237
|
xmldoc.xpath("//svgmap").each do |s|
|
201
238
|
s1 = s.dup
|
@@ -204,8 +241,8 @@ module Asciidoctor
|
|
204
241
|
s1.xpath(".//li").each do |li|
|
205
242
|
t = li&.at(".//eref | .//link | .//xref") or next
|
206
243
|
href = t.xpath("./following-sibling::node()")
|
207
|
-
|
208
|
-
|
244
|
+
href.empty? or
|
245
|
+
s << %[<target href="#{svgmap_target(href)}">#{t.to_xml}</target>]
|
209
246
|
end
|
210
247
|
end
|
211
248
|
end
|
@@ -215,7 +252,7 @@ module Asciidoctor
|
|
215
252
|
next unless n.name == "link"
|
216
253
|
n.children = n["target"]
|
217
254
|
end
|
218
|
-
nodeset.text.sub(/^[,;]/, "").strip
|
255
|
+
nodeset.text.sub(/^[,; ]/, "").strip
|
219
256
|
end
|
220
257
|
end
|
221
258
|
end
|
@@ -3,21 +3,26 @@ module Asciidoctor
|
|
3
3
|
module Cleanup
|
4
4
|
def external_terms_boilerplate(sources)
|
5
5
|
@i18n.l10n(
|
6
|
-
@i18n.external_terms_boilerplate.gsub(/%/, sources || "???"),
|
6
|
+
@i18n.external_terms_boilerplate.gsub(/%/, sources || "???"),
|
7
|
+
@lang, @script
|
8
|
+
)
|
7
9
|
end
|
8
10
|
|
9
11
|
def internal_external_terms_boilerplate(sources)
|
10
12
|
@i18n.l10n(
|
11
|
-
@i18n.internal_external_terms_boilerplate.gsub(/%/, sources || "??"),
|
13
|
+
@i18n.internal_external_terms_boilerplate.gsub(/%/, sources || "??"),
|
14
|
+
@lang, @script
|
15
|
+
)
|
12
16
|
end
|
13
17
|
|
14
18
|
def term_defs_boilerplate(div, source, term, preface, isodoc)
|
15
19
|
a = @i18n.term_def_boilerplate and div.next = a
|
16
20
|
source.each do |s|
|
17
21
|
@anchors[s["bibitemid"]] or
|
18
|
-
@log.add("Crossreferences", nil,
|
22
|
+
@log.add("Crossreferences", nil,
|
23
|
+
"term source #{s['bibitemid']} not referenced")
|
19
24
|
end
|
20
|
-
a =
|
25
|
+
a = source.empty? && term.nil? ? @i18n.no_terms_boilerplate :
|
21
26
|
term_defs_boilerplate_cont(source, term, isodoc)
|
22
27
|
a and div.next = a
|
23
28
|
end
|
@@ -55,7 +60,7 @@ module Asciidoctor
|
|
55
60
|
end
|
56
61
|
|
57
62
|
def termdef_boilerplate_cleanup(xmldoc)
|
58
|
-
#termdef_remove_initial_paras(xmldoc)
|
63
|
+
# termdef_remove_initial_paras(xmldoc)
|
59
64
|
end
|
60
65
|
|
61
66
|
def termdef_remove_initial_paras(xmldoc)
|
@@ -76,6 +81,7 @@ module Asciidoctor
|
|
76
81
|
termdef_boilerplate_cleanup(xmldoc)
|
77
82
|
xmldoc.xpath(self.class::TERM_CLAUSE).each do |f|
|
78
83
|
next if f.at("./clause[@type = 'boilerplate']")
|
84
|
+
|
79
85
|
term_defs_boilerplate(f.at("./title"), xmldoc.xpath(".//termdocsource"),
|
80
86
|
f.at(".//term"), f.at(".//p"), isodoc)
|
81
87
|
end
|
@@ -84,15 +90,16 @@ module Asciidoctor
|
|
84
90
|
initial_boilerplate(xmldoc, isodoc)
|
85
91
|
end
|
86
92
|
|
87
|
-
def initial_boilerplate(
|
88
|
-
return if
|
89
|
-
|
90
|
-
|
91
|
-
|
93
|
+
def initial_boilerplate(xml, isodoc)
|
94
|
+
return if xml.at("//boilerplate")
|
95
|
+
|
96
|
+
preface = xml.at("//preface") || xml.at("//sections") ||
|
97
|
+
xml.at("//annex") || xml.at("//references") || return
|
98
|
+
b = boilerplate(xml, isodoc) or return
|
92
99
|
preface.previous = b
|
93
100
|
end
|
94
101
|
|
95
|
-
def boilerplate_file(
|
102
|
+
def boilerplate_file(_xmldoc)
|
96
103
|
File.join(@libdir, "boilerplate.xml")
|
97
104
|
end
|
98
105
|
|
@@ -100,7 +107,7 @@ module Asciidoctor
|
|
100
107
|
file = boilerplate_file(xml)
|
101
108
|
file = File.join(@localdir, @boilerplateauthority) if @boilerplateauthority
|
102
109
|
!file.nil? and File.exists?(file) or return
|
103
|
-
conv.populate_template(
|
110
|
+
conv.populate_template(File.read(file, encoding: "UTF-8"), nil)
|
104
111
|
end
|
105
112
|
|
106
113
|
def bibdata_cleanup(xmldoc)
|
@@ -118,14 +125,16 @@ module Asciidoctor
|
|
118
125
|
def bibdata_docidentifier_cleanup(xmldoc)
|
119
126
|
ins = xmldoc.at("//bibdata/docidentifier")
|
120
127
|
xmldoc.xpath("//bibdata/docidentifier").each_with_index do |b, i|
|
121
|
-
next if i
|
128
|
+
next if i.zero?
|
129
|
+
|
122
130
|
ins.next = b.remove
|
123
131
|
ins = ins.next
|
124
132
|
end
|
125
133
|
end
|
126
134
|
|
127
135
|
def gather_indirect_erefs(xmldoc, prefix)
|
128
|
-
xmldoc.xpath("//eref[@type = '#{prefix}']")
|
136
|
+
xmldoc.xpath("//eref[@type = '#{prefix}']")
|
137
|
+
.each_with_object({}) do |e, m|
|
129
138
|
e.delete("type")
|
130
139
|
m[e["bibitemid"]] = true
|
131
140
|
end.keys
|
@@ -160,7 +169,7 @@ module Asciidoctor
|
|
160
169
|
def resolve_local_indirect_erefs(xmldoc, refs, prefix)
|
161
170
|
refs.each_with_object([]) do |r, m|
|
162
171
|
id = r.sub(/^#{prefix}_/, "")
|
163
|
-
if xmldoc.at("//*[@id = '#{id}'][@type = '#{prefix}']")
|
172
|
+
if n = xmldoc.at("//*[@id = '#{id}']") and n.at("./ancestor-or-self::*[@type = '#{prefix}']")
|
164
173
|
xmldoc.xpath("//eref[@bibitemid = '#{r}']").each do |e|
|
165
174
|
indirect_eref_to_xref(e, id)
|
166
175
|
end
|