metanorma-iso 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da80e1829e3bb23b48ec255ec0d6533f4649eb2ad68c226213bc79715ae2b1a4
4
- data.tar.gz: 91fde5d59c47042e11426c4b66128acd946302786345f30aead55e0783b30297
3
+ metadata.gz: '07499247abd9fb32513b4866fe1ed231c89ab893d360ed817cd215361c31aac1'
4
+ data.tar.gz: 0e72da21b9efc829e6868edaacaf430bccfc816588ad0b209fe7ed3fdb077e74
5
5
  SHA512:
6
- metadata.gz: a20bb43d79f3e9590238a0f115d70d149d14b8ee5884e97898f7ab40f8fcc5cf6855bb5065d90e3931f763d620a68dba936ad79a0a7d87e42e31289a5273b1da
7
- data.tar.gz: d9ed11afc2c9ba8ed9964106dc9ebdbbde7278be5b06036e4ba7150a2a0501bd968a10bf7f31cf98c96cb713cb0cd9950b4b47431f91471ce1831b8f454b2bec
6
+ metadata.gz: c0c76bae355c918ed8dc336e6f00a2145621d7c2c1382331b486381ffc2f57071777d8dd582754c021ec3dfdc45820ec3122c1034ea36048e14fafc1a3505420
7
+ data.tar.gz: c178a3832ede766c0aea9662284179def0fe8df3c45994de3b396714688c06d0170cf29e0dcc8f1351f4885428a9ee7013d9f7d7898f49cbbbd849e4192e7436
@@ -454,6 +454,25 @@ from the image.
454
454
  image::logo.jpg
455
455
  --
456
456
 
457
+ === Subclauses in Terms & Definitions sections
458
+
459
+ Normally any terminal subclause in a Terms & Definitions section is treated as a term
460
+ definition. Exceptionally, an introductory section can be tagged to be treated as a clause,
461
+ instead of a term, by prefixing it with the style attribute `[.nonterm]`.
462
+
463
+ [source,asciidoctor]
464
+ --
465
+ == Terms and definitions
466
+
467
+ [.nonterm]
468
+ === Introduction
469
+ The following terms have non-normative effect, and should be ignored by the ametrical.
470
+
471
+ === Anapaest
472
+
473
+ metrical foot consisting of a short, a long, and a short
474
+ --
475
+
457
476
  === Sections embedded more than 5 levels
458
477
 
459
478
  Asciidoctor permits only 5 levels of section embedding (not counting the document title).
@@ -241,6 +241,20 @@ stem:[t_A]
241
241
  Time to launch.
242
242
  --
243
243
 
244
+ As defined above, all terminal subclauses of a term section are treated as term definitions. Exceptionally, an introductory section can be treated as a subclause instead of a term, by prefixing it with the style attribute `[.nonterm]`:
245
+
246
+ [source,asciidoctor]
247
+ --
248
+ == Terms and definitions
249
+
250
+ [.nonterm]
251
+ === Introduction
252
+ The following terms have non-normative effect, and should be ignored by the ametrical.
253
+
254
+ === Anapaest
255
+
256
+ metrical foot consisting of a short, a long, and a short
257
+ --
244
258
 
245
259
  === Symbols and Abbreviations
246
260
 
@@ -323,6 +323,8 @@ and Note 1 to entry is not included here
323
323
 
324
324
  Term banks such as the http://www.electropedia.org[IEV] must be treated like any other document, with terms treated as clauses; e.g. `<<IEV,clause "103-01-01">>`. The IEV must be explictly referenced with that label; when the XML is generated, it will be replaced by the official references to `IEC 60050-nnn:2001` standards documents.
325
325
 
326
+ Exceptionally, an introductory section can be treated as a subclause instead of a term, by prefixing it with the style attribute `[.nonterm]`.
327
+
326
328
  === References (Normative, Informative)
327
329
 
328
330
  All bibliographic entries must be given as unordered lists. Normative references are expected to include only ISO and related standards; informative references may include any source.
@@ -21,7 +21,8 @@ module Asciidoctor
21
21
  @term_def = true
22
22
  term_def_parse(a, xml, node, true)
23
23
  @term_def = false
24
- when "symbols and abbreviated terms"
24
+ when "symbols and abbreviated terms",
25
+ "abbreviations", "abbreviated terms", "symbols"
25
26
  symbols_parse(a, xml, node)
26
27
  when "bibliography" then bibliography_parse(a, xml, node)
27
28
  else
@@ -69,122 +69,132 @@ module Asciidoctor
69
69
  subtitle = ss.at("./title")
70
70
  !subtitle.nil? && !subtitle&.text&.empty? ||
71
71
  warn("#{title}: each first-level subclause must have a title")
72
+ end
73
+ end
72
74
  end
