metanorma-iso 2.3.6 → 2.4.1

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.
@@ -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.3.6".freeze
3
+ VERSION = "2.4.1".freeze
4
4
  end
5
5
  end
@@ -32,7 +32,7 @@ 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.3.0"
35
+ spec.add_dependency "metanorma-standoc", "~> 2.4.0"
36
36
  spec.add_dependency "mnconvert", "~> 1.14"
37
37
  spec.add_dependency "pubid-iso", "~> 0.4.0"
38
38
  spec.add_dependency "ruby-jing"
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.3.6
4
+ version: 2.4.1
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-02-27 00:00:00.000000000 Z
11
+ date: 2023-03-27 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.3.0
19
+ version: 2.4.0
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.3.0
26
+ version: 2.4.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mnconvert
29
29
  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