metanorma-iso 3.0.2 → 3.0.4

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.
@@ -92,11 +92,11 @@ module Metanorma
92
92
 
93
93
  def term_xrefs_validate1(xref, termids)
94
94
  closest_id = xref.xpath("./ancestor::*[@id]")&.last or return
95
- (termids[xref["target"]] && !termids[closest_id["id"]]) and
95
+ termids[xref["target"]] && !termids[closest_id["id"]] and
96
96
  @log.add("Style", xref,
97
97
  "only terms clauses can cross-reference terms clause " \
98
98
  "(#{xref['target']})")
99
- (!termids[xref["target"]] && termids[closest_id["id"]]) and
99
+ !termids[xref["target"]] && termids[closest_id["id"]] and
100
100
  @log.add("Style", xref,
101
101
  "non-terms clauses cannot cross-reference terms clause " \
102
102
  "(#{xref['target']})")
@@ -193,15 +193,12 @@ module Metanorma
193
193
  end
194
194
  end
195
195
 
196
- def validate(doc)
197
- content_validate(doc)
198
- schema = case @doctype
199
- when "amendment", "technical-corrigendum" # @amd
200
- "isostandard-amd.rng"
201
- else "isostandard-compile.rng"
202
- end
203
- schema_validate(formattedstr_strip(doc.dup),
204
- File.join(File.dirname(__FILE__), schema))
196
+ def schema_file
197
+ case @doctype
198
+ when "amendment", "technical-corrigendum" # @amd
199
+ "isostandard-amd.rng"
200
+ else "isostandard-compile.rng"
201
+ end
205
202
  end
206
203
  end
207
204
  end
@@ -124,12 +124,15 @@ module Metanorma
124
124
 
125
125
  def style_no_guidance(node, text, docpart)
126
126
  @lang == "en" or return
127
- r = requirement_check(text)
128
- style_warning(node, "#{docpart} may contain requirement", r) if r
129
- r = permission_check(text)
130
- style_warning(node, "#{docpart} may contain permission", r) if r
131
- r = recommendation_check(text)
132
- style_warning(node, "#{docpart} may contain recommendation", r) if r
127
+ r = requirement_check(text) and
128
+ style_warning(node, "#{docpart} may contain requirement", r,
129
+ display: false)
130
+ r = permission_check(text) and
131
+ style_warning(node, "#{docpart} may contain permission", r,
132
+ display: false)
133
+ r = recommendation_check(text) and
134
+ style_warning(node, "#{docpart} may contain recommendation", r,
135
+ display: false)
133
136
  end
134
137
  end
135
138
  end
@@ -30,15 +30,17 @@ module Metanorma
30
30
  # ISO/IEC DIR 2, 13.2
31
31
  def introduction_style(node)
32
32
  @novalid and return
33
- r = requirement_check(extract_text(node))
34
- style_warning(node, "Introduction may contain requirement", r) if r
33
+ r = requirement_check(extract_text(node)) and
34
+ style_warning(node, "Introduction may contain requirement", r,
35
+ display: false)
35
36
  end
36
37
 
37
38
  # ISO/IEC DIR 2, 16.5.6
38
39
  def definition_style(node)
39
40
  @novalid and return
40
- r = requirement_check(extract_text(node))
41
- style_warning(node, "Definition may contain requirement", r) if r
41
+ r = requirement_check(extract_text(node)) and
42
+ style_warning(node, "Definition may contain requirement", r,
43
+ display: false)
42
44
  end
43
45
 
44
46
  # ISO/IEC DIR 2, 16.5.7
@@ -70,8 +72,7 @@ module Metanorma
70
72
  # style check with a regex on a token
71
73
  # and a negative match on its preceding token
72
74
  def style_two_regex_not_prev(n, text, regex, re_prev, warning)
73
- return if text.nil?
74
-
75
+ text.nil? and return
75
76
  arr = Tokenizer::WhitespaceTokenizer.new.tokenize(text)
76
77
  arr.each_index do |i|
77
78
  m = regex.match arr[i]
@@ -108,7 +109,8 @@ module Metanorma
108
109
  # https://www.iso.org/ISO-house-style.html#iso-hs-s-text-r-s-might
109
110
  def style_ambig_words(node, text)
110
111
  r = ambig_words_check(text) and
111
- style_warning(node, "may contain ambiguous provision", r)
112
+ style_warning(node, "may contain ambiguous provision", r,
113
+ display: false)
112
114
  @lang == "en" and style_regex(/\b(?<num>billions?)\b/i,
113
115
  "ambiguous number", node, text)
114
116
  end
@@ -208,12 +210,11 @@ module Metanorma
208
210
  end
209
211
  end
210
212
 
211
- def style_warning(node, msg, text = nil)
212
- return if @novalid
213
-
213
+ def style_warning(node, msg, text = nil, display: true)
214
+ @novalid and return
214
215
  w = msg
215
216
  w += ": #{text}" if text
216
- @log.add("Style", node, w)
217
+ @log.add("Style", node, w, display:)
217
218
  end
218
219
 
219
220
  ASSETS_TO_STYLE =
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Iso
3
- VERSION = "3.0.2".freeze
3
+ VERSION = "3.0.4".freeze
4
4
  end
5
5
  end
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: 3.0.2
4
+ version: 3.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: 2025-03-17 00:00:00.000000000 Z
11
+ date: 2025-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc
@@ -352,6 +352,7 @@ files:
352
352
  - lib/isodoc/iso/metadata.rb
353
353
  - lib/isodoc/iso/pdf_convert.rb
354
354
  - lib/isodoc/iso/presentation_bibdata.rb
355
+ - lib/isodoc/iso/presentation_section.rb
355
356
  - lib/isodoc/iso/presentation_terms.rb
356
357
  - lib/isodoc/iso/presentation_xml_convert.rb
357
358
  - lib/isodoc/iso/presentation_xref.rb