metanorma-iso 2.4.8 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,22 +8,33 @@ module IsoDoc
8
8
  class Xref < IsoDoc::Xref
9
9
  attr_accessor :anchors_previous, :anchors
10
10
 
11
- def initial_anchor_names(doc)
12
- if @klass.amd(doc) then initial_anchor_names_amd(doc)
13
- else initial_anchor_names1(doc)
11
+ def clause_order_main(docxml)
12
+ if @klass.amd?(docxml)
13
+ [{ path: "//sections/clause", multi: true }]
14
+ else
15
+ [{ path: "//clause[@type = 'scope']" },
16
+ { path: @klass.norm_ref_xpath },
17
+ { path:
18
+ "#{@klass.middle_clause(docxml)} | //sections/terms | " \
19
+ "//sections/clause[descendant::terms or descendant::definitions] " \
20
+ "| //sections/definitions", multi: true }]
14
21
  end
15
- if @parse_settings.empty? || @parse_settings[:clauses]
16
- introduction_names(doc.at(ns("//introduction")))
22
+ end
23
+
24
+ def clause_order_back(docxml)
25
+ if @klass.amd?(docxml)
26
+ [{ path: @klass.norm_ref_xpath },
27
+ { path: @klass.bibliography_xpath },
28
+ { path: "//indexsect", multi: true },
29
+ { path: "//colophon/*", multi: true }]
30
+ else super
17
31
  end
18
32
  end
19
33
 
20
- def initial_anchor_names_amd(doc)
34
+ def initial_anchor_names(doc)
35
+ super
21
36
  if @parse_settings.empty? || @parse_settings[:clauses]
22
- ["//preface/*", "//sections/clause"].each do |xpath|
23
- doc.xpath(ns(xpath)).each do |c|
24
- c.element? and preface_names(c)
25
- end
26
- end
37
+ introduction_names(doc.at(ns("//introduction")))
27
38
  end
28
39
  end
29
40
 
@@ -33,23 +44,6 @@ module IsoDoc
33
44
  sequential_asset_names(doc.xpath(ns("//preface/*")))
34
45
  end
35
46
 
36
- def initial_anchor_names1(doc)
37
- if @parse_settings.empty? || @parse_settings[:clauses]
38
- doc.xpath(ns("//preface/*")).each do |c|
39
- c.element? and preface_names(c)
40
- end
41
- # potentially overridden in middle_section_asset_names()
42
- sequential_asset_names(doc.xpath(ns("//preface/*")))
43
- n = Counter.new
44
- n = section_names(doc.at(ns("//clause[@type = 'scope']")), n, 1)
45
- n = section_names(doc.at(ns(@klass.norm_ref_xpath)), n, 1)
46
- doc.xpath(ns("//sections/clause[not(@type = 'scope')] | " \
47
- "//sections/terms | //sections/definitions")).each do |c|
48
- n = section_names(c, n, 1)
49
- end
50
- end
51
- end
52
-
53
47
  def hierarchical_formula_names(clause, num)
54
48
  c = IsoDoc::XrefGen::Counter.new
55
49
  clause.xpath(ns(".//formula")).each do |t|
@@ -131,13 +125,6 @@ module IsoDoc
131
125
  .sub(/ \(All Parts\)/i, "") }
132
126
  end
133
127
 
134
- def back_anchor_names(docxml)
135
- super
136
- if @parse_settings.empty? || @parse_settings[:clauses]
137
- docxml.xpath(ns("//indexsect")).each { |b| preface_names(b) }
138
- end
139
- end
140
-
141
128
  def list_anchor_names(sections)
142
129
  sections.each do |s|
143
130
  notes = s.xpath(ns(".//ol")) - s.xpath(ns(".//clause//ol")) -
@@ -1,5 +1,5 @@
1
1
  == copyright-statement
2
- === {% if stage_int >= 40 %}DOCUMENT PROTÉGÉ PAR COPYRIGHT{%else%}{blank}
2
+ === {% if stage_int >= 40 %}DOCUMENT PROTÉGÉ PAR COPYRIGHT{%else%}{blank}{%endif%}
3
3
 