73
- end
74
- end
75
75
 
76
- def title_all_siblings(xpath, label)
77
- notitle = false
78
- withtitle = false
79
- xpath.each do |s|
80
- title_all_siblings(s.xpath("./clause | ./terms | ./references"),
81
- s&.at("./title")&.text || s["id"])
82
- subtitle = s.at("./title")
83
- notitle = notitle || (!subtitle || subtitle.text.empty?)
84
- withtitle = withtitle || (subtitle && !subtitle.text.empty?)
85
- end
86
- notitle && withtitle &&
87
- warn("#{label}: all subclauses must have a title, or none")
88
- end
76
+ def title_all_siblings(xpath, label)
77
+ notitle = false
78
+ withtitle = false
79
+ xpath.each do |s|
80
+ title_all_siblings(s.xpath("./clause | ./terms | ./references"),
81
+ s&.at("./title")&.text || s["id"])
82
+ subtitle = s.at("./title")
83
+ notitle = notitle || (!subtitle || subtitle.text.empty?)
84
+ withtitle = withtitle || (subtitle && !subtitle.text.empty?)
85
+ end
86
+ notitle && withtitle &&
87
+ warn("#{label}: all subclauses must have a title, or none")
88
+ end
89
89
 
90
- def title_validate(root)
91
- title_intro_validate(root)
92
- title_main_validate(root)
93
- title_part_validate(root)
94
- title_subpart_validate(root)
95
- title_names_type_validate(root)
96
- title_first_level_validate(root)
97
- title_all_siblings(root.xpath(SECTIONS_XPATH), "(top level)")
98
- end
90
+ def title_validate(root)
91
+ title_intro_validate(root)
92
+ title_main_validate(root)
93
+ title_part_validate(root)
94
+ title_subpart_validate(root)
95
+ title_names_type_validate(root)
96
+ title_first_level_validate(root)
97
+ title_all_siblings(root.xpath(SECTIONS_XPATH), "(top level)")
98
+ end
99
99
 
100
- def onlychild_clause_validate(root)
101
- root.xpath(Standoc::Utils::SUBCLAUSE_XPATH).each do |c|
102
- next unless c.xpath("../clause").size == 1
103
- title = c.at("./title")
104
- location = c["id"] || c.text[0..60] + "..."
105
- location += ":#{title.text}" if c["id"] && !title.nil?
106
- warn "ISO style: #{location}: subclause is only child"
107
- end
108
- end
100
+ def onlychild_clause_validate(root)
101
+ root.xpath(Standoc::Utils::SUBCLAUSE_XPATH).each do |c|
102
+ next unless c.xpath("../clause").size == 1
103
+ title = c.at("./title")
104
+ location = c["id"] || c.text[0..60] + "..."
105
+ location += ":#{title.text}" if c["id"] && !title.nil?
106
+ warn "ISO style: #{location}: subclause is only child"
107
+ end
108
+ end
109
109
 
110
- def isosubgroup_validate(root)
111
- root.xpath("//technical-committee/@type").each do |t|
112
- unless %w{TC PC JTC JPC}.include? t.text
113
- warn "ISO: invalid technical committee type #{t}"
110
+ def isosubgroup_validate(root)
111
+ root.xpath("//technical-committee/@type").each do |t|
112
+ unless %w{TC PC JTC JPC}.include? t.text
113
+ warn "ISO: invalid technical committee type #{t}"
114
+ end
115
+ end
116
+ root.xpath("//subcommittee/@type").each do |t|
117
+ unless %w{SC JSC}.include? t.text
118
+ warn "ISO: invalid subcommittee type #{t}"
119
+ end
120
+ end
114
121
  end
115
- end
116
- root.xpath("//subcommittee/@type").each do |t|
117
- unless %w{SC JSC}.include? t.text
118
- warn "ISO: invalid subcommittee type #{t}"
122
+
123
+ def see_xrefs_validate(root)
124
+ root.xpath("//xref").each do |t|
125
+ # does not deal with preceding text marked up
126
+ preceding = t.at("./preceding-sibling::text()[last()]")
127
+ next unless !preceding.nil? && /\bsee\s*$/mi.match(preceding)
128
+ (target = root.at("//*[@id = '#{t['target']}']")) || next
129
+ if target&.at("./ancestor-or-self::*[@obligation = 'normative']")
130
+ warn "ISO: 'see #{t['target']}' is pointing to a normative section"
131
+ end
132
+ end
119
133
  end
120
- end
121
- end
122
134
 
123
- def see_xrefs_validate(root)
124
- root.xpath("//xref").each do |t|
125
- # does not deal with preceding text marked up
126
- preceding = t.at("./preceding-sibling::text()[last()]")
127
- next unless !preceding.nil? && /\bsee\s*$/mi.match(preceding)
128
- (target = root.at("//*[@id = '#{t['target']}']")) || next
129
- if target&.at("./ancestor-or-self::*[@obligation = 'normative']")
130
- warn "ISO: 'see #{t['target']}' is pointing to a normative section"
135
+ def see_erefs_validate(root)
136
+ root.xpath("//eref").each do |t|
137
+ preceding = t.at("./preceding-sibling::text()[last()]")
138
+ next unless !preceding.nil? && /\bsee\s*$/mi.match(preceding)
139
+ target = root.at("//*[@id = '#{t['bibitemid']}']")
140
+ if target.at("./ancestor::references"\
141
+ "[title = 'Normative References']")
142
+ warn "ISO: 'see #{t}' is pointing to a normative reference"
143
+ end
144
+ end
131
145
  end
132
- end
133
- end
134
146
 
135
- def see_erefs_validate(root)
136
- root.xpath("//eref").each do |t|
137
- preceding = t.at("./preceding-sibling::text()[last()]")
138
- next unless !preceding.nil? && /\bsee\s*$/mi.match(preceding)
139
- target = root.at("//*[@id = '#{t['bibitemid']}']")
140
- if target.at("./ancestor::references"\
141
- "[title = 'Normative References']")
142
- warn "ISO: 'see #{t}' is pointing to a normative reference"
147
+ def locality_erefs_validate(root)
148
+ root.xpath("//eref[locality]").each do |t|
149
+ unless /^IEV$|:[ ]?(\d+{4}|--)$/.match t["citeas"]
150
+ warn "ISO: undated reference #{t['citeas']} should not contain "\
151
+ "specific elements"
152
+ end
153
+ end
143
154
  end
144
- end
145
- end
146
155
 
147
- def locality_erefs_validate(root)
148
- root.xpath("//eref[locality]").each do |t|
149
- unless /^IEV$|:[ ]?(\d+{4}|--)$/.match t["citeas"]
150
- warn "ISO: undated reference #{t['citeas']} should not contain "\
151
- "specific elements"
156
+ def termdef_warn(text, re, term, msg)
157
+ re.match(text) && warn("ISO style: #{term}: #{msg}")
152
158
  end
153
- end
154
- end
155
159
 
156
- def termdef_warn(text, re, term, msg)
157
- re.match(text) && warn("ISO style: #{term}: #{msg}")
158
- end
160
+ def termdef_style(xmldoc)
161
+ xmldoc.xpath("//term").each do |t|
162
+ para = t.at("./definition") || return
163
+ term = t.at("./preferred").text
164
+ termdef_warn(para.text, /^(the|a)\b/i, term,
165
+ "term definition starts with article")
166
+ termdef_warn(para.text, /\.$/i, term,
167
+ "term definition ends with period")
168
+ end
169
+ cited_term_style(xmldoc)
170
+ end
159
171
 
160
- def termdef_style(xmldoc)
161
- xmldoc.xpath("//term").each do |t|
162
- para = t.at("./definition") || return
163
- term = t.at("./preferred").text
164
- termdef_warn(para.text, /^(the|a)\b/i, term,
165
- "term definition starts with article")
166
- termdef_warn(para.text, /\.$/i, term,
167
- "term definition ends with period")
168
- end
169
- end
172
+ def cited_term_style(xmldoc)
173
+ xmldoc.xpath("//term//xref").each do |x|
174
+ next unless xmldoc.at("//term[@id = '#{x['target']}']")
175
+ x&.previous&.text == " (" and x&.previous&.previous&.name == "em" or
176
+ style_warning(x, "term citation not preceded with italicised term",
177
+ x.parent.text)
178
+ end
179
+ end
170
180
 
171
- def content_validate(doc)
172
- super
173
- title_validate(doc.root)
174
- isosubgroup_validate(doc.root)
175
- onlychild_clause_validate(doc.root)
176
- termdef_style(doc.root)
177
- iev_validate(doc.root)
178
- see_xrefs_validate(doc.root)
179
- see_erefs_validate(doc.root)
180
- locality_erefs_validate(doc.root)
181
- end
181
+ def content_validate(doc)
182
+ super
183
+ title_validate(doc.root)
184
+ isosubgroup_validate(doc.root)
185
+ onlychild_clause_validate(doc.root)
186
+ termdef_style(doc.root)
187
+ iev_validate(doc.root)
188
+ see_xrefs_validate(doc.root)
189
+ see_erefs_validate(doc.root)
190
+ locality_erefs_validate(doc.root)
191
+ end
182
192
 
183
- def validate(doc)
184
- content_validate(doc)
185
- schema_validate(formattedstr_strip(doc.dup),
186
- File.join(File.dirname(__FILE__), "isostandard.rng"))
187
- end
193
+ def validate(doc)
194
+ content_validate(doc)
195
+ schema_validate(formattedstr_strip(doc.dup),
196
+ File.join(File.dirname(__FILE__), "isostandard.rng"))
197
+ end
188
198
  end
