metanorma-iso 2.4.0 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -84,15 +84,15 @@ module IsoDoc
84
84
  p = titlenums[:part]
85
85
  titlenums[:part] && titlenums[:subpart] and
86
86
  p = "#{titlenums[:part]}–#{titlenums[:subpart]}"
87
- "#{PART_LABEL[lang.to_sym]} #{p}"
87
+ "#{self.class::PART_LABEL[lang.to_sym]} #{p}"
88
88
  end
89
89
 
90
90
  def amd_prefix(titlenums, lang)
91
- "#{AMD_LABEL[lang.to_sym]} #{titlenums[:amd]}"
91
+ "#{self.class::AMD_LABEL[lang.to_sym]} #{titlenums[:amd]}"
92
92
  end
93
93
 
94
94
  def corr_prefix(titlenums, lang)
95
- "#{CORR_LABEL[lang.to_sym]} #{titlenums[:corr]}"
95
+ "#{self.class::CORR_LABEL[lang.to_sym]} #{titlenums[:corr]}"
96
96
  end
97
97
 
98
98
  def compose_title(tparts, tnums, lang)
@@ -23,6 +23,7 @@ module IsoDoc
23
23
  sourcecode docxml
24
24
  formula docxml
25
25
  admonition docxml
26
+ source docxml
26
27
  ol docxml
27
28
  permission docxml
28
29
  requirement docxml
@@ -86,7 +86,7 @@ module IsoDoc
86
86
  }.freeze
87
87
 
88
88
  def new_styles(docxml)
89
- STYLESMAP.each do |k, v|
89
+ self.class::STYLESMAP.each do |k, v|
90
90
  docxml.xpath("//*[@class = '#{k}']").each { |s| s["class"] = v }
91
91
  end
92
92
  docxml.xpath("//div[@class = 'Section3']//p[@class = 'Tabletitle']")
@@ -231,14 +231,19 @@ module IsoDoc
231
231
  out.div align: "center", class: "table_container" do |div|
232
232
  div.table **table_attrs(node) do |t|
233
233
  table_parse_core(node, t)
234
- (dl = node.at(ns("./dl"))) && parse(dl, div)
235
- node.xpath(ns("./note[not(@type = 'units')]"))
236
- .each { |n| parse(n, div) }
234
+ table_parse_tail(node, t)
237
235
  end
238
236
  end
239
237
  @in_table = false
240
238
  end
241
239
 
240
+ def table_parse_tail(node, out)
241
+ (dl = node.at(ns("./dl"))) && parse(dl, out)
242
+ node.xpath(ns("./source")).each { |n| parse(n, out) }
243
+ node.xpath(ns("./note[not(@type = 'units')]"))
244
+ .each { |n| parse(n, out) }
245
+ end
246
+
242
247
  include BaseConvert
243
248
  include Init
244
249
  end
@@ -382,6 +382,9 @@
382
382
  <optional>
383
383
  <ref name="dl"/>
384
384
  </optional>
385
+ <optional>
386
+ <ref name="source"/>
387
+ </optional>
385
388
  </element>
386
389
  </define>
387
390
  <define name="figure">
@@ -404,9 +407,6 @@
404
407
  <attribute name="class"/>
405
408
  </optional>
406
409
  <ref name="BlockAttributes"/>
407
- <optional>
408
- <ref name="source"/>
409
- </optional>
410
410
  <optional>
411
411
  <ref name="tname"/>
412
412
  </optional>
@@ -431,6 +431,20 @@
431
431
  <zeroOrMore>
432
432
  <ref name="note"/>
433
433
  </zeroOrMore>
434
+ <optional>
435
+ <ref name="source"/>
436
+ </optional>
437
+ </element>
438
+ </define>
439
+ <define name="source">
440
+ <element name="source">
441
+ <attribute name="status">
442
+ <ref name="SourceStatusType"/>
443
+ </attribute>
444
+ <ref name="origin"/>
445
+ <optional>
446
+ <ref name="modification"/>
447
+ </optional>
434
448
  </element>
435
449
  </define>
436
450
  <define name="sourcecode">
@@ -2099,10 +2113,7 @@
2099
2113
  <define name="termsource">
2100
2114
  <element name="termsource">
2101
2115
  <attribute name="status">
2102
- <choice>
2103
- <value>identical</value>
2104
- <value>modified</value>
2105
- </choice>
2116
+ <ref name="SourceStatusType"/>
2106
2117
  </attribute>
2107
2118
  <attribute name="type">
2108
2119
  <choice>
@@ -2116,6 +2127,17 @@
2116
2127
  </optional>
2117
2128
  </element>
2118
2129
  </define>
2130
+ <define name="SourceStatusType">
2131
+ <choice>
2132
+ <value>identical</value>
2133
+ <value>modified</value>
2134
+ <value>restyled</value>
2135
+ <value>context-added</value>
2136
+ <value>generalisation</value>
2137
+ <value>specialisation</value>
2138
+ <value>unspecified</value>
2139
+ </choice>
2140
+ </define>
2119
2141
  <define name="origin">
2120
2142
  <element name="origin">
2121
2143
  <choice>
@@ -106,10 +106,11 @@ module Metanorma
106
106
  xmldoc.xpath("//term").each do |t|
107
107
  para = t.at("./definition/verbal-definition") || return
108
108
  term = t.at("./preferred//name").text
109
- termdef_warn(para.text, /\A(the|a)\b/i, t, term,
110
- "term definition starts with article")
111
- termdef_warn(para.text, /\.\Z/i, t, term,
112
- "term definition ends with period")
109
+ @lang == "en" and termdef_warn(para.text, /\A(the|a)\b/i, t, term,
110
+ "term definition starts with article")
111
+ %(Cyrl Latn).include?(@script) and
112
+ termdef_warn(para.text, /\.\Z/i, t, term,
113
+ "term definition ends with period")
113
114
  end
114
115
  end
115
116
 
@@ -56,7 +56,8 @@ module Metanorma
56
56
  def list_punctuation1(list, prectext)
57
57
  prectext ||= ""
58
58
  entries = list.xpath(".//li")
59
- case prectext.strip.chars.last
59
+ %w(Cyrl Latn Grek).include?(@script) or return
60
+ case prectext.strip[-1]
60
61
  when ":", "" then list_after_colon_punctuation(list, entries)
61
62
  when "." then entries.each { |li| list_full_sentence(li) }