4
4
  [[boilerplate-year]]
5
5
  &#xa9; span:std_publisher:[{{ agency }}] span:std_docNumber[{{ docyear }}]
@@ -110,10 +110,10 @@ module Metanorma
110
110
  xml.xpath("//*[@inline-header]").each { |h| h.delete("inline-header") }
111
111
  end
112
112
 
113
- def boilerplate_file(xmldoc)
113
+ def boilerplate_file(_xmldoc)
114
114
  file = case @lang
115
- when "fr" then "boilerplate-fr.xml"
116
- when "ru" then "boilerplate-ru.xml"
115
+ when "fr" then "boilerplate-fr.adoc"
116
+ when "ru" then "boilerplate-ru.adoc"
117
117
  else "boilerplate.adoc"
118
118
  end
119
119
  File.join(@libdir, file)
@@ -142,11 +142,10 @@ module Metanorma
142
142
  def unpublished_note(xmldoc)
143
143
  xmldoc.xpath("//bibitem[not(./ancestor::bibitem)]" \
144
144
  "[not(note[@type = 'Unpublished-Status'])]").each do |b|
145
- next if pub_class(b) > 2
146
- next unless (s = b.at("./status/stage")) && (s.text.to_i < 60)
147
-
145
+ pub_class(b) > 2 and next
146
+ ((s = b.at("./status/stage")) && (s.text.to_i < 60)) or next
148
147
  id = b.at("docidentifier").text
149
- insert_unpub_note(b, @i18n.under_preparation.sub(/%/, id))
148
+ insert_unpub_note(b, @i18n.under_preparation.sub("%", id))
150
149
  end
151
150
  end
152
151
 
@@ -155,7 +154,7 @@ module Metanorma
155
154
  .each do |b|
156
155
  withdrawn_ref?(b) or next
157
156
  if id = replacement_standard(b)
158
- insert_unpub_note(b, @i18n.cancelled_and_replaced.sub(/%/, id))
157
+ insert_unpub_note(b, @i18n.cancelled_and_replaced.sub("%", id))
159
158
  else insert_unpub_note(b, @i18n.withdrawn)
160
159
  end
161
160
  end
@@ -227,7 +226,7 @@ module Metanorma
227
226
  xmldoc.xpath("//bibdata/contributor[role/@type = 'publisher']/" \
228
227
  "organization").each_with_object([]) do |p, m|
229
228
  x = p.at("./abbreviation") || p.at("./name") or next
230
- m << x.text
229
+ m << x.children.to_xml
231
230
  end
232
231
  end
233
232
 
@@ -237,8 +236,7 @@ module Metanorma
237
236
  def editorial_group_types(xmldoc)
238
237
  %w(technical-committee subcommittee workgroup).each do |v|
239
238
  xmldoc.xpath("//bibdata//#{v} | //bibdata//approval-#{v}").each do |g|
240
- next if g["type"]
241
-
239
+ g["type"] and next
242
240
  g["type"] = DEFAULT_EDGROUP_TYPE[v.to_sym]
243
241
  end
244
242
  end
@@ -5,6 +5,7 @@ require "json"
5
5
  require "pathname"
6
6
  require "open-uri"
7
7
  require_relative "front_id"
8
+ require_relative "front_contributor"
8
9
 
9
10
  module Metanorma
10
11
  module ISO
@@ -17,13 +18,16 @@ module Metanorma
17
18
  xml.updates_document_type a
18
19
  end
19
20
 
21
+ STAGE_ERROR = [Pubid::Core::Errors::HarmonizedStageCodeInvalidError,
22
+ Pubid::Core::Errors::TypeStageParseError,
23
+ Pubid::Core::Errors::StageInvalidError].freeze
24
+
20
25
  def metadata_stage(node, xml)
21
26
  id = iso_id_default(iso_id_params(node))
22
27
  id.stage and
23
28
  xml.stagename metadata_stagename(id)&.strip,