189
199
  end
190
200
  end
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module ISO
3
- VERSION = "1.0.3".freeze
3
+ VERSION = "1.0.4".freeze
4
4
  end
5
5
  end
@@ -930,4 +930,16 @@ it "Do not warn if not more than 7 levels of subclause" do
930
930
 
931
931
  INPUT
932
932
  end
933
+
934
+ it "Warn if term citation in Terms & Definitions not preceded with italicised term" do
935
+ expect { Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true) }.to output(%r{term citation not preceded with italicised term}).to_stderr
936
+ #{VALIDATING_BLANK_HDR}
937
+ == Terms and Definitions
938
+
939
+ [[term]]
940
+ === Term
941
+
942
+ The definition of a term (<<term>>) is a part of the specialized vocabulary of a particular field
943
+ INPUT
944
+ end
933
945
  end
@@ -1,7 +1,7 @@
1
1
  MIME-Version: 1.0
2
- Content-Type: multipart/related; boundary="----=_NextPart_c65e6679.db03.4744"
2
+ Content-Type: multipart/related; boundary="----=_NextPart_64b56c80.e800.431f"
3
3
 
4
- ------=_NextPart_c65e6679.db03.4744
4
+ ------=_NextPart_64b56c80.e800.431f
5
5
  Content-Location: file:///C:/Doc/spec/assets/iso.htm
6
6
  Content-Type: text/html; charset="utf-8"
7
7
 
@@ -843,11 +843,11 @@ Switzerland<p class="MsoNormal"></p></span></p>
843
843
  <p class="MsoToc1"><span lang="EN-GB" xml:lang="EN-GB"><span style="mso-element:field-begin"></span><span style="mso-spacerun:yes">&#xA0;</span>TOC
844
844
  \o "1-2" \h \z \u <span style="mso-element:field-separator"></span></span>
845
845
  <span class="MsoHyperlink"><span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
846
- <a href="#_Toc586635060">Foreword<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
846
+ <a href="#_Toc91959334">Foreword<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
847
847
  <span style="mso-tab-count:1 dotted">. </span>
848
848
  </span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
849
849
  <span style="mso-element:field-begin"></span></span>
850
- <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"> PAGEREF _Toc586635060 \h </span>
850
+ <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"> PAGEREF _Toc91959334 \h </span>
851
851
  <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-separator"></span></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">1</span>
852
852
  <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-end"></span></span></a></span></span></p>
853
853
 
@@ -880,7 +880,7 @@ Switzerland<p class="MsoNormal"></p></span></p>
880
880
  </html>
881
881
 
882
882
 
883
- ------=_NextPart_c65e6679.db03.4744
883
+ ------=_NextPart_64b56c80.e800.431f
884
884
  Content-Location: file:///C:/Doc/spec/assets/iso_files/filelist.xml
885
885
  Content-Transfer-Encoding: base64
886
886
  Content-Type: application/xml
@@ -890,7 +890,7 @@ ICAgICAgIDxvOk1haW5GaWxlIEhSZWY9Ii4uL3NwZWMvYXNzZXRzL2lzby5odG0iLz4gIDxvOkZp
890
890
  bGUgSFJlZj0iZmlsZWxpc3QueG1sIi8+CiAgPG86RmlsZSBIUmVmPSJoZWFkZXIuaHRtbCIvPgo8
891
891
  L3htbD4K
892
892
 
893
- ------=_NextPart_c65e6679.db03.4744
893
+ ------=_NextPart_64b56c80.e800.431f
894
894
  Content-Location: file:///C:/Doc/spec/assets/iso_files/header.html
895
895
  Content-Transfer-Encoding: base64
896
896
  Content-Type: text/html charset="utf-8"
@@ -1083,4 +1083,4 @@ cD4NCg0KPHAgY2xhc3M9TXNvRm9vdGVyPjxzcGFuIGxhbmc9RU4tQVUgc3R5bGU9J2ZvbnQtc2l6
1083
1083
  ZToxMC4wcHQ7Jz7CqQ0KJm5ic3A7Jm5ic3A74oCTIEFsbCByaWdodHMgcmVzZXJ2ZWQ8bzpwPjwv
1084
1084
  bzpwPjwvc3Bhbj48L3A+DQoNCjwvZGl2Pg0KDQoNCg0KPC9ib2R5Pg0KDQo8L2h0bWw+DQo=
1085
1085
 
1086
- ------=_NextPart_c65e6679.db03.4744--
1086
+ ------=_NextPart_64b56c80.e800.431f--
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-iso
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
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-08-25 00:00:00.000000000 Z
11
+ date: 2018-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor