metanorma-iso 3.0.3 → 3.0.5

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.
@@ -4,7 +4,9 @@ require "uri" if /^2\./.match?(RUBY_VERSION)
4
4
  module Metanorma
5
5
  module Iso
6
6
  class Converter < Standoc::Converter
7
- def clause_parse(attrs, xml, node)
7
+
8
+ # KILL
9
+ def clause_parsex(attrs, xml, node)
8
10
  node.option? "appendix" and return appendix_parse(attrs, xml, node)
9
11
  super
10
12
  end
@@ -14,7 +16,8 @@ module Metanorma
14
16
  clause_parse(attrs, xml, node)
15
17
  end
16
18
 
17
- def appendix_parse(attrs, xml, node)
19
+ # KILL
20
+ def appendix_parsex(attrs, xml, node)
18
21
  attrs[:"inline-header"] = node.option? "inline-header"
19
22
  set_obligation(attrs, node)
20
23
  xml.appendix **attr_code(attrs) do |xml_section|
@@ -23,6 +26,10 @@ module Metanorma
23
26
  end
24
27
  end
25
28
 
29
+ def support_appendix?(_node)
30
+ true
31
+ end
32
+
26
33
  def patent_notice_parse(xml, node)
27
34
  # xml.patent_notice do |xml_section|
28
35
  # xml_section << node.content
@@ -14,16 +14,14 @@ module Metanorma
14
14
  class Converter < Standoc::Converter
15
15
  def isosubgroup_validate(root)
16
16
  root.xpath("//technical-committee/@type").each do |t|
17
- unless %w{TC PC JTC JPC}.include? t.text
17
+ %w{TC PC JTC JPC}.include?(t.text) or
18
18
  @log.add("Document Attributes", nil,
19
19
  "invalid technical committee type #{t}")
20
- end
21
20
  end
22
21
  root.xpath("//subcommittee/@type").each do |t|
23
- unless %w{SC JSC}.include? t.text
22
+ %w{SC JSC}.include?(t.text) or
24
23
  @log.add("Document Attributes", nil,
25
24
  "invalid subcommittee type #{t}")
26
- end
27
25
  end
28
26
  end
29
27
 
@@ -193,15 +191,12 @@ module Metanorma
193
191
  end
194
192
  end
195
193
 
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))
194
+ def schema_file
195
+ case @doctype
196
+ when "amendment", "technical-corrigendum" # @amd
197
+ "isostandard-amd.rng"
198
+ else "isostandard-compile.rng"
199
+ end
205
200
  end
206
201
  end
207
202
  end
@@ -61,7 +61,7 @@ module Metanorma
61
61
  when ":", "" then list_after_colon_punctuation(list, entries)
62
62
  when "." then entries.each { |li| list_full_sentence(li) }
63
63
  else style_warning(list, "All lists must be preceded by " \
64
- "colon or full stop", prectext)
64
+ "colon or full stop", prectext, display: false)
65
65
  end
66
66
  end
67
67
 
@@ -81,7 +81,7 @@ module Metanorma
81
81
  text = elem.text.strip
82
82
  starts_lowercase?(text) or
83
83
  style_warning(elem, "List entry of broken up sentence must start " \
84
- "with lowercase letter", text)
84
+ "with lowercase letter", text, display: false)
85
85
  list_semicolon_phrase_punct(elem, text, last)
86
86
  end
87
87
 
@@ -90,11 +90,12 @@ module Metanorma
90
90
  if last
91
91
  punct == "." or
92
92
  style_warning(elem, "Final list entry of broken up " \
93
- "sentence must end with full stop", text)
93
+ "sentence must end with full stop", text,
94
+ display: false)
94
95
  else
95
96
  punct == ";" or
96
97
  style_warning(elem, "List entry of broken up sentence must " \
97
- "end with semicolon", text)
98
+ "end with semicolon", text, display: false)
98
99
  end
99
100
  end
100
101
 
@@ -103,11 +104,11 @@ module Metanorma
103
104
  text = elem.text.strip
104
105
  starts_uppercase?(text) or
105
106
  style_warning(elem, "List entry of separate sentences must start " \
106
- "with uppercase letter", text)
107
+ "with uppercase letter", text, display: false)
107
108
  punct = text.strip.sub(/^.*?(\S)$/m, "\\1")
108
109
  punct == "." or
109
110
  style_warning(elem, "List entry of separate sentences must " \
110
- "end with full stop", text)
111
+ "end with full stop", text, display: false)
111
112
  end
112
113
 
113
114
  # allow that all-caps word (acronym) is agnostic as to lowercase
@@ -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.3".freeze
3
+ VERSION = "3.0.5".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.3
4
+ version: 3.0.5
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-31 00:00:00.000000000 Z
11
+ date: 2025-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc