metanorma-iso 1.9.2 → 1.9.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@ require "isodoc"
2
2
 
3
3
  module IsoDoc
4
4
  module Iso
5
- class Metadata < IsoDoc::Metadata
5
+ class Metadata < IsoDoc::Metadata
6
6
  def initialize(lang, script, i18n)
7
7
  super
8
8
  set(:tc, "XXXX")
@@ -14,17 +14,17 @@ module IsoDoc
14
14
  set(:obsoletes_part, nil)
15
15
  end
16
16
 
17
- def status_abbrev(stage, substage, iter, draft, doctype)
17
+ def status_abbrev(stage, _substage, iter, draft, doctype)
18
18
  return "" unless stage
19
19
 
20
20
  if %w(technical-report technical-specification).include?(doctype)
21
21
  stage = "DTS" if stage == "DIS"
22
22
  stage = "FDTS" if stage == "FDIS"
23
23
  end
24
- if %w(PWI NWIP WD CD).include?(stage)
25
- stage += iter if iter
24
+ if %w(PWI NWIP WD CD).include?(stage) && iter
25
+ stage += iter
26
26
  end
27
- stage = "Pre" + stage if draft =~ /^0\./
27
+ stage = "Pre#{stage}" if /^0\./.match?(draft)
28
28
  stage
29
29
  end
30
30
 
@@ -48,14 +48,14 @@ module IsoDoc
48
48
  end
49
49
 
50
50
  def unpublished(status)
51
- status.to_i > 0 && status.to_i < 60
51
+ status.to_i.positive? && status.to_i < 60
52
52
  end
53
53
 
54
54
  def docid(isoxml, _out)
55
55
  dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'ISO']"))
56
56
  set(:docnumber, dn&.text)
57
57
  tcdn = isoxml.xpath(ns("//bibdata/docidentifier[@type = 'iso-tc']"))
58
- set(:tc_docnumber, tcdn.map { |n| n.text })
58
+ set(:tc_docnumber, tcdn.map(&:text))
59
59
  dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'iso-with-lang']"))
60
60
  set(:docnumber_lang, dn&.text)
61
61
  dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'iso-reference']"))
@@ -87,6 +87,7 @@ module IsoDoc
87
87
 
88
88
  def part_title(part, partnum, subpartnum, lang)
89
89
  return "" unless part
90
+
90
91
  suffix = @c.encode(part.text, :hexadecimal)
91
92
  partnum = "#{partnum}&ndash;#{subpartnum}" if partnum && subpartnum
92
93
  suffix = "#{part_label(lang)}&nbsp;#{partnum}: " + suffix if partnum
@@ -125,10 +126,14 @@ module IsoDoc
125
126
  end
126
127
 
127
128
  def title_parts(isoxml, lang)
128
- [isoxml.at(ns("//bibdata//title[@type='title-intro' and @language='#{lang}']")),
129
- isoxml.at(ns("//bibdata//title[@type='title-main' and @language='#{lang}']")),
130
- isoxml.at(ns("//bibdata//title[@type='title-part' and @language='#{lang}']")),
131
- isoxml.at(ns("//bibdata//title[@type='title-amd' and @language='#{lang}']"))]
129
+ [isoxml.at(ns("//bibdata//title[@type='title-intro' and "\
130
+ "@language='#{lang}']")),
131
+ isoxml.at(ns("//bibdata//title[@type='title-main' and "\
132
+ "@language='#{lang}']")),
133
+ isoxml.at(ns("//bibdata//title[@type='title-part' and "\
134
+ "@language='#{lang}']")),
135
+ isoxml.at(ns("//bibdata//title[@type='title-amd' and "\
136
+ "@language='#{lang}']"))]
132
137
  end
133
138
 
134
139
  def title(isoxml, _out)
@@ -139,7 +144,10 @@ module IsoDoc
139
144
  set(:doctitlemain, @c.encode(main ? main.text : "", :hexadecimal))
140
145
  main = compose_title(main, intro, part, partnumber, subpartnumber, lang)
141
146
  set(:doctitle, main)