24
29
  **attr_code(abbreviation: id.typed_stage_abbrev&.strip)
25
- rescue Pubid::Core::Errors::HarmonizedStageCodeInvalidError,
26
- Pubid::Core::Errors::TypeStageParseError
30
+ rescue *STAGE_ERROR
27
31
  end
28
32
 
29
33
  def metadata_stagename(id)
@@ -44,53 +48,6 @@ module Metanorma
44
48
  a = node.attr("horizontal") and xml.horizontal a
45
49
  end
46
50
 
47
- def org_abbrev
48
- { "International Organization for Standardization" => "ISO",
49
- "International Electrotechnical Commission" => "IEC" }
50
- end
51
-
52
- def metadata_author(node, xml)
53
- publishers = node.attr("publisher") || "ISO"
54
- csv_split(publishers).each do |p|
55
- xml.contributor do |c|
56
- c.role type: "author"
57
- c.organization do |a|
58
- organization(a, p, false, node, !node.attr("publisher"))
59
- end
60
- end
61
- end
62
- end
63
-
64
- def metadata_publisher(node, xml)
65
- publishers = node.attr("publisher") || "ISO"
66
- csv_split(publishers).each do |p|
67
- xml.contributor do |c|
68
- c.role type: "publisher"
69
- c.organization do |a|
70
- organization(a, p, true, node, !node.attr("publisher"))
71
- end
72
- end
73
- end
74
- end
75
-
76
- def metadata_copyright(node, xml)
77
- publishers = node.attr("copyright-holder") || node.attr("publisher") ||
78
- "ISO"
79
- csv_split(publishers).each do |p|
80
- xml.copyright do |c|
81
- c.from (node.attr("copyright-year") || Date.today.year)
82
- c.owner do |owner|
83
- owner.organization do |o|
84
- organization(
85
- o, p, true, node,
86
- !(node.attr("copyright-holder") || node.attr("publisher"))
87
- )
88
- end
89
- end
90
- end
91
- end
92
- end
93
-
94
51
  def metadata_status(node, xml)
95
52
  stage = get_stage(node)
96
53
  substage = get_substage(node)
@@ -100,8 +57,7 @@ module Metanorma
100
57
  s.substage substage
101
58
  i = node.attr("iteration") and s.iteration i
102
59
  end
103
- rescue Pubid::Core::Errors::HarmonizedStageCodeInvalidError,
104
- Pubid::Core::Errors::TypeStageParseError
60
+ rescue *STAGE_ERROR
105
61
  report_illegal_stage(stage, substage)
106
62
  end
107
63
 
@@ -111,46 +67,6 @@ module Metanorma
111
67
  warn err
112
68
  end
113
69
 
114
- def metadata_committee(node, xml)
115
- metadata_editorial_committee(node, xml)
116
- metadata_approval_committee(node, xml)
117
- end
118
-
119
- def metadata_editorial_committee(node, xml)
120
- xml.editorialgroup do |a|
121
- %w(technical-committee subcommittee workgroup).each do |v|
122
- node.attr("#{v}-number") and committee_component(v, node, a)
123
- end
124
- node.attr("secretariat") and a.secretariat(node.attr("secretariat"))
125
- end
126
- end
127
-
128
- def metadata_approval_committee(node, xml)
129
- types = metadata_approval_committee_types(node)
130
- xml.approvalgroup do |a|
131
- metadata_approval_agency(a, node.attr("approval-agency")
132
- &.split(%r{[/,;]}))
133
- types.each do |v|
134
- node.attr("#{v}-number") and committee_component(v, node, a)
135
- end
136
- end
137
- end
138
-
139
- def metadata_approval_committee_types(node)
140
- types = %w(technical-committee subcommittee workgroup)
141
- node.attr("approval-technical-committee-number") and
142
- types = %w(approval-technical-committee approval-subcommittee
143
- approval-workgroup)
144
- types
145
- end
146
-
147
- def metadata_approval_agency(xml, list)
148
- list = ["ISO"] if list.nil? || list.empty?
149
- list.each do |v|
150
- xml.agency v
151
- end
152
- end
153
-
154
70
  def title_intro(node, xml, lang, at)