62
63
  else style_warning(list, "All lists must be preceded by "\
@@ -98,6 +99,7 @@ module Metanorma
98
99
  end
99
100
 
100
101
  def list_full_sentence(elem)
102
+ %w(Cyrl Latn Grek).include?(@script) or return
101
103
  text = elem.text.strip
102
104
  starts_uppercase?(text) or
103
105
  style_warning(elem, "List entry of separate sentences must start "\
@@ -99,6 +99,7 @@ module Metanorma
99
99
  end
100
100
 
101
101
  def style_no_guidance(node, text, docpart)
102
+ @lang == "en" or return
102
103
  r = requirement_check(text)
103
104
  style_warning(node, "#{docpart} may contain requirement", r) if r
104
105
  r = permission_check(text)
@@ -32,9 +32,9 @@ module Metanorma
32
32
  @log.add("Style", f, "normative references contains subclauses")
33
33
  end
34
34
 
35
- ONE_SYMBOLS_WARNING = "Only one Symbols and Abbreviated "\
35
+ ONE_SYMBOLS_WARNING = "Only one Symbols and Abbreviated " \
36
36
  "Terms section in the standard".freeze
37
- NON_DL_SYMBOLS_WARNING = "Symbols and Abbreviated Terms can "\
37
+ NON_DL_SYMBOLS_WARNING = "Symbols and Abbreviated Terms can " \
38
38
  "only contain a definition list".freeze
39
39
 
40
40
  def symbols_validate(root)
@@ -46,7 +46,7 @@ module Metanorma
46
46
  @log.add("Style", f.first, NON_DL_SYMBOLS_WARNING)
47
47
  @vocab and f.each do |f1|
48
48
  f1.at("./ancestor::annex") or
49
- @log.add("Style", f1, "In vocabulary documents, Symbols and "\
49
+ @log.add("Style", f1, "In vocabulary documents, Symbols and " \
50
50
  "Abbreviated Terms are only permitted in annexes")
51
51
  end
52
52
  end
@@ -80,15 +80,15 @@ module Metanorma
80
80
  val: ["./self::introduction", "./self::clause[@type = 'scope']"] },
81
81
  { msg: "Prefatory material must be followed by (clause) Scope",
82
82
  val: ["./self::clause[@type = 'scope']"] },
83
- { msg: "Normative References must be followed by "\
83
+ { msg: "Normative References must be followed by " \
84
84
  "Terms and Definitions",
85
85
  val: ["./self::terms | .//terms"] },
86
86
  ].freeze
87
87
 
88
88
  SECTIONS_XPATH =
89
- "//foreword | //introduction | //sections/terms | .//annex | "\
90
- "//sections/definitions | //sections/clause | "\
91
- "//references[not(parent::clause)] | "\
89
+ "//foreword | //introduction | //sections/terms | .//annex | " \
90
+ "//sections/definitions | //sections/clause | " \
91
+ "//references[not(parent::clause)] | " \
92
92
  "//clause[descendant::references][not(parent::clause)]".freeze
93
93
 
94
94
  def sections_sequence_validate(root)
@@ -119,7 +119,7 @@ module Metanorma
119
119
  @log.add("Style", elem, "Document must contain at least one clause")
120
120
  end
121
121
  elem&.at("./self::clause") ||
122
- @log.add("Style", elem, "Document must contain clause after "\
122
+ @log.add("Style", elem, "Document must contain clause after " \
123
123
  "Terms and Definitions")
124
124
  elem&.at("./self::clause[@type = 'scope']") &&
125
125
  @log.add("Style", elem,
@@ -151,12 +151,12 @@ module Metanorma
151
151
  while elem&.name == "annex"
152
152
  elem = names.shift
153
153
  if elem.nil?
154
- @log.add("Style", nil, "Document must include (references) "\
154
+ @log.add("Style", nil, "Document must include (references) " \
155
155
  "Normative References")
156
156
  end
157
157
  end
158
158
  elem&.at("./self::references[@normative = 'true']") ||
159
- @log.add("Style", nil, "Document must include (references) "\
159
+ @log.add("Style", nil, "Document must include (references) " \
160
160
  "Normative References")
161
161
  elem = names&.shift
162
162
  elem&.at("./self::references[@normative = 'false']") ||
@@ -227,13 +227,13 @@ module Metanorma
227
227
  if terms.size == 1
228
228
  ((t = terms.first.at("./title")) && (t&.text == @i18n.termsdef)) or
229
229
  @log.add("Style", terms.first,
230
- "Single terms clause in vocabulary document "\
230
+ "Single terms clause in vocabulary document " \
231
231
  "should have normal Terms and definitions heading")
232
232
  elsif terms.size > 1
233
233
  terms.each do |x|
234
234
  ((t = x.at("./title")) && /^#{@i18n.termsrelated}/.match?(t&.text)) or
235
235
  @log.add("Style", x,
236
- "Multiple terms clauses in vocabulary document "\
236
+ "Multiple terms clauses in vocabulary document " \
237
237
  "should have 'Terms related to' heading")
238
238
  end
239
239
  end
@@ -110,8 +110,8 @@ module Metanorma
110
110
  )
111
111
  style_regex(/\b(?<num>[0-9]+\.[0-9]+)/i,
112
112
  "possible decimal point", node, text)
113
- style_regex(/\b(?<num>billions?)\b/i,
114
- "ambiguous number", node, text)
113
+ @lang == "en" and style_regex(/\b(?<num>billions?)\b/i,
114
+ "ambiguous number", node, text)
115
115
  style_regex(/(^|\s)(?<num>-[0-9][0-9,.]*)/i,
116
116
  "hyphen instead of minus sign U+2212", node, text)
117
117
  end
@@ -135,8 +135,8 @@ module Metanorma
135
135
  end
136
136
 
137
137
  # leaving out as problematic: N J K C S T H h d B o E
138
- SI_UNIT = "(m|cm|mm|km|μm|nm|g|kg|mgmol|cd|rad|sr|Hz|Hz|MHz|Pa|hPa|kJ|"\
139
- "V|kV|W|MW|kW|F|μF|Ω|Wb|°C|lm|lx|Bq|Gy|Sv|kat|l|t|eV|u|Np|Bd|"\
138
+ SI_UNIT = "(m|cm|mm|km|μm|nm|g|kg|mgmol|cd|rad|sr|Hz|Hz|MHz|Pa|hPa|kJ|" \
139
+ "V|kV|W|MW|kW|F|μF|Ω|Wb|°C|lm|lx|Bq|Gy|Sv|kat|l|t|eV|u|Np|Bd|" \
140
140
  "bit|kB|MB|Hart|nat|Sh|var)".freeze
141
141
 
142
142
  # ISO/IEC DIR 2, 9.3
@@ -165,8 +165,8 @@ module Metanorma
165
165
  # https://www.iso.org/ISO-house-style.html#iso-hs-s-text-r-p-and
166
166
  # https://www.iso.org/ISO-house-style.html#iso-hs-s-text-r-p-andor
167
167
  def style_punct(node, text)
168
- style_regex(/\b(?<num>and\/?or)\b/i,
169
- "Use 'either x or y, or both'", node, text)
168
+ @lang == "en" and style_regex(/\b(?<num>and\/?or)\b/i,
169
+ "Use 'either x or y, or both'", node, text)
170
170
  style_regex(/\s(?<num>&)\s/i,
171
171
  "Avoid ampersand in ordinary text'", node, text)
172
172
  end
@@ -180,8 +180,8 @@ module Metanorma
180
180
  end
181
181
 
182
182
  ASSETS_TO_STYLE =
183
- "//termsource | //formula | //termnote | "\
184
- "//p[not(ancestor::boilerplate)] | //li[not(p)] | //dt | "\
183
+ "//termsource | //formula | //termnote | " \
184
+ "//p[not(ancestor::boilerplate)] | //li[not(p)] | //dt | " \
185
185
  "//dd[not(p)] | //td[not(p)] | //th[not(p)]".freeze
186
186
 
187
187
  def asset_style(root)
@@ -42,8 +42,8 @@ module Metanorma
42
42
  def title_subpart_validate(root)
43
43
  docid = root.at("//bibdata/docidentifier[@type = 'ISO']")
44
44
  subpart = /-\d+-\d+/.match docid
45
- iec = root.at("//bibdata/contributor[role/@type = 'publisher']/"\
46
- "organization[abbreviation = 'IEC' or "\
45
+ iec = root.at("//bibdata/contributor[role/@type = 'publisher']/" \
46
+ "organization[abbreviation = 'IEC' or " \
47
47
  "name = 'International Electrotechnical Commission']")
48
48
  subpart && !iec and
49
49
  @log.add("Style", docid, "Subpart defined on non-IEC document!")
@@ -51,6 +51,7 @@ module Metanorma
51
51
 
52
52
  # ISO/IEC DIR 2, 11.5.2
53
53
  def title_names_type_validate(root)
54
+ @lang == "en" or return
54
55
  doctypes = /International\sStandard | Technical\sSpecification |
55
56
  Publicly\sAvailable\sSpecification | Technical\sReport | Guide /xi
56
57
  title_main_en = title_lang_part(root, "main", "en")
@@ -93,8 +94,8 @@ module Metanorma
93
94
 
94
95
  # https://www.iso.org/ISO-house-style.html#iso-hs-s-text-r-p-full
95
96
  def title_no_full_stop_validate(root)
96
- root.xpath("//preface//title | //sections//title | //annex//title | "\
97
- "//references/title | //preface//name | //sections//name | "\
97
+ root.xpath("//preface//title | //sections//title | //annex//title | " \
98
+ "//references/title | //preface//name | //sections//name | " \
98
99
  "//annex//name").each do |t|
99
100
  style_regex(/\A(?<num>.+\.\Z)/i,
100
101
  "No full stop at end of title or caption",
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "2.4.0".freeze
3
+ VERSION = "2.4.2".freeze
4
4
  end
5
5
  end
@@ -32,9 +32,9 @@ Gem::Specification.new do |spec|
32
32
  spec.test_files = `git ls-files -- {spec}/*`.split("\n")
33
33
  spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
34
34
 
35
- spec.add_dependency "metanorma-standoc", "~> 2.4.0"
35
+ spec.add_dependency "metanorma-standoc", "~> 2.4.2"
36
36
  spec.add_dependency "mnconvert", "~> 1.14"
37
- spec.add_dependency "pubid-iso", "~> 0.4.0"
37
+ spec.add_dependency "pubid-iso", "~> 0.5.0"
38
38
  spec.add_dependency "ruby-jing"
39
39
  spec.add_dependency "tokenizer", "~> 0.3.0"
40
40
  spec.add_dependency "twitter_cldr"
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: 2.4.0
4
+ version: 2.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-13 00:00:00.000000000 Z
11
+ date: 2023-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.4.0
19
+ version: 2.4.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.4.0
26
+ version: 2.4.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mnconvert
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.4.0
47
+ version: 0.5.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.4.0
54
+ version: 0.5.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: ruby-jing
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -340,6 +340,7 @@ files:
340
340
  - lib/isodoc/iso/html_convert.rb
341
341
  - lib/isodoc/iso/i18n-en.yaml
342
342
  - lib/isodoc/iso/i18n-fr.yaml
343
+ - lib/isodoc/iso/i18n-ja.yaml
343
344
  - lib/isodoc/iso/i18n-ru.yaml
344
345
  - lib/isodoc/iso/i18n-zh-Hans.yaml
345
346
  - lib/isodoc/iso/i18n.rb