142
- set(:doctitleintro, @c.encode(intro ? intro.text : "", :hexadecimal)) if intro
147
+ if intro
148
+ set(:doctitleintro,
149
+ @c.encode(intro ? intro.text : "", :hexadecimal))
150
+ end
143
151
  set(:doctitlepartlabel, part_prefix(partnumber, subpartnumber, lang))
144
152
  set(:doctitlepart, @c.encode(part.text, :hexadecimal)) if part
145
153
  set(:doctitleamdlabel, amd_prefix(amdnumber, lang)) if amdnumber
@@ -155,7 +163,10 @@ module IsoDoc
155
163
  set(:docsubtitlemain, @c.encode(main ? main.text : "", :hexadecimal))
156
164
  main = compose_title(main, intro, part, partnumber, subpartnumber, lang)
157
165
  set(:docsubtitle, main)
158
- set(:docsubtitleintro, @c.encode(intro ? intro.text : "", :hexadecimal)) if intro
166
+ if intro
167
+ set(:docsubtitleintro,
168
+ @c.encode(intro ? intro.text : "", :hexadecimal))
169
+ end
159
170
  set(:docsubtitlepartlabel, part_prefix(partnumber, subpartnumber, lang))
160
171
  set(:docsubtitlepart, @c.encode(part.text, :hexadecimal)) if part
161
172
  set(:docsubtitleamdlabel, amd_prefix(amdnumber, lang)) if amdnumber
@@ -173,8 +184,8 @@ module IsoDoc
173
184
 
174
185
  def tc(xml)
175
186
  tc_num = xml.at(ns("//bibdata/ext/editorialgroup/technical-committee/@number"))
176
- tc_type = xml.at(ns("//bibdata/ext/editorialgroup/technical-committee/@type"))&.
177
- text || "TC"
187
+ tc_type = xml.at(ns("//bibdata/ext/editorialgroup/technical-committee/@type"))
188
+ &.text || "TC"
178
189
  if tc_num
179
190
  tcid = "#{tc_type} #{tc_num.text}"
180
191
  set(:tc, tcid)
@@ -212,7 +223,8 @@ module IsoDoc
212
223
  ics = []
213
224
  isoxml.xpath(ns("//bibdata/ext/ics/code")).each { |i| ics << i.text }
214
225
  set(:ics, ics.empty? ? nil : ics.join(", "))
215
- a = isoxml.at(ns("//bibdata/ext/horizontal")) and set(:horizontal, a.text)
226
+ a = isoxml.at(ns("//bibdata/ext/horizontal")) and set(:horizontal,
227
+ a.text)
216
228
  end
217
229
  end
218
230
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "1.9.2".freeze
3
+ VERSION = "1.9.3".freeze
4
4
  end
5
5
  end
@@ -212,6 +212,8 @@ RSpec.describe Asciidoctor::ISO do
212
212
  :pub-fax: 4444444
213
213
  :pub-email: x@example.com
214
214
  :pub-uri: http://www.example.com
215
+ :docstage:
216
+ :docsubstage:
215
217
  INPUT
216
218
  expect(xmlpp(output.sub(%r{<boilerplate>.*</boilerplate>}m, "")))
217
219
  .to be_equivalent_to xmlpp(<<~"OUTPUT")
@@ -304,7 +306,6 @@ RSpec.describe Asciidoctor::ISO do
304
306
  <phone type='fax'>4444444</phone>
305
307
  <email>x@example.com</email>
306
308
  <uri>http://www.example.com</uri>
307
- #{' '}
308
309
  </organization>
309
310
  </owner>
310
311
  </copyright>
@@ -586,4 +586,43 @@ RSpec.describe Asciidoctor::ISO do
586
586
  expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
587
587
  .to be_equivalent_to xmlpp(output)
588
588
  end
589
+
590
+ it "processes nested terms" do
591
+ input = <<~INPUT
592
+ #{ASCIIDOC_BLANK_HDR}
593
+ == Terms and Definitions
594
+
595
+ [.term]
596
+ === Term1
597
+
598
+ definition
599
+
600
+ ==== Term11
601
+ definition2
602
+ INPUT
603
+ output = <<~OUTPUT
604
+ #{BLANK_HDR}
605
+ <sections>
606
+ <terms id='_' obligation='normative'>
607
+ <title>Terms and definitions</title>
608
+ #{TERM_BOILERPLATE}
609
+ <term id='term-term1'>
610
+ <preferred>Term1</preferred>
611
+ <definition>
612
+ <p id='_'>definition</p>
613
+ </definition>
614
+ <term id='term-term11'>
615
+ <preferred>Term11</preferred>
616
+ <definition>
617
+ <p id='_'>definition2</p>
618
+ </definition>
619
+ </term>
620
+ </term>
621
+ </terms>
622
+ </sections>
623
+ </iso-standard>
624
+ OUTPUT
625
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
626
+ .to be_equivalent_to xmlpp(output)
627
+ end
589
628
  end
@@ -26,7 +26,7 @@ RSpec.describe Asciidoctor::ISO do
26
26
  <title>Clause</title>
27
27
  <p id="_">
28
28
  <eref bibitemid="iso123" citeas="ISO 123:--" type="inline"/>
29
- <fn reference="1">The standard is in press</fn>
29
+ <fn reference="1"><p id="_">The standard is in press</p></fn>
30
30
  <eref bibitemid="iso123" citeas="ISO 123:--" type="inline"/>A.
31
31
  <fn reference="2">
32
32
  <p id="_">a footnote</p></fn>
@@ -52,6 +52,14 @@ RSpec.describe IsoDoc do
52
52
  <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality></origin>
53
53
  </termsource>
54
54
  </term>
55
+ <term id="A">
56
+ <preferred>term1</preferred>
57
+ <definition>term1 definition</definition>
58
+ <term id="B">
59
+ <preferred>term2</preferred>
60
+ <definition>term2 definition</definition>
61
+ </term>
62
+ </term>
55
63
  </terms>
56
64
  </sections>
57
65
  </iso-standard>
@@ -119,6 +127,16 @@ RSpec.describe IsoDoc do
119
127
  <origin bibitemid='ISO7301' type='inline' citeas='ISO 7301:2011'><locality type='clause'><referenceFrom>3.1</referenceFrom></locality>ISO 7301:2011, 3.1</origin>
120
128
  </termsource>
121
129
  </term>
130
+ <term id='A'>
131
+ <name>1.3</name>
132
+ <preferred>term1</preferred>
133
+ <definition>term1 definition</definition>
134
+ <term id='B'>
135
+ <name>1.3.1</name>
136
+ <preferred>term2</preferred>
137
+ <definition>term2 definition</definition>
138
+ </term>
139
+ </term>
122
140
  </terms>
123
141
  </sections>
124
142
  </iso-standard>
@@ -175,6 +193,12 @@ RSpec.describe IsoDoc do
175
193
  </div>
176
194
  <p>[TERMREF]<a href="#ISO7301">ISO 7301:2011, 3.1</a>
177
195
  [/TERMREF]</p>
196
+ <p class='TermNum' id='A'>1.3</p>
197
+ <p class='Terms' style='text-align:left;'>term1</p>
198
+ term1 definition
199
+ <p class='TermNum' id='B'>1.3.1</p>
200
+ <p class='Terms' style='text-align:left;'>term2</p>
201
+ term2 definition
178
202
  </div>
179
203
  </div>
180
204
  </body>
@@ -212,6 +236,12 @@ RSpec.describe IsoDoc do
212
236
  <div id='_671a1994-4783-40d0-bc81-987d06ffb74f' class="Note"><p class="Note">Note 2 to entry: <ul><li>A</li></ul><p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p></p></div>
213
237
  <p class="Source">[TERMREF]<a href="#ISO7301">ISO 7301:2011, 3.1</a>
214
238
  [/TERMREF]</p>
239
+ <p class='TermNum' id='A'>1.3</p>
240
+ <p class='Terms' style='text-align:left;'>term1</p>
241
+ term1 definition
242
+ <p class='TermNum' id='B'>1.3.1</p>
243
+ <p class='Terms' style='text-align:left;'>term2</p>
244
+ term2 definition
215
245
  </div>
216
246
  OUTPUT
217
247
  expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({})
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.9.2
4
+ version: 1.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-16 00:00:00.000000000 Z
11
+ date: 2021-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: isodoc