155
71
  return unless node.attr("title-intro-#{lang}")
156
72
 
@@ -0,0 +1,144 @@
1
+ module Metanorma
2
+ module ISO
3
+ class Converter < Standoc::Converter
4
+ def home_agency
5
+ "ISO"
6
+ end
7
+
8
+ def org_abbrev
9
+ { "International Organization for Standardization" => "ISO",
10
+ "International Electrotechnical Commission" => "IEC" }
11
+ end
12
+
13
+ def metadata_author(node, xml)
14
+ publishers = node.attr("publisher") || home_agency
15
+ metadata_contrib_sdo(node, xml, publishers,
16
+ { role: "author",
17
+ default_org: !node.attr("publisher") })
18
+ committee_contributors(node, xml, false, home_agency)
19
+ end
20
+
21
+ def metadata_contrib_sdo(node, xml, publishers, opt)
22
+ publishers.nil? and return
23
+ csv_split(publishers).each do |p|
24
+ xml.contributor do |c|
25
+ c.role type: opt[:role] do |r|
26
+ opt[:desc] and r << opt[:desc]
27
+ end
28
+ c.organization do |a|
29
+ (opt[:committee] and
30
+ contrib_committee_build(a, opt[:agency],
31
+ { name: p, id: opt[:ident] })) or
32
+ organization(a, p, opt[:role] == "publisher", node,
33
+ opt[:default_org])
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ def committee_contributors(node, xml, approval, agency)
40
+ types = metadata_approval_committee_types(approval ? node : nil)
41
+ types.each do |v|
42
+ n = node.attr("#{v}-number") or next
43
+ t = committee_abbrev(node.attr("#{v}-type"), n, v)
44
+ metadata_contrib_sdo(
45
+ node, xml, node.attr(v),
46
+ { role: approval ? "authorizer" : "author", ident: t,
47
+ default_org: false, committee: true, agency: agency,
48
+ desc: v.sub(/^approval-/, "").gsub("-", " ").capitalize }
49
+ )
50
+ end
51
+ approval and
52
+ metadata_contrib_sdo(node, xml, agency,
53
+ { role: "authorizer", default_org: false,
54
+ desc: "Agency", committee: false })
55
+ end
56
+
57
+ def contrib_committee_build(xml, agency, committee)
58
+ n = org_abbrev.invert[agency] and agency = n
59
+ xml.name agency
60
+ xml.subdivision committee[:name]
61
+ committee[:abbr] and xml.abbreviation committee[:abbr]
62
+ committee[:id] and xml.identifier committee[:id]
63
+ end
64
+
65
+ COMMITTEE_ABBREVS =
66
+ { "technical-committee" => "TC", "subcommittee" => "SC",
67
+ "workgroup" => "WG" }.freeze
68
+
69
+ def committee_abbrev(type, number, level)
70
+ type ||= COMMITTEE_ABBREVS[level.sub(/^approval-/, "")]
71
+ type == "Other" and type = ""
72
+ "#{type} #{number}".strip
73
+ end
74
+
75
+ def metadata_publisher(node, xml)
76
+ publishers = node.attr("publisher") || home_agency
77
+ metadata_contrib_sdo(node, xml, publishers,
78
+ { role: "publisher",
79
+ default_org: !node.attr("publisher") })
80
+ # approvals
81
+ committee_contributors(node, xml, true,
82
+ node.attr("approval-agency") || home_agency)
83
+ end
84
+
85
+ def metadata_copyright(node, xml)
86
+ publishers = node.attr("copyright-holder") || node.attr("publisher") ||
87
+ home_agency
88
+ csv_split(publishers).each do |p|
89
+ xml.copyright do |c|
90
+ c.from (node.attr("copyright-year") || Date.today.year)
91
+ c.owner do |owner|
92
+ owner.organization do |o|
93
+ organization(
94
+ o, p, true, node,
95
+ !(node.attr("copyright-holder") || node.attr("publisher"))
96
+ )
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
102
+
103
+ def metadata_committee(node, xml)
104
+ metadata_editorial_committee(node, xml)
105
+ metadata_approval_committee(node, xml)
106
+ end
107
+
108
+ def metadata_editorial_committee(node, xml)
109
+ xml.editorialgroup do |a|
110
+ %w(technical-committee subcommittee workgroup).each do |v|
111
+ node.attr("#{v}-number") and committee_component(v, node, a)
112
+ end
113
+ node.attr("secretariat") and a.secretariat(node.attr("secretariat"))
114
+ end
115
+ end
116
+
117
+ def metadata_approval_committee(node, xml)
118
+ types = metadata_approval_committee_types(node)
119
+ xml.approvalgroup do |a|
120
+ metadata_approval_agency(a, node.attr("approval-agency")
121
+ &.split(%r{[/,;]}))
122
+ types.each do |v|
123
+ node.attr("#{v}-number") and committee_component(v, node, a)
124
+ end
125
+ end
126
+ end
127
+
128
+ def metadata_approval_committee_types(node)
129
+ types = %w(technical-committee subcommittee workgroup)
130
+ !node.nil? && node.attr("approval-technical-committee-number") and
131
+ types = %w(approval-technical-committee approval-subcommittee
132
+ approval-workgroup)
133
+ types
134
+ end
135
+
136
+ def metadata_approval_agency(xml, list)
137
+ list = [home_agency] if list.nil? || list.empty?
138
+ list.each do |v|
139
+ xml.agency v
140
+ end
141
+ end
142
+ end
143
+ end
144
+ end
@@ -17,7 +17,7 @@
17
17
  these elements; we just want one namespace for any child grammars
