metanorma-standoc 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +351 -0
- data/lib/asciidoctor/standoc/base.rb +8 -4
- data/lib/asciidoctor/standoc/biblio.rng +1 -0
- data/lib/asciidoctor/standoc/cleanup_ref.rb +8 -9
- data/lib/asciidoctor/standoc/front.rb +8 -1
- data/lib/asciidoctor/standoc/ref.rb +3 -2
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +1 -0
- data/spec/asciidoctor-standoc/base_spec.rb +10 -0
- data/spec/asciidoctor-standoc/cleanup_spec.rb +134 -7
- data/spec/asciidoctor-standoc/isobib_cache_spec.rb +39 -0
- data/spec/asciidoctor-standoc/validate_spec.rb +1 -0
- data/spec/spec_helper.rb +12 -2
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56d1dfa7cef4ffc384854d78494c559fb24c426dd31d2429ad11de246e858b92
|
4
|
+
data.tar.gz: 3069d3e34e8ae8663655073ae67666964312b169bd42a056538d748f2dc8dae0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59cb8b7330a1605369d6216014bfceff8e60345985853a9c424be9bb99105b176e4ec5f3af9131d159f4616c7d2d93a2bfb4e7692b5028dc04bcbaeb2e6db5bf
|
7
|
+
data.tar.gz: b8cc513d452db412d7c86ebb9dd66c12e2c12be64ccdce84a70958ed6e1ce03f9b44226bbe378c14ef506af0dbfffed1562ca91b69a82ae646ad1d7dd84364b7
|
data/README.adoc
CHANGED
@@ -7,3 +7,354 @@ image:https://codeclimate.com/github/riboseinc/metanorma-standoc/badges/gpa.svg[
|
|
7
7
|
WARNING: This gem is still under development.
|
8
8
|
|
9
9
|
Gem for serialising the https://github.com/riboseinc/metanorma-model-standoc[Metanorma Standoc] model.
|
10
|
+
|
11
|
+
[[model_additions]]
|
12
|
+
== Asciidoctor model additions
|
13
|
+
|
14
|
+
=== Section titles
|
15
|
+
Metanorma standards has special section types: "Scope", "Normative References", "Terms and Definitions", "Symbols and Abbreviated Terms", "Bibliography". By default, these are identified in Asciidoc by using those titles. The gem allows you to override the title by using a `heading` attribute on the node, so that the actual title in your Asciidoc can be something different; that is useful, for example, if you are translating the document into different languages. So:
|
16
|
+
|
17
|
+
[source,asciidoctor]
|
18
|
+
--
|
19
|
+
[heading=scope]
|
20
|
+
== 范围
|
21
|
+
--
|
22
|
+
|
23
|
+
Note that both the XML population, and the isodoc gem will overwrite any supplied title. If you are translating Metanorma documents into other languages, you will still need access to versions of the metanorma-standoc and isodoc gems in those languages.
|
24
|
+
|
25
|
+
=== Obligation
|
26
|
+
The obligation of sections (whether they are normative or informative) is indicated
|
27
|
+
with the attribute "obligation". For most sections, this is fixed; for annexes and clauses, the
|
28
|
+
default value of the obligation is "normative", and users need to set the obligation
|
29
|
+
to "informative" as a section attribute.
|
30
|
+
|
31
|
+
[source,asciidoctor]
|
32
|
+
--
|
33
|
+
[[AnnexA]]
|
34
|
+
[appendix,obligation=informative]
|
35
|
+
== Determination of defects
|
36
|
+
--
|
37
|
+
|
38
|
+
=== Term markup
|
39
|
+
|
40
|
+
To ensure the structure of Terms and Definitions is captured accurately, the following
|
41
|
+
macros are defined, and must be used to mark up their respective content:
|
42
|
+
|
43
|
+
`alt:[TERM]`:: for alternative terms
|
44
|
+
`deprecated:[TERM]`:: for deprecated terms
|
45
|
+
`domain:[TERM]`:: for term domains
|
46
|
+
|
47
|
+
The macro contents can contain their own markup.
|
48
|
+
|
49
|
+
[source,asciidoctor]
|
50
|
+
--
|
51
|
+
=== paddy
|
52
|
+
alt:[_paddy_ rice]
|
53
|
+
deprecated:[#[smallcap]#cargo# rice]
|
54
|
+
domain:[rice]
|
55
|
+
|
56
|
+
_paddy_ (<<paddy>>) from which the husk only has been removed
|
57
|
+
--
|
58
|
+
|
59
|
+
=== Terms and Definitions markup
|
60
|
+
|
61
|
+
If the Terms and Definitions of a standard are partly or fully sourced from
|
62
|
+
another standard, that standard is cited in a `source` attribute to the section,
|
63
|
+
which is set to the reference anchor of the standard (given under the Normative
|
64
|
+
Referencecs)..
|
65
|
+
The boilerplate of the Terms and Definitions section is adjusted accordingly.
|
66
|
+
|
67
|
+
[source,asciidoctor]
|
68
|
+
--
|
69
|
+
[source=ISO712]
|
70
|
+
== Terms and Definitions
|
71
|
+
--
|
72
|
+
|
73
|
+
Multiple sources are allowed, and need to be quoted and comma-delimited:
|
74
|
+
|
75
|
+
[source,asciidoctor]
|
76
|
+
--
|
77
|
+
[source="ISO712,ISO24333"]
|
78
|
+
== Terms and Definitions
|
79
|
+
--
|
80
|
+
|
81
|
+
|
82
|
+
=== Paragraph alignment
|
83
|
+
|
84
|
+
Alignment is defined as an attribute for paragraphs:
|
85
|
+
|
86
|
+
[source,asciidoctor]
|
87
|
+
--
|
88
|
+
[align=left]
|
89
|
+
This paragraph is aligned left
|
90
|
+
|
91
|
+
[align=right]
|
92
|
+
This paragraph is aligned right
|
93
|
+
|
94
|
+
[align=center]
|
95
|
+
This paragraph is aligned center
|
96
|
+
|
97
|
+
[align=justified]
|
98
|
+
This paragraph is justified, which is the default
|
99
|
+
--
|
100
|
+
|
101
|
+
=== Reviewer notes
|
102
|
+
|
103
|
+
Reviewer notes are encoded as sidebars, and can be separated at a distance from the
|
104
|
+
text they are annotating; the text they are annotating is indicated through anchors.
|
105
|
+
Reviewer notes are only rendered if the document has a `:draft:` attribute.
|
106
|
+
|
107
|
+
The following attributes on reviewer notes are mandatory:
|
108
|
+
|
109
|
+
* `reviewer` attribute (naming the reviewer)
|
110
|
+
* the starting target anchor of the note (`from` attribute)
|
111
|
+
|
112
|
+
The following attributes are optional:
|
113
|
+
|
114
|
+
* `date` attribute, optionally including the time (as xs:date or xs:datetime)
|
115
|
+
* the ending target anchor of the note (`to` attribute)
|
116
|
+
|
117
|
+
The span of text covered by the reviewer note is from the start of the
|
118
|
+
text encompassed by the `from` element, to the end of the text encompassed
|
119
|
+
by the `to` element. If only the `from` element supplied, the reviewer note
|
120
|
+
covers the `from` element. The `from` and `to` elements can be bookmarks,
|
121
|
+
which cover no space.
|
122
|
+
|
123
|
+
[source,asciidoctor]
|
124
|
+
--
|
125
|
+
[[clause_address_profile_definition]]
|
126
|
+
=== Address Profile Definition (AddressProfileDescription)
|
127
|
+
|
128
|
+
[[para1]]
|
129
|
+
This is a clause address [[A]]profile[[B]] definition
|
130
|
+
|
131
|
+
[reviewer="Nick Nicholas",date=20180125T0121,from=clause_address_profile_definition,to=para1]
|
132
|
+
****
|
133
|
+
I do not agree with this statement.
|
134
|
+
****
|
135
|
+
|
136
|
+
[reviewer="Nick Nicholas",date=20180125T0121,from=A,to=B]
|
137
|
+
****
|
138
|
+
Profile?!
|
139
|
+
****
|
140
|
+
--
|
141
|
+
|
142
|
+
=== Strikethrough and Small Caps
|
143
|
+
|
144
|
+
The following formatting macros are used for strikethrough and small caps text:
|
145
|
+
|
146
|
+
[source,asciidoctor]
|
147
|
+
--
|
148
|
+
[strike]#strike through text#
|
149
|
+
[smallcap]#small caps text#
|
150
|
+
--
|
151
|
+
|
152
|
+
=== Count of table header and footer rows
|
153
|
+
|
154
|
+
In Asciidoc, a table can have at most one header row or footer row. In Metanorma,
|
155
|
+
a nominal single header row is routinely broken up into multiple rows in order
|
156
|
+
to accommodate units or symbols, that line up against each other, though
|
157
|
+
they are displayed as merged cells with no grid between them. To address this,
|
158
|
+
tables can be marked up with an optional `headerrows` attribute:
|
159
|
+
|
160
|
+
[source,asciidoctor]
|
161
|
+
--
|
162
|
+
[headerrows=2]
|
163
|
+
|===
|
164
|
+
.2+|Defect 4+^| Maximum permissible mass fraction of defects in husked rice +
|
165
|
+
stem:[w_max]
|
166
|
+
| in husked rice | in milled rice (non-glutinous) | in husked parboiled rice | in milled parboiled rice
|
167
|
+
|
168
|
+
| Extraneous matter: organic footnote:[Organic extraneous matter includes foreign seeds, husks, bran, parts of straw, etc.] | 1,0 | 0,5 | 1,0 | 0,5
|
169
|
+
|===
|
170
|
+
--
|
171
|
+
|
172
|
+
=== Inline clause numbers
|
173
|
+
|
174
|
+
For some clauses (notably test methods), the clause heading appears inline with the clause, instead of being separated on a different line. This is indicated in Asciidoc by the option
|
175
|
+
attribute `inline-header`:
|
176
|
+
|
177
|
+
[source,asciidoctor]
|
178
|
+
--
|
179
|
+
[%inline-header]
|
180
|
+
[[AnnexA-2-1]]
|
181
|
+
==== Sample divider,
|
182
|
+
|
183
|
+
consisting of a conical sample divider
|
184
|
+
--
|
185
|
+
|
186
|
+
=== Bibliographic details
|
187
|
+
|
188
|
+
Citations can include details of where in the document the citation is located; these
|
189
|
+
are entered by suffixing the type of locality, then an equals sign, then the reference.
|
190
|
+
The word "whole" on its own is also treated as a locality. Multiple
|
191
|
+
instances of locality and reference can be provided, delimited by comma or colon. Any trailing
|
192
|
+
text after the sequence of locality=reference (or locality, space, reference) are treated
|
193
|
+
as substitute text, as would occur normally in an Asciidoctor crossreference. For
|
194
|
+
example:
|
195
|
+
|
196
|
+
[source,asciidoctor]
|
197
|
+
--
|
198
|
+
<<ISO712,the foregoing reference>> # renders as: the foregoing reference
|
199
|
+
<<ISO712,section=5, page 8-10>> # renders as: ISO 712, Section 5, Page 8-10
|
200
|
+
<<ISO712,section=5, page=8-10: 5:8-10>> # renders as ISO 712, 5:8-10 ("5:8-10" treated as replacement text for all the foregoing)
|
201
|
+
<<ISO712,whole>> # renders as: ISO 712, Whole of text
|
202
|
+
--
|
203
|
+
|
204
|
+
The references cannot contain spaces. Any text following the sequence of localities
|
205
|
+
will be displayed instead of the localities.
|
206
|
+
|
207
|
+
A custom locality can be entered by prefixing it with `locality:`:
|
208
|
+
|
209
|
+
[source,asciidoctor]
|
210
|
+
--
|
211
|
+
<<ISO712,locality:frontispiece=5, page=8-10>> # renders as: ISO 712, Frontispiece 5, Page 8-10
|
212
|
+
--
|
213
|
+
|
214
|
+
Custom localities may not contain commas, colons, or space. Localities with the `locality:`
|
215
|
+
prefix are recognised in internationalisation configuration files.
|
216
|
+
|
217
|
+
=== Block Quotes
|
218
|
+
|
219
|
+
As in normal Asciidoctor, block quotes are preceded with an author and a citation;
|
220
|
+
but the citation is expected to be in the same format as all other citations,
|
221
|
+
a cross-reference optionally followed by text, which may include the bibliographic
|
222
|
+
sections referenced:
|
223
|
+
|
224
|
+
[source,asciidoctor]
|
225
|
+
--
|
226
|
+
[quote, ISO, "ISO7301,section 1"]
|
227
|
+
_____
|
228
|
+
This International Standard gives the minimum specifications for rice (_Oryza sativa_ L.)
|
229
|
+
which is subject to international trade. It is applicable to the following types: husked rice
|
230
|
+
and milled rice, parboiled or not, intended for direct human consumption. It is neither
|
231
|
+
applicable to other products derived from rice, nor to waxy rice (glutinous rice).
|
232
|
+
_____
|
233
|
+
--
|
234
|
+
|
235
|
+
=== Image size
|
236
|
+
|
237
|
+
The value `auto` is accepted for image width and height attributes. It is only passed on
|
238
|
+
to HTML output; if the output is to Word, both the width and height attributes are stripped
|
239
|
+
from the image.
|
240
|
+
|
241
|
+
[source,asciidoctor]
|
242
|
+
--
|
243
|
+
[height=90,width=auto]
|
244
|
+
image::logo.jpg
|
245
|
+
--
|
246
|
+
|
247
|
+
=== Subclauses in Terms & Definitions sections
|
248
|
+
|
249
|
+
Normally any terminal subclause in a Terms & Definitions section is treated as a term
|
250
|
+
definition. Exceptionally, an introductory section can be tagged to be treated as a clause,
|
251
|
+
instead of a term, by prefixing it with the style attribute `[.nonterm]`.
|
252
|
+
|
253
|
+
[source,asciidoctor]
|
254
|
+
--
|
255
|
+
== Terms and definitions
|
256
|
+
|
257
|
+
[.nonterm]
|
258
|
+
=== Introduction
|
259
|
+
The following terms have non-normative effect, and should be ignored by the ametrical.
|
260
|
+
|
261
|
+
=== Anapaest
|
262
|
+
|
263
|
+
metrical foot consisting of a short, a long, and a short
|
264
|
+
--
|
265
|
+
|
266
|
+
=== Sections embedded more than 5 levels
|
267
|
+
|
268
|
+
Asciidoctor permits only 5 levels of section embedding (not counting the document title).
|
269
|
+
Standards do contain more levels of embedding; ISO/IEC DIR 2 only considers it a problem
|
270
|
+
if there are more than 7 levels of embedding. To realise higher levels of embedding,
|
271
|
+
prefix a 5-level section title with the attribute `level=`:
|
272
|
+
|
273
|
+
[source,asciidoctor]
|
274
|
+
--
|
275
|
+
====== Clause 5
|
276
|
+
|
277
|
+
[level=6]
|
278
|
+
===== Clause 6
|
279
|
+
|
280
|
+
[level=7]
|
281
|
+
====== Clause 7A
|
282
|
+
|
283
|
+
[level=7]
|
284
|
+
====== Clause 7B
|
285
|
+
|
286
|
+
[level=6]
|
287
|
+
====== Clause 6B
|
288
|
+
|
289
|
+
====== Clause 5B
|
290
|
+
--
|
291
|
+
|
292
|
+
This generates the following ISO XML:
|
293
|
+
|
294
|
+
[source,xml]
|
295
|
+
--
|
296
|
+
<clause id="_" inline-header="false" obligation="normative">
|
297
|
+
<title>
|
298
|
+
Clause 5
|
299
|
+
</title>
|
300
|
+
<clause id="_" inline-header="false" obligation="normative">
|
301
|
+
<title>
|
302
|
+
Clause 6
|
303
|
+
</title>
|
304
|
+
<clause id="_" inline-header="false" obligation="normative">
|
305
|
+
<title>
|
306
|
+
Clause 7A
|
307
|
+
</title>
|
308
|
+
</clause>
|
309
|
+
<clause id="_" inline-header="false" obligation="normative">
|
310
|
+
<title>
|
311
|
+
Clause 7B
|
312
|
+
</title>
|
313
|
+
</clause>
|
314
|
+
</clause>
|
315
|
+
<clause id="_" inline-header="false" obligation="normative">
|
316
|
+
<title>
|
317
|
+
Clause 6B
|
318
|
+
</title>
|
319
|
+
</clause>
|
320
|
+
</clause>
|
321
|
+
<clause id="_" inline-header="false" obligation="normative">
|
322
|
+
<title>
|
323
|
+
Clause 5B
|
324
|
+
</title>
|
325
|
+
</clause>
|
326
|
+
--
|
327
|
+
|
328
|
+
=== PlantUML
|
329
|
+
|
330
|
+
The http://plantuml.com[PlantUML] diagramming tool is integrated with Asciidoctor
|
331
|
+
in this gem, as a literal block with the style attribute `plantuml`:
|
332
|
+
|
333
|
+
[source,asciidoctor]
|
334
|
+
--
|
335
|
+
[plantuml]
|
336
|
+
....
|
337
|
+
@startuml
|
338
|
+
Alice -> Bob: Authentication Request
|
339
|
+
Bob --> Alice: Authentication Response
|
340
|
+
|
341
|
+
Alice -> Bob: Another authentication Request
|
342
|
+
Alice <-- Bob: another authentication Response
|
343
|
+
@enduml
|
344
|
+
....
|
345
|
+
--
|
346
|
+
|
347
|
+
The integration runs PlantUML for each such block, generating a PNG image.
|
348
|
+
The images are stored in the `plantuml` directory, and linked into the output
|
349
|
+
document in place of the PlantUML.
|
350
|
+
|
351
|
+
PlantUML needs to be installed by users separately, and accesssible from the
|
352
|
+
command line:
|
353
|
+
|
354
|
+
* `brew install plantuml` on MacOS.
|
355
|
+
* For Linux, link the PlantUML jar file into a command line executable; see
|
356
|
+
`.travis.yml` for an example.
|
357
|
+
|
358
|
+
If PlantUML is not installed locally, the source PlantUML is incorporated into
|
359
|
+
the output document as sourcecode.
|
360
|
+
|
@@ -42,6 +42,8 @@ module Asciidoctor
|
|
42
42
|
htmlcoverpage: node.attr("htmlcoverpage"),
|
43
43
|
htmlintropage: node.attr("htmlintropage"),
|
44
44
|
scripts: node.attr("scripts"),
|
45
|
+
scripts_pdf: node.attr("scripts-pdf"),
|
46
|
+
datauriimage: node.attr("data-uri-image"),
|
45
47
|
}
|
46
48
|
end
|
47
49
|
|
@@ -92,8 +94,9 @@ module Asciidoctor
|
|
92
94
|
|
93
95
|
def init_bib_caches(node)
|
94
96
|
unless (@no_isobib_cache || @no_isobib)
|
95
|
-
globalname = bibliocache_name(true)
|
96
|
-
localname = bibliocache_name(false) if node.attr("local-cache")
|
97
|
+
globalname = bibliocache_name(true) unless node.attr("local-cache-only")
|
98
|
+
localname = bibliocache_name(false) if node.attr("local-cache") ||
|
99
|
+
node.attr("local-cache-only")
|
97
100
|
if node.attr("flush-caches")
|
98
101
|
system("rm -f #{globalname}") unless globalname.nil?
|
99
102
|
system("rm -f #{localname}") unless localname.nil?
|
@@ -104,8 +107,9 @@ module Asciidoctor
|
|
104
107
|
|
105
108
|
def init_iev_caches(node)
|
106
109
|
unless (@no_isobib_cache || @no_isobib)
|
107
|
-
globalname = ievcache_name(true)
|
108
|
-
localname = ievcache_name(false) if node.attr("local-cache")
|
110
|
+
globalname = ievcache_name(true) unless node.attr("local-cache-only")
|
111
|
+
localname = ievcache_name(false) if node.attr("local-cache") ||
|
112
|
+
node.attr("local-cache-only")
|
109
113
|
if node.attr("flush-caches")
|
110
114
|
system("rm -f #{globalname}") unless globalname.nil?
|
111
115
|
system("rm -f #{localname}") unless localname.nil?
|
@@ -116,11 +116,7 @@ module Asciidoctor
|
|
116
116
|
xmldoc.xpath("//bibitem[not(ancestor::bibitem)]").each do |ref|
|
117
117
|
isopub = ref.at(ISO_PUBLISHER_XPATH)
|
118
118
|
docid = ref.at("./docidentifier[not(@type = 'DOI')]")
|
119
|
-
#date = ref.at("./date[@type = 'published']")
|
120
|
-
#allparts = ref.at("./allparts")
|
121
119
|
reference = format_ref(docid.text, isopub)
|
122
|
-
#reference += ":#{date_range(date)}" if date
|
123
|
-
#reference += " (all parts)" if allparts
|
124
120
|
@anchors[ref["id"]] = { xref: reference }
|
125
121
|
end
|
126
122
|
end
|
@@ -137,19 +133,22 @@ module Asciidoctor
|
|
137
133
|
m = /^(\d+)/.match cl || next
|
138
134
|
parts << m[0]
|
139
135
|
x["citeas"] = x["citeas"].sub(/60050/, "60050-#{m[0]}")
|
140
|
-
x["bibitemid"] =
|
136
|
+
x["bibitemid"] = "IEC60050-#{m[0]}"
|
141
137
|
end
|
142
138
|
parts
|
143
139
|
end
|
144
140
|
|
145
141
|
# replace generic IEV reference with references to all extracted
|
146
142
|
# IEV parts
|
147
|
-
def refsIev2iec60050part(parts, iev)
|
143
|
+
def refsIev2iec60050part(xmldoc, parts, iev)
|
148
144
|
new_iev = ""
|
149
145
|
parts.sort.each do |p|
|
150
|
-
hit = @bibdb&.fetch("IEC 60050-#{p}", nil, keep_year: true)
|
151
|
-
next if hit.nil?
|
146
|
+
hit = @bibdb&.fetch("IEC 60050-#{p}", nil, keep_year: true) || next
|
152
147
|
new_iev += hit.to_xml.sub(/ id="[^"]+"/, %{ id="IEC60050-#{p}"})
|
148
|
+
date = hit.dates[0].on.year
|
149
|
+
xmldoc.xpath("//*[@citeas = 'IEC 60050-#{p}:2011']").each do |x|
|
150
|
+
x["citeas"] = x["citeas"].sub(/:2011$/, ":#{date}")
|
151
|
+
end
|
153
152
|
end
|
154
153
|
iev.replace(new_iev)
|
155
154
|
end
|
@@ -158,7 +157,7 @@ module Asciidoctor
|
|
158
157
|
def iev_cleanup(xmldoc)
|
159
158
|
iev = xmldoc.at("//bibitem[docidentifier = 'IEC 60050:2011']") || return
|
160
159
|
parts = linksIev2iec60050part(xmldoc)
|
161
|
-
refsIev2iec60050part(parts, iev)
|
160
|
+
refsIev2iec60050part(xmldoc, parts, iev)
|
162
161
|
end
|
163
162
|
end
|
164
163
|
end
|
@@ -29,10 +29,17 @@ module Asciidoctor
|
|
29
29
|
out.send compname.gsub(/-/, "_"), node.attr(compname),
|
30
30
|
**attr_code(number: node.attr("#{compname}-number"),
|
31
31
|
type: node.attr("#{compname}-type"))
|
32
|
+
i = 2
|
33
|
+
while node.attr(compname+"_#{i}") do
|
34
|
+
out.send compname.gsub(/-/, "_"), node.attr(compname+"_#{i}"),
|
35
|
+
**attr_code(number: node.attr("#{compname}-number_#{i}"),
|
36
|
+
type: node.attr("#{compname}-type_#{i}"))
|
37
|
+
i += 1
|
38
|
+
end
|
32
39
|
end
|
33
40
|
|
34
41
|
def organization(org, orgname)
|
35
|
-
|
42
|
+
org.name orgname
|
36
43
|
end
|
37
44
|
|
38
45
|
def metadata_author(node, xml)
|
@@ -44,8 +44,8 @@ module Asciidoctor
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def docid(t, code)
|
47
|
-
type,
|
48
|
-
t.docidentifier (
|
47
|
+
type, code1 = @bibdb&.docid_type(code) unless /^\[\d+\]$/.match(code)
|
48
|
+
t.docidentifier (code1 || code), **attr_code(type: type)
|
49
49
|
end
|
50
50
|
|
51
51
|
def isorefmatches(xml, m)
|
@@ -101,6 +101,7 @@ module Asciidoctor
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def fetch_ref(xml, code, year, **opts)
|
104
|
+
return nil if opts[:no_year]
|
104
105
|
hit = @bibdb&.fetch(code, year, opts)
|
105
106
|
return nil if hit.nil?
|
106
107
|
xml.parent.add_child(hit.to_xml)
|
data/metanorma-standoc.gemspec
CHANGED
@@ -52,6 +52,15 @@ RSpec.describe Asciidoctor::Standoc do
|
|
52
52
|
:workgroup: WG
|
53
53
|
:workgroup-number: 3
|
54
54
|
:workgroup-type: C
|
55
|
+
:technical-committee_2: TC1
|
56
|
+
:technical-committee-number_2: 11
|
57
|
+
:technical-committee-type_2: A1
|
58
|
+
:subcommittee_2: SC1
|
59
|
+
:subcommittee-number_2: 21
|
60
|
+
:subcommittee-type_2: B1
|
61
|
+
:workgroup_2: WG1
|
62
|
+
:workgroup-number_2: 31
|
63
|
+
:workgroup-type_2: C1
|
55
64
|
:secretariat: SECRETARIAT
|
56
65
|
:copyright-year: 2001
|
57
66
|
:docstage: 10
|
@@ -76,6 +85,7 @@ RSpec.describe Asciidoctor::Standoc do
|
|
76
85
|
</copyright>
|
77
86
|
<editorialgroup>
|
78
87
|
<technical-committee number="1" type="A">TC</technical-committee>
|
88
|
+
<technical-committee number="11" type="A1">TC1</technical-committee>
|
79
89
|
</editorialgroup>
|
80
90
|
<ics>
|
81
91
|
<code>1</code>
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
require "iecbib"
|
2
3
|
|
3
4
|
RSpec.describe Asciidoctor::Standoc do
|
4
5
|
it "removes empty text elements" do
|
@@ -807,6 +808,11 @@ r = 1 %</stem>
|
|
807
808
|
it "separates IEV citations by top-level clause" do
|
808
809
|
system "mv ~/.iev.pstore ~/.iev.pstore1"
|
809
810
|
system "rm test.iev.pstore"
|
811
|
+
system "mv ~/.relaton-bib.pstore ~/.relaton-bib.pstore1"
|
812
|
+
system "rm test.relaton.pstore"
|
813
|
+
mock_iecbib_get_iec60050_102_01
|
814
|
+
mock_iecbib_get_iec60050_103_01
|
815
|
+
mock_iev
|
810
816
|
expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
|
811
817
|
#{CACHED_ISOBIB_BLANK_HDR}
|
812
818
|
|
@@ -836,27 +842,27 @@ r = 1 %</stem>
|
|
836
842
|
<terms id="_" obligation="normative"><title>Terms and definitions</title><term id="_">
|
837
843
|
<preferred>Automation1</preferred>
|
838
844
|
<termsource status="identical">
|
839
|
-
<origin bibitemid="
|
845
|
+
<origin bibitemid="IEC60050-103" type="inline" citeas="IEC 60050-103:2009"><locality type="clause"><referenceFrom>103-01-02</referenceFrom></locality></origin>
|
840
846
|
</termsource>
|
841
847
|
</term>
|
842
848
|
<term id="_">
|
843
849
|
<preferred>Automation2</preferred>
|
844
850
|
<termsource status="identical">
|
845
|
-
<origin bibitemid="
|
851
|
+
<origin bibitemid="IEC60050-102" type="inline" citeas="IEC 60050-102:2007"><locality type="clause"><referenceFrom>102-01-02</referenceFrom></locality></origin>
|
846
852
|
</termsource>
|
847
853
|
</term>
|
848
854
|
<term id="_">
|
849
855
|
<preferred>Automation3</preferred>
|
850
856
|
<termsource status="identical">
|
851
|
-
<origin bibitemid="
|
857
|
+
<origin bibitemid="IEC60050-103" type="inline" citeas="IEC 60050-103:2009"><locality type="clause"><referenceFrom>103-01-02</referenceFrom></locality></origin>
|
852
858
|
</termsource>
|
853
859
|
</term></terms></sections><bibliography><references id="_" obligation="informative">
|
854
860
|
<title>Normative References</title>
|
855
861
|
<bibitem type="international-standard" id="IEC60050-102">
|
856
862
|
<title format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary</title>
|
857
|
-
<docidentifier>IEC 60050-102:
|
863
|
+
<docidentifier>IEC 60050-102:2007</docidentifier>
|
858
864
|
<date type="published">
|
859
|
-
<on>
|
865
|
+
<on>2007</on>
|
860
866
|
</date>
|
861
867
|
<contributor>
|
862
868
|
<role type="publisher"/>
|
@@ -884,9 +890,9 @@ r = 1 %</stem>
|
|
884
890
|
</copyright>
|
885
891
|
</bibitem><bibitem type="international-standard" id="IEC60050-103">
|
886
892
|
<title format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary</title>
|
887
|
-
<docidentifier>IEC 60050-103:
|
893
|
+
<docidentifier>IEC 60050-103:2009</docidentifier>
|
888
894
|
<date type="published">
|
889
|
-
<on>
|
895
|
+
<on>2009</on>
|
890
896
|
</date>
|
891
897
|
<contributor>
|
892
898
|
<role type="publisher"/>
|
@@ -917,5 +923,126 @@ r = 1 %</stem>
|
|
917
923
|
</standard-document>
|
918
924
|
OUTPUT
|
919
925
|
system "mv ~/.iev.pstore1 ~/.iev.pstore"
|
926
|
+
system "rm ~/.relaton-bib.pstore"
|
927
|
+
system "mv ~/.relaton-bib.pstore1 ~/.relaton-bib.pstore"
|
920
928
|
end
|
929
|
+
|
930
|
+
private
|
931
|
+
|
932
|
+
def mock_iecbib_get_iec60050_103_01
|
933
|
+
expect(Iecbib::IecBibliography).to receive(:get).with("IEC 60050-103", nil, {keep_year: true}) do
|
934
|
+
IsoBibItem.from_xml(<<~"OUTPUT")
|
935
|
+
<bibitem type="international-standard" id="IEC60050-103">
|
936
|
+
<title format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary</title>
|
937
|
+
<docidentifier>IEC 60050-103:2009</docidentifier>
|
938
|
+
<date type="published">
|
939
|
+
<on>2009</on>
|
940
|
+
</date>
|
941
|
+
<contributor>
|
942
|
+
<role type="publisher"/>
|
943
|
+
<organization>
|
944
|
+
<name>International Electrotechnical Commission</name>
|
945
|
+
<abbreviation>IEC</abbreviation>
|
946
|
+
<uri>www.iec.ch</uri>
|
947
|
+
</organization>
|
948
|
+
</contributor>
|
949
|
+
<language>en</language>
|
950
|
+
<language>fr</language>
|
951
|
+
<script>Latn</script>
|
952
|
+
<status>
|
953
|
+
<stage>60</stage>
|
954
|
+
</status>
|
955
|
+
<copyright>
|
956
|
+
<from>2018</from>
|
957
|
+
<owner>
|
958
|
+
<organization>
|
959
|
+
<name>International Electrotechnical Commission</name>
|
960
|
+
<abbreviation>IEC</abbreviation>
|
961
|
+
<uri>www.iec.ch</uri>
|
962
|
+
</organization>
|
963
|
+
</owner>
|
964
|
+
</copyright>
|
965
|
+
</bibitem>
|
966
|
+
OUTPUT
|
967
|
+
end
|
968
|
+
end
|
969
|
+
|
970
|
+
def mock_iecbib_get_iec60050_102_01
|
971
|
+
expect(Iecbib::IecBibliography).to receive(:get).with("IEC 60050-102", nil, {keep_year: true}) do
|
972
|
+
IsoBibItem.from_xml(<<~"OUTPUT")
|
973
|
+
<bibitem type="international-standard" id="IEC60050-102">
|
974
|
+
<title format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary</title>
|
975
|
+
<docidentifier>IEC 60050-102:2007</docidentifier>
|
976
|
+
<date type="published">
|
977
|
+
<on>2007</on>
|
978
|
+
</date>
|
979
|
+
<contributor>
|
980
|
+
<role type="publisher"/>
|
981
|
+
<organization>
|
982
|
+
<name>International Electrotechnical Commission</name>
|
983
|
+
<abbreviation>IEC</abbreviation>
|
984
|
+
<uri>www.iec.ch</uri>
|
985
|
+
</organization>
|
986
|
+
</contributor>
|
987
|
+
<language>en</language>
|
988
|
+
<language>fr</language>
|
989
|
+
<script>Latn</script>
|
990
|
+
<status>
|
991
|
+
<stage>60</stage>
|
992
|
+
</status>
|
993
|
+
<copyright>
|
994
|
+
<from>2018</from>
|
995
|
+
<owner>
|
996
|
+
<organization>
|
997
|
+
<name>International Electrotechnical Commission</name>
|
998
|
+
<abbreviation>IEC</abbreviation>
|
999
|
+
<uri>www.iec.ch</uri>
|
1000
|
+
</organization>
|
1001
|
+
</owner>
|
1002
|
+
</copyright>
|
1003
|
+
</bibitem>
|
1004
|
+
OUTPUT
|
1005
|
+
end
|
1006
|
+
end
|
1007
|
+
|
1008
|
+
def mock_iev
|
1009
|
+
expect(Iecbib::IecBibliography).to receive(:get).with("IEV", nil, {}) do
|
1010
|
+
IsoBibItem.from_xml(<<~"OUTPUT")
|
1011
|
+
<bibitem type="international-standard" id="IEC60050:2001">
|
1012
|
+
<title format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary</title>
|
1013
|
+
<docidentifier>IEC 60050:2011</docidentifier>
|
1014
|
+
<date type="published">
|
1015
|
+
<on>2007</on>
|
1016
|
+
</date>
|
1017
|
+
<contributor>
|
1018
|
+
<role type="publisher"/>
|
1019
|
+
<organization>
|
1020
|
+
<name>International Electrotechnical Commission</name>
|
1021
|
+
<abbreviation>IEC</abbreviation>
|
1022
|
+
<uri>www.iec.ch</uri>
|
1023
|
+
</organization>
|
1024
|
+
</contributor>
|
1025
|
+
<language>en</language>
|
1026
|
+
<language>fr</language>
|
1027
|
+
<script>Latn</script>
|
1028
|
+
<status>
|
1029
|
+
<stage>60</stage>
|
1030
|
+
</status>
|
1031
|
+
<copyright>
|
1032
|
+
<from>2018</from>
|
1033
|
+
<owner>
|
1034
|
+
<organization>
|
1035
|
+
<name>International Electrotechnical Commission</name>
|
1036
|
+
<abbreviation>IEC</abbreviation>
|
1037
|
+
<uri>www.iec.ch</uri>
|
1038
|
+
</organization>
|
1039
|
+
</owner>
|
1040
|
+
</copyright>
|
1041
|
+
</bibitem>
|
1042
|
+
OUTPUT
|
1043
|
+
end.at_least :once
|
1044
|
+
end
|
1045
|
+
|
1046
|
+
|
1047
|
+
|
921
1048
|
end
|
@@ -119,6 +119,25 @@ EOS
|
|
119
119
|
system "mv ~/.iev.pstore1 ~/.iev.pstore"
|
120
120
|
end
|
121
121
|
|
122
|
+
it "does not fetch references for ISO references in preparation" do
|
123
|
+
system "mv ~/.relaton-bib.pstore ~/.relaton-bib.pstore1"
|
124
|
+
system "rm -f test.relaton.pstore"
|
125
|
+
Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
|
126
|
+
#{CACHED_ISOBIB_BLANK_HDR}
|
127
|
+
[bibliography]
|
128
|
+
== Normative References
|
129
|
+
|
130
|
+
* [[[iso123,ISO 123:--]]] footnote:[The standard is in press] _Standard_
|
131
|
+
INPUT
|
132
|
+
expect(File.exist?("#{Dir.home}/.relaton-bib.pstore")).to be true
|
133
|
+
db = Relaton::Db.new "#{Dir.home}/.relaton-bib.pstore", nil
|
134
|
+
entry = db.load_entry("ISO(ISO 123:--)")
|
135
|
+
expect(entry).to be nil
|
136
|
+
|
137
|
+
system "rm ~/.relaton-bib.pstore"
|
138
|
+
system "mv ~/.relaton-bib.pstore1 ~/.relaton-bib.pstore"
|
139
|
+
end
|
140
|
+
|
122
141
|
it "activates global cache" do
|
123
142
|
system "mv ~/.relaton-bib.pstore ~/.relaton-bib.pstore1"
|
124
143
|
system "rm -f test.relaton.pstore"
|
@@ -167,6 +186,26 @@ EOS
|
|
167
186
|
system "mv ~/.relaton-bib.pstore1 ~/.relaton-bib.pstore"
|
168
187
|
end
|
169
188
|
|
189
|
+
it "activates only local cache" do
|
190
|
+
system "mv ~/.relaton-bib.pstore ~/.relaton-bib.pstore1"
|
191
|
+
system "rm -f test.relaton.pstore"
|
192
|
+
mock_isobib_get_123
|
193
|
+
Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
|
194
|
+
#{LOCAL_ONLY_CACHED_ISOBIB_BLANK_HDR}
|
195
|
+
[bibliography]
|
196
|
+
== Normative References
|
197
|
+
|
198
|
+
* [[[iso123,ISO 123:2001]]] _Standard_
|
199
|
+
INPUT
|
200
|
+
expect(File.exist?("#{Dir.home}/.relaton-bib.pstore")).to be false
|
201
|
+
expect(File.exist?("test.relaton.pstore")).to be true
|
202
|
+
|
203
|
+
db = Relaton::Db.new "test.relaton.pstore", nil
|
204
|
+
entry = db.load_entry("ISO(ISO 123:2001)")
|
205
|
+
expect(entry).to_not be nil
|
206
|
+
|
207
|
+
system "mv ~/.relaton-bib.pstore1 ~/.relaton-bib.pstore"
|
208
|
+
end
|
170
209
|
|
171
210
|
it "fetches uncached references" do
|
172
211
|
system "mv ~/.relaton-bib.pstore ~/.relaton-bib.pstore1"
|
data/spec/spec_helper.rb
CHANGED
@@ -76,6 +76,16 @@ LOCAL_CACHED_ISOBIB_BLANK_HDR = <<~"HDR"
|
|
76
76
|
|
77
77
|
HDR
|
78
78
|
|
79
|
+
LOCAL_ONLY_CACHED_ISOBIB_BLANK_HDR = <<~"HDR"
|
80
|
+
= Document title
|
81
|
+
Author
|
82
|
+
:docfile: test.adoc
|
83
|
+
:nodoc:
|
84
|
+
:novalid:
|
85
|
+
:local-cache-only:
|
86
|
+
|
87
|
+
HDR
|
88
|
+
|
79
89
|
VALIDATING_BLANK_HDR = <<~"HDR"
|
80
90
|
= Document title
|
81
91
|
Author
|
@@ -189,10 +199,10 @@ end
|
|
189
199
|
|
190
200
|
def mock_open_uri(code)
|
191
201
|
expect(OpenURI).to receive(:open_uri).and_wrap_original do |m, *args|
|
192
|
-
expect(args[0]).to be_instance_of String
|
202
|
+
# expect(args[0]).to be_instance_of String
|
193
203
|
file = "spec/examples/#{code.tr('-', '_')}.html"
|
194
204
|
File.write file, m.call(*args).read unless File.exist? file
|
195
205
|
File.read file
|
196
|
-
end
|
206
|
+
end.at_least :once
|
197
207
|
end
|
198
208
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-standoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -262,6 +262,20 @@ dependencies:
|
|
262
262
|
- - "~>"
|
263
263
|
- !ruby/object:Gem::Version
|
264
264
|
version: 0.4.0
|
265
|
+
- !ruby/object:Gem::Dependency
|
266
|
+
name: iecbib
|
267
|
+
requirement: !ruby/object:Gem::Requirement
|
268
|
+
requirements:
|
269
|
+
- - "~>"
|
270
|
+
- !ruby/object:Gem::Version
|
271
|
+
version: 0.1.1
|
272
|
+
type: :development
|
273
|
+
prerelease: false
|
274
|
+
version_requirements: !ruby/object:Gem::Requirement
|
275
|
+
requirements:
|
276
|
+
- - "~>"
|
277
|
+
- !ruby/object:Gem::Version
|
278
|
+
version: 0.1.1
|
265
279
|
description: |
|
266
280
|
metanorma-standoc realises standards following the Metanorma standoc model
|
267
281
|
|