metanorma-iso 1.5.11 → 1.6.1
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 +83 -0
- data/README.adoc +5 -6
- data/lib/asciidoctor/iso/base.rb +5 -5
- data/lib/asciidoctor/iso/basicdoc.rng +50 -3
- data/lib/asciidoctor/iso/boilerplate-fr.xml +2 -2
- data/lib/asciidoctor/iso/cleanup.rb +33 -6
- data/lib/asciidoctor/iso/front.rb +5 -0
- data/lib/asciidoctor/iso/isodoc.rng +61 -3
- data/lib/asciidoctor/iso/isostandard-amd.rng +8 -4
- data/lib/asciidoctor/iso/isostandard.rng +27 -10
- data/lib/asciidoctor/iso/validate.rb +13 -1
- data/lib/asciidoctor/iso/validate_section.rb +21 -9
- data/lib/isodoc/iso/base_convert.rb +2 -1
- data/lib/isodoc/iso/html/header.html +4 -8
- data/lib/isodoc/iso/html/htmlstyle.css +1 -1
- data/lib/isodoc/iso/html/htmlstyle.scss +1 -1
- data/lib/isodoc/iso/html/isodoc.css +42 -42
- data/lib/isodoc/iso/html/isodoc.scss +42 -42
- data/lib/isodoc/iso/html/style-human.css +9 -9
- data/lib/isodoc/iso/html/style-human.scss +7 -7
- data/lib/isodoc/iso/html/style-iso.css +7 -7
- data/lib/isodoc/iso/html/style-iso.scss +5 -5
- data/lib/isodoc/iso/html/wordstyle.css +67 -67
- data/lib/isodoc/iso/html/wordstyle.scss +67 -67
- data/lib/isodoc/iso/html_convert.rb +4 -0
- data/lib/isodoc/iso/i18n-en.yaml +1 -0
- data/lib/isodoc/iso/i18n-fr.yaml +2 -0
- data/lib/isodoc/iso/i18n-zh-Hans.yaml +1 -0
- data/lib/isodoc/iso/i18n.rb +10 -11
- data/lib/isodoc/iso/iso.amendment.xsl +381 -86
- data/lib/isodoc/iso/iso.international-standard.xsl +381 -86
- data/lib/isodoc/iso/metadata.rb +1 -0
- data/lib/isodoc/iso/sections.rb +1 -1
- data/lib/isodoc/iso/word_convert.rb +4 -0
- data/lib/isodoc/iso/xref.rb +34 -8
- data/lib/metanorma/iso/processor.rb +11 -9
- data/lib/metanorma/iso/version.rb +1 -1
- data/metanorma-iso.gemspec +2 -2
- data/spec/asciidoctor-iso/amd_spec.rb +14 -14
- data/spec/asciidoctor-iso/base_spec.rb +20 -18
- data/spec/asciidoctor-iso/blocks_spec.rb +22 -22
- data/spec/asciidoctor-iso/cleanup_spec.rb +36 -30
- data/spec/asciidoctor-iso/inline_spec.rb +7 -7
- data/spec/asciidoctor-iso/lists_spec.rb +9 -9
- data/spec/asciidoctor-iso/refs_spec.rb +177 -146
- data/spec/asciidoctor-iso/section_spec.rb +12 -7
- data/spec/asciidoctor-iso/table_spec.rb +4 -4
- data/spec/asciidoctor-iso/validate_spec.rb +401 -85
- data/spec/isodoc/amd_spec.rb +13 -13
- data/spec/isodoc/blocks_spec.rb +1 -0
- data/spec/isodoc/metadata_spec.rb +2 -0
- data/spec/isodoc/ref_spec.rb +2 -2
- data/spec/isodoc/section_spec.rb +20 -0
- data/spec/isodoc/xref_spec.rb +12 -0
- metadata +7 -12
- data/.github/workflows/macos.yml +0 -49
- data/.github/workflows/ubuntu.yml +0 -53
- data/.github/workflows/windows.yml +0 -50
- data/lib/asciidoctor/iso/macros.rb +0 -21
- data/lib/asciidoctor/iso/term_lookup_cleanup.rb +0 -86
- data/spec/asciidoctor-iso/macros_spec.rb +0 -310
@@ -1,86 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true.
|
2
|
-
|
3
|
-
module Asciidoctor
|
4
|
-
module ISO
|
5
|
-
# Intelligent term lookup xml modifier
|
6
|
-
# Lookup all `term` and `calause` tags and replace `termxref` tags with
|
7
|
-
# `xref`:target tag
|
8
|
-
class TermLookupCleanup
|
9
|
-
AUTOMATIC_GENERATED_ID_REGEXP = /\A_/
|
10
|
-
EXISTING_TERM_REGEXP = /\Aterm-/
|
11
|
-
|
12
|
-
attr_reader :xmldoc, :termlookup, :log
|
13
|
-
|
14
|
-
def initialize(xmldoc, log)
|
15
|
-
@xmldoc = xmldoc
|
16
|
-
@log = log
|
17
|
-
@termlookup = {}
|
18
|
-
end
|
19
|
-
|
20
|
-
def call
|
21
|
-
@termlookup = replace_automatic_generated_ids_terms
|
22
|
-
set_termxref_tags_target
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def set_termxref_tags_target
|
28
|
-
xmldoc.xpath('//termxref').each do |node|
|
29
|
-
target = normalize_ref_id(node.text)
|
30
|
-
if termlookup[target].nil?
|
31
|
-
remove_missing_ref(node, target)
|
32
|
-
next
|
33
|
-
end
|
34
|
-
modify_ref_node(node, target)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def remove_missing_ref(node, target)
|
39
|
-
log.add('AsciiDoc Input', node,
|
40
|
-
%(Error: Term reference in `term[#{target}]` missing: \
|
41
|
-
"#{target}" is not defined in document))
|
42
|
-
term_name_node = node.previous.previous
|
43
|
-
term_name_node.remove
|
44
|
-
term_name_node.name = "strong"
|
45
|
-
term_name_node.children.first.content =
|
46
|
-
%(term "#{term_name_node.text}" not resolved)
|
47
|
-
node.add_previous_sibling(term_name_node)
|
48
|
-
node.remove
|
49
|
-
end
|
50
|
-
|
51
|
-
def modify_ref_node(node, target)
|
52
|
-
node.name = 'xref'
|
53
|
-
node['target'] = termlookup[target]
|
54
|
-
node.children.remove
|
55
|
-
node.remove_attribute('defaultref')
|
56
|
-
end
|
57
|
-
|
58
|
-
def replace_automatic_generated_ids_terms
|
59
|
-
xmldoc.xpath('//term').each.with_object({}) do |term_node, res|
|
60
|
-
normalize_id_and_memorize(term_node, res, './preferred')
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def normalize_id_and_memorize(term_node, res_table, text_selector)
|
65
|
-
term_text = normalize_ref_id(term_node.at(text_selector).text)
|
66
|
-
unless AUTOMATIC_GENERATED_ID_REGEXP.match(term_node['id']).nil?
|
67
|
-
term_node['id'] = unique_text_id(term_text)
|
68
|
-
end
|
69
|
-
res_table[term_text] = term_node['id']
|
70
|
-
end
|
71
|
-
|
72
|
-
def normalize_ref_id(text)
|
73
|
-
text.downcase.gsub(/[[:space:]]/, '-')
|
74
|
-
end
|
75
|
-
|
76
|
-
def unique_text_id(text)
|
77
|
-
return "term-#{text}" if xmldoc.at("//*[@id = 'term-#{text}']").nil?
|
78
|
-
(1..Float::INFINITY).lazy.each do |index|
|
79
|
-
if xmldoc.at("//*[@id = 'term-#{text}-#{index}']").nil?
|
80
|
-
break("term-#{text}-#{index}")
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
@@ -1,310 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe Asciidoctor::ISO do
|
4
|
-
it "processes the Asciidoctor::ISO inline macros" do
|
5
|
-
expect(xmlpp(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
6
|
-
#{ASCIIDOC_BLANK_HDR}
|
7
|
-
alt:[term1]
|
8
|
-
deprecated:[term1]
|
9
|
-
domain:[term1]
|
10
|
-
INPUT
|
11
|
-
#{BLANK_HDR}
|
12
|
-
<sections>
|
13
|
-
<admitted>term1</admitted>
|
14
|
-
<deprecates>term1</deprecates>
|
15
|
-
<domain>term1</domain>
|
16
|
-
</sections>
|
17
|
-
</iso-standard>
|
18
|
-
OUTPUT
|
19
|
-
end
|
20
|
-
|
21
|
-
describe 'term inline macros' do
|
22
|
-
subject(:convert) do
|
23
|
-
xmlpp(
|
24
|
-
strip_guid(
|
25
|
-
Asciidoctor.convert(
|
26
|
-
input, backend: :iso, header_footer: true)))
|
27
|
-
end
|
28
|
-
let(:input) do
|
29
|
-
<<~XML
|
30
|
-
#{ASCIIDOC_BLANK_HDR}
|
31
|
-
== Terms and Definitions
|
32
|
-
|
33
|
-
=== name2
|
34
|
-
|
35
|
-
== Main
|
36
|
-
|
37
|
-
term:[name,name2] is a term
|
38
|
-
XML
|
39
|
-
end
|
40
|
-
let(:output) do
|
41
|
-
<<~XML
|
42
|
-
#{BLANK_HDR}
|
43
|
-
<sections>
|
44
|
-
<terms id='_' obligation='normative'>
|
45
|
-
<title>Terms and definitions</title>
|
46
|
-
<p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
|
47
|
-
<p id='_'>
|
48
|
-
ISO and IEC maintain terminological databases for use in standardization
|
49
|
-
at the following addresses:
|
50
|
-
</p>
|
51
|
-
<ul id='_'>
|
52
|
-
<li>
|
53
|
-
<p id='_'>
|
54
|
-
ISO Online browsing platform: available at
|
55
|
-
<link target='http://www.iso.org/obp'/>
|
56
|
-
</p>
|
57
|
-
</li>
|
58
|
-
<li>
|
59
|
-
<p id='_'>
|
60
|
-
IEC Electropedia: available at
|
61
|
-
<link target='http://www.electropedia.org'/>
|
62
|
-
</p>
|
63
|
-
</li>
|
64
|
-
</ul>
|
65
|
-
<term id='term-name2'>
|
66
|
-
<preferred>name2</preferred>
|
67
|
-
</term>
|
68
|
-
</terms>
|
69
|
-
<clause id='_' inline-header='false' obligation='normative'>
|
70
|
-
<title>Main</title>
|
71
|
-
<p id='_'>
|
72
|
-
<em>name</em>
|
73
|
-
(
|
74
|
-
<xref target='term-name2'/>
|
75
|
-
) is a term
|
76
|
-
</p>
|
77
|
-
</clause>
|
78
|
-
</sections>
|
79
|
-
</iso-standard>
|
80
|
-
XML
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'converts macro into the correct xml' do
|
84
|
-
expect(convert).to(be_equivalent_to(xmlpp(output)))
|
85
|
-
end
|
86
|
-
|
87
|
-
context 'default params' do
|
88
|
-
let(:input) do
|
89
|
-
<<~XML
|
90
|
-
#{ASCIIDOC_BLANK_HDR}
|
91
|
-
|
92
|
-
== Terms and Definitions
|
93
|
-
|
94
|
-
=== name
|
95
|
-
|
96
|
-
== Main
|
97
|
-
|
98
|
-
term:[name] is a term
|
99
|
-
XML
|
100
|
-
end
|
101
|
-
let(:output) do
|
102
|
-
<<~XML
|
103
|
-
#{BLANK_HDR}
|
104
|
-
<sections>
|
105
|
-
<terms id='_' obligation='normative'>
|
106
|
-
<title>Terms and definitions</title>
|
107
|
-
<p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
|
108
|
-
<p id='_'>
|
109
|
-
ISO and IEC maintain terminological databases for use in standardization
|
110
|
-
at the following addresses:
|
111
|
-
</p>
|
112
|
-
<ul id='_'>
|
113
|
-
<li>
|
114
|
-
<p id='_'>
|
115
|
-
ISO Online browsing platform: available at
|
116
|
-
<link target='http://www.iso.org/obp' />
|
117
|
-
</p>
|
118
|
-
</li>
|
119
|
-
<li>
|
120
|
-
<p id='_'>
|
121
|
-
IEC Electropedia: available at
|
122
|
-
<link target='http://www.electropedia.org' />
|
123
|
-
</p>
|
124
|
-
</li>
|
125
|
-
</ul>
|
126
|
-
<term id='term-name'>
|
127
|
-
<preferred>name</preferred>
|
128
|
-
</term>
|
129
|
-
</terms>
|
130
|
-
<clause id='_' inline-header='false' obligation='normative'>
|
131
|
-
<title>Main</title>
|
132
|
-
<p id='_'>
|
133
|
-
<em>name</em>
|
134
|
-
(
|
135
|
-
<xref target='term-name' />
|
136
|
-
) is a term
|
137
|
-
</p>
|
138
|
-
</clause>
|
139
|
-
</sections>
|
140
|
-
</iso-standard>
|
141
|
-
XML
|
142
|
-
end
|
143
|
-
|
144
|
-
it 'uses `name` as termref name' do
|
145
|
-
expect(convert).to(be_equivalent_to(xmlpp(output)))
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
context 'multiply exising ids in document' do
|
150
|
-
let(:input) do
|
151
|
-
<<~XML
|
152
|
-
#{ASCIIDOC_BLANK_HDR}
|
153
|
-
|
154
|
-
== Terms and Definitions
|
155
|
-
|
156
|
-
=== name
|
157
|
-
=== name2
|
158
|
-
|
159
|
-
[[term-name]]
|
160
|
-
== Main
|
161
|
-
|
162
|
-
paragraph
|
163
|
-
|
164
|
-
[[term-name2]]
|
165
|
-
== Second
|
166
|
-
|
167
|
-
term:[name] is a term
|
168
|
-
term:[name2] is a term
|
169
|
-
XML
|
170
|
-
end
|
171
|
-
let(:output) do
|
172
|
-
<<~XML
|
173
|
-
#{BLANK_HDR}
|
174
|
-
<sections>
|
175
|
-
<terms id='_' obligation='normative'>
|
176
|
-
<title>Terms and definitions</title>
|
177
|
-
<p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
|
178
|
-
<p id='_'>
|
179
|
-
ISO and IEC maintain terminological databases for use in standardization
|
180
|
-
at the following addresses:
|
181
|
-
</p>
|
182
|
-
<ul id='_'>
|
183
|
-
<li>
|
184
|
-
<p id='_'>
|
185
|
-
ISO Online browsing platform: available at
|
186
|
-
<link target='http://www.iso.org/obp' />
|
187
|
-
</p>
|
188
|
-
</li>
|
189
|
-
<li>
|
190
|
-
<p id='_'>
|
191
|
-
IEC Electropedia: available at
|
192
|
-
<link target='http://www.electropedia.org' />
|
193
|
-
</p>
|
194
|
-
</li>
|
195
|
-
</ul>
|
196
|
-
<term id='term-name-1'>
|
197
|
-
<preferred>name</preferred>
|
198
|
-
</term>
|
199
|
-
<term id='term-name2-1'>
|
200
|
-
<preferred>name2</preferred>
|
201
|
-
</term>
|
202
|
-
</terms>
|
203
|
-
<clause id='term-name' inline-header='false' obligation='normative'>
|
204
|
-
<title>Main</title>
|
205
|
-
<p id='_'>paragraph</p>
|
206
|
-
</clause>
|
207
|
-
<clause id='term-name2' inline-header='false' obligation='normative'>
|
208
|
-
<title>Second</title>
|
209
|
-
<p id='_'>
|
210
|
-
<em>name</em>
|
211
|
-
(
|
212
|
-
<xref target='term-name-1' />
|
213
|
-
) is a term
|
214
|
-
<em>name2</em>
|
215
|
-
(
|
216
|
-
<xref target='term-name2-1' />
|
217
|
-
) is a term
|
218
|
-
</p>
|
219
|
-
</clause>
|
220
|
-
</sections>
|
221
|
-
</iso-standard>
|
222
|
-
XML
|
223
|
-
end
|
224
|
-
|
225
|
-
it 'generates unique ids which dont match existing ids' do
|
226
|
-
expect(convert).to(be_equivalent_to(xmlpp(output)))
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
context 'when missing actual ref' do
|
231
|
-
let(:input) do
|
232
|
-
<<~XML
|
233
|
-
#{ASCIIDOC_BLANK_HDR}
|
234
|
-
|
235
|
-
== Terms and Definitions
|
236
|
-
|
237
|
-
=== name identity
|
238
|
-
|
239
|
-
[[name-check]]
|
240
|
-
=== name check
|
241
|
-
|
242
|
-
paragraph
|
243
|
-
|
244
|
-
term:[name check] is a term
|
245
|
-
|
246
|
-
term:[name identity] is a term
|
247
|
-
|
248
|
-
Moreover, term:[missing] is a term
|
249
|
-
XML
|
250
|
-
end
|
251
|
-
let(:output) do
|
252
|
-
<<~XML
|
253
|
-
#{BLANK_HDR}
|
254
|
-
<sections>
|
255
|
-
<terms id='_' obligation='normative'>
|
256
|
-
<title>Terms and definitions</title>
|
257
|
-
<p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
|
258
|
-
<p id='_'>
|
259
|
-
ISO and IEC maintain terminological databases for use in standardization
|
260
|
-
at the following addresses:
|
261
|
-
</p>
|
262
|
-
<ul id='_'>
|
263
|
-
<li>
|
264
|
-
<p id='_'>
|
265
|
-
ISO Online browsing platform: available at
|
266
|
-
<link target='http://www.iso.org/obp'/>
|
267
|
-
</p>
|
268
|
-
</li>
|
269
|
-
<li>
|
270
|
-
<p id='_'>
|
271
|
-
IEC Electropedia: available at
|
272
|
-
<link target='http://www.electropedia.org'/>
|
273
|
-
</p>
|
274
|
-
</li>
|
275
|
-
</ul>
|
276
|
-
<term id='term-name-identity'>
|
277
|
-
<preferred>name identity</preferred>
|
278
|
-
</term>
|
279
|
-
<term id='name-check'>
|
280
|
-
<preferred>name check</preferred>
|
281
|
-
<definition>
|
282
|
-
<p id='_'>paragraph</p>
|
283
|
-
<p id='_'>
|
284
|
-
<em>name check</em>
|
285
|
-
(
|
286
|
-
<xref target='name-check'/>
|
287
|
-
) is a term
|
288
|
-
</p>
|
289
|
-
<p id='_'>
|
290
|
-
<em>name identity</em>
|
291
|
-
(
|
292
|
-
<xref target='term-name-identity'/>
|
293
|
-
) is a term
|
294
|
-
</p>
|
295
|
-
<p id="_">Moreover, (<strong>term “missing” not resolved</strong>) is a term
|
296
|
-
</p>
|
297
|
-
</definition>
|
298
|
-
</term>
|
299
|
-
</terms>
|
300
|
-
</sections>
|
301
|
-
</iso-standard>
|
302
|
-
XML
|
303
|
-
end
|
304
|
-
|
305
|
-
it 'generates unique ids which dont match existing ids' do
|
306
|
-
expect(convert).to(be_equivalent_to(xmlpp(output)))
|
307
|
-
end
|
308
|
-
end
|
309
|
-
end
|
310
|
-
end
|