18
18
  of this.
19
19
  -->
20
- <!-- VERSION v1.2.2 -->
20
+ <!-- VERSION v1.2.4 -->
21
21
  <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
22
22
  <include href="reqt.rng"/>
23
23
  <include href="basicdoc.rng">
@@ -192,9 +192,11 @@
192
192
  </attribute>
193
193
  </optional>
194
194
  <attribute name="citeas"/>
195
- <attribute name="type">
196
- <ref name="ReferenceFormat"/>
197
- </attribute>
195
+ <optional>
196
+ <attribute name="type">
197
+ <ref name="ReferenceFormat"/>
198
+ </attribute>
199
+ </optional>
198
200
  <optional>
199
201
  <attribute name="alt"/>
200
202
  </optional>
@@ -836,6 +838,26 @@
836
838
  <ref name="paragraph"/>
837
839
  </element>
838
840
  </define>
841
+ <define name="stem">
842
+ <element name="stem">
843
+ <attribute name="type">
844
+ <choice>
845
+ <value>MathML</value>
846
+ <value>AsciiMath</value>
847
+ <value>LatexMath</value>
848
+ </choice>
849
+ </attribute>
850
+ <attribute name="block">
851
+ <data type="boolean"/>
852
+ </attribute>
853
+ <oneOrMore>
854
+ <choice>
855
+ <text/>
856
+ <ref name="AnyElement"/>
857
+ </choice>
858
+ </oneOrMore>
859
+ </element>
860
+ </define>
839
861
  <define name="em">
840
862
  <element name="em">
841
863
  <zeroOrMore>
@@ -2046,6 +2068,9 @@
2046
2068
  </define>
2047
2069
  <define name="termdefinition">
2048
2070
  <element name="definition">
2071
+ <optional>
2072
+ <attribute name="type"/>
2073
+ </optional>
2049
2074
  <choice>
2050
2075
  <ref name="verbaldefinition"/>
2051
2076
  <ref name="nonverbalrep"/>
@@ -34,7 +34,7 @@ module Metanorma
34
34
  root.xpath("//xref").each do |t|
35
35
  preceding = t.at("./preceding-sibling::text()[last()]")
36
36
  next unless !preceding.nil? &&
37
- /\b(see| refer to)\s*\Z/mi.match(preceding)
37
+ /\b(see| refer to)\p{Zs}*\Z/mi.match(preceding)
38
38
 
39
39
  (target = root.at("//*[@id = '#{t['target']}']")) || next
40
40
  target.at("./ancestor-or-self::*[@obligation = 'normative']") &&
@@ -49,7 +49,7 @@ module Metanorma
49
49
  @lang == "en" or return
50
50
  root.xpath("//eref").each do |t|
51
51
  prec = t.at("./preceding-sibling::text()[last()]")
52
- next unless !prec.nil? && /\b(see|refer to)\s*\Z/mi.match(prec)
52
+ next unless !prec.nil? && /\b(see|refer to)\p{Zs}*\Z/mi.match(prec)
53
53
 
54
54
  unless target = root.at("//*[@id = '#{t['bibitemid']}']")
55
55
  @log.add("Bibliography", t,
@@ -20,7 +20,7 @@ module Metanorma
20
20
 
21
21
  def requirement_re
22
22
  Regexp.new(self.class::REQUIREMENT_RE_STR.gsub(/\s/, "")
23
- .gsub(/_/, "\\s"), Regexp::IGNORECASE)
23
+ .gsub("_", "\\s"), Regexp::IGNORECASE)
24
24
  end
25
25
 
26
26
  def requirement_check(text)
@@ -41,7 +41,7 @@ module Metanorma
41
41
 
42
42
  def recommendation_re
43
43
  Regexp.new(self.class::RECOMMENDATION_RE_STR.gsub(/\s/, "")
44
- .gsub(/_/, "\\s"), Regexp::IGNORECASE)
44
+ .gsub("_", "\\s"), Regexp::IGNORECASE)
45
45
  end
46
46
 
47
47
  def recommendation_check(text)
@@ -64,7 +64,7 @@ module Metanorma
64
64
  def permission_re
65
65
  @lang == "en" or return
66
66
  Regexp.new(self.class::PERMISSION_RE_STR.gsub(/\s/, "")
67
- .gsub(/_/, "\\s"), Regexp::IGNORECASE)
67
+ .gsub("_", "\\s"), Regexp::IGNORECASE)
68
68
  end
69
69
 
70
70
  def permission_check(text)
@@ -87,7 +87,7 @@ module Metanorma
87
87
  def possibility_re
88
88
  @lang == "en" or return
89
89
  Regexp.new(self.class::POSSIBILITY_RE_STR.gsub(/\s/, "")
90
- .gsub(/_/, "\\s"), Regexp::IGNORECASE)
90
+ .gsub("_", "\\s"), Regexp::IGNORECASE)
91
91
  end
92
92
 
93
93
  def possibility_check(text)
@@ -111,7 +111,7 @@ module Metanorma
111
111
  def ambig_words_re
112
112
  @lang == "en" or return
113
113
  Regexp.new(self.class::AMBIG_WORDS_RE_STR.gsub(/\s/, "")
114
- .gsub(/_/, "\\s"), Regexp::IGNORECASE)
114
+ .gsub("_", "\\s"), Regexp::IGNORECASE)
115
115
  end
116
116
 
117
117
  def ambig_words_check(text)
@@ -4,7 +4,7 @@ module Metanorma
4
4
  module ISO
5
5
  class Converter < Standoc::Converter
6
6
  def section_validate(doc)
7
- doctype = doc&.at("//bibdata/ext/doctype")&.text
7
+ doctype = doc.at("//bibdata/ext/doctype")&.text
8
8
  unless %w(amendment technical-corrigendum).include? doctype
9
9
  foreword_validate(doc.root)
10
10
  normref_validate(doc.root)
@@ -193,10 +193,14 @@ module Metanorma
193
193
  NORM_BIBITEMS =
194
194
  "//references[@normative = 'true']/bibitem".freeze
195
195
 
196
+ ISO_PUBLISHER_XPATH = <<~XPATH.freeze
197
+ ./contributor[role/@type = 'publisher']/organization[abbreviation = 'ISO' or abbreviation = 'IEC' or name = 'International Organization for Standardization' or name = 'International Electrotechnical Commission']
198
+ XPATH
199
+
196
200
  # ISO/IEC DIR 2, 10.2
197
201
  def norm_bibitem_style(root)
198
202
  root.xpath(NORM_BIBITEMS).each do |b|
199
- if b.at(Standoc::Converter::ISO_PUBLISHER_XPATH).nil?
203
+ if b.at(ISO_PUBLISHER_XPATH).nil?
200
204
  @log.add("Style", b, "#{NORM_ISO_WARN}: #{b.text}")
201
205
  end
202
206
  end
@@ -127,7 +127,7 @@ module Metanorma
127
127
  "possible decimal point", node, text)
128
128
  @lang == "en" and style_regex(/\b(?<num>billions?)\b/i,
129
129
  "ambiguous number", node, text)
130
- style_regex(/(?:^|\s)(?<num>-[0-9][0-9,.]*)/i,
130
+ style_regex(/(?:^|\P{Zs})(?<num>-[0-9][0-9,.]*)/i,
131
131
  "hyphen instead of minus sign U+2212", node, text)
132
132
  end
133
133
 
@@ -158,8 +158,8 @@ module Metanorma
158
158
  # ISO/IEC DIR 2, 8.4
159
159
  # ISO/IEC DIR 2, 9.3
160
160
  def style_abbrev(node, text)
161
- style_regex(/(\A|\s)(?!e\.g\.|i\.e\.)
162
- (?<num>[a-z]{1,2}\.([a-z]{1,2}|\.))\b/ix,
161
+ style_regex(/(?:\A|\p{Zs})(?!e\.g\.|i\.e\.)
162
+ (?<num>[a-z]{1,2}\.(?:[a-z]{1,2}|\.))\b/ix,
163
163
  "no dots in abbreviations", node, text)
164
164
  style_regex(/\b(?<num>ppm)\b/i,
165
165
  "language-specific abbreviation", node, text)
@@ -172,7 +172,7 @@ module Metanorma
172
172
 
173
173
  # ISO/IEC DIR 2, 9.3
174
174
  def style_units(node, text)
175
- style_regex(/\b(?<num>[0-9][0-9,]*\s+[\u00b0\u2032\u2033])/,
175
+ style_regex(/\b(?<num>[0-9][0-9,]*\p{Zs}+[\u00b0\u2032\u2033])/,
176
176
  "space between number and degrees/minutes/seconds",
177
177
  node, text)
178
178
  style_regex(/\b(?<num>[0-9][0-9,]*#{SI_UNIT})\b/o,
@@ -188,7 +188,7 @@ module Metanorma
188
188
  # ISO/IEC DIR 2, 9.3
189
189
  def style_non_std_units(node, text)
190
190
  NONSTD_UNITS.each do |k, v|
191
- style_regex(/\b(?<num>[0-9][0-9,]*\s+#{k})\b/,
191
+ style_regex(/\b(?<num>[0-9][0-9,]*\p{Zs}+#{k})\b/,
192
192
  "non-standard unit (should be #{v})", node, text)
193
193
  end
194
194
  end
@@ -198,7 +198,7 @@ module Metanorma
198
198
  def style_punct(node, text)
199
199
  @lang == "en" and style_regex(/\b(?<num>and\/?or)\b/i,
200
200
  "Use 'either x or y, or both'", node, text)
201
- style_regex(/\s(?<num>&)\s/i,
201
+ style_regex(/\p{Zs}(?<num>&)\p{Zs}/i,
202
202
  "Avoid ampersand in ordinary text'", node, text)
203
203
  eref_style_punct(node)
204
204
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "2.4.8".freeze
3
+ VERSION = "2.5.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.4.3"
35
+ spec.add_dependency "metanorma-standoc", "~> 2.5.1"
36
36
  spec.add_dependency "mnconvert", "~> 1.14"
37
37
  spec.add_dependency "pubid-iso", "~> 0.5.0"
38
38
  spec.add_dependency "ruby-jing"