metanorma-iso 2.7.5 → 2.7.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -212,6 +212,11 @@ module IsoDoc
212
212
  end
213
213
  end
214
214
 
215
+ def twitter_cldr_localiser_symbols
216
+ { group: " ", fraction_group: " ",
217
+ fraction_group_digits: 3 }
218
+ end
219
+
215
220
  include Init
216
221
  end
217
222
  end
@@ -105,22 +105,6 @@ module IsoDoc
105
105
  locality_span_wrap(ret, opt[:type])
106
106
  end
107
107
 
108
- =begin
109
- def prefix_container(container, linkend, node, target)
110
- delim = ", "
111
- ref = if @xrefs.anchor(target, :type) == "listitem" &&
112
- !@xrefs.anchor(target, :refer_list)
113
- delim = " "
114
- @xrefs.anchor(container, :label)
115
- # 7 a) : Clause 7 a), but Clause 7 List 1 a)
116
- else anchor_xref(node, container)
117
- end
118
-
119
- ref and linkend = ref + delim + linkend
120
- l10n(linkend)
121
- end
122
- =end
123
-
124
108
  # 7 a) : Clause 7 a), but Clause 7 List 1 a)
125
109
  def prefix_container(container, linkend, node, target)
126
110
  prefix_container?(container, node) or return linkend
@@ -135,10 +119,11 @@ module IsoDoc
135
119
  def prefix_container_template(container, node, target)
136
120
  nested_xref = @i18n.nested_xref
137
121
  container_label = anchor_xref(node, container)
138
- if @xrefs.anchor(target, :type) == "listitem" &&
139
- !@xrefs.anchor(target, :refer_list)
122
+ if @xrefs.anchor(target, :type) == "listitem"
123
+ if !@xrefs.anchor(target, :refer_list)
140
124
  nested_xref = "%1 %2"
141
- n = @xrefs.anchor(container, :label) and container_label = n
125
+ # n = @xrefs.anchor(container, :label) and container_label = n
126
+ end
142
127
  end
143
128
  [nested_xref, container_label]
144
129
  end
@@ -52,18 +52,22 @@ module IsoDoc
52
52
 
53
53
  def convert(input_filename, file = nil, debug = false,
54
54
  output_filename = nil)
55
- file = File.read(input_filename, encoding: "utf-8") if file.nil?
56
- docxml = Nokogiri::XML(file) { |config| config.huge }
57
- stage = docxml&.at(ns("//bibdata/status/stage"))&.text
58
- if @dis &&
59
- ((/^[4569].$/.match?(stage) && @wordtemplate != "simple") ||
60
- (/^[0-3].$/.match?(stage) && @wordtemplate == "dis"))
55
+ if @dis && use_dis?(input_filename, file)
56
+ swap_renderer(self, @dis, file, input_filename, debug)
61
57
  @dis.convert(input_filename, file, debug, output_filename)
62
58
  else
63
59
  super
64
60
  end
65
61
  end
66
62
 
63
+ def use_dis?(input_filename, file)
64
+ file ||= File.read(input_filename, encoding: "utf-8")
65
+ stage = Nokogiri::XML(file, &:huge)
66
+ .at(ns("//bibdata/status/stage"))&.text
67
+ (/^[4569].$/.match?(stage) && @wordtemplate != "simple") ||
68
+ (/^[0-3].$/.match?(stage) && @wordtemplate == "dis")
69
+ end
70
+
67
71
  def make_body(xml, docxml)
68
72
  body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72" }
69
73
  xml.body **body_attr do |body|
@@ -18,7 +18,7 @@ module IsoDoc
18
18
  end
19
19
 
20
20
  def word_section_end_empty_para(docxml)
21
- docxml.at("//div[@class='WordSection1']/p[last()]").remove
21
+ docxml.at("//div[@class='WordSection1']/p[last()]")&.remove
22
22
  end
23
23
 
24
24
  def word_table_cell_para(docxml)
@@ -61,8 +61,6 @@ module IsoDoc
61
61
  end
62
62
 
63
63
  def toWord(result, filename, dir, header)
64
- result = from_xhtml(word_cleanup(to_xhtml(result)))
65
- .gsub("-DOUBLE_HYPHEN_ESCAPE-", "--")
66
64
  @wordstylesheet = wordstylesheet_update
67
65
  ::Html2Doc::IsoDIS.new(
68
66
  filename: filename,
@@ -140,12 +140,10 @@ module IsoDoc
140
140
 
141
141
  # all li in the ol in lists are consecutively numbered through @start
142
142
  def single_ol_for_xrefs?(lists)
143
- return true if lists.size == 1
144
-
143
+ lists.size == 1 and return true
145
144
  start = 0
146
145
  lists.each_with_index do |l, i|
147
- next if i.zero?
148
-
146
+ i.zero? and next
149
147
  start += lists[i - 1].xpath(ns("./li")).size
150
148
  return false unless l["start"]&.to_i == start + 1
151
149
  end
@@ -58,9 +58,19 @@ module IsoDoc
58
58
  end
59
59
  end
60
60
 
61
+ def annex_name_anchors1(clause, num, level)
62
+ ret = { label: num, level: level, subtype: "annex" }
63
+ ret2 = if level == 2
64
+ { xref: l10n("#{@labels['clause']} #{num}"),
65
+ elem: @labels["clause"] }
66
+ else
67
+ { xref: num }
68
+ end
69
+ @anchors[clause["id"]] = ret.merge(ret2)
70
+ end
71
+
61
72
  def annex_names1(clause, num, level)
62
- @anchors[clause["id"]] = { label: num, xref: num, level: level,
63
- subtype: "annex" }
73
+ annex_name_anchors1(clause, num, level)
64
74
  i = Counter.new(0, prefix: "#{num}.")
65
75
  clause.xpath(ns("./clause | ./references")).each do |c|
66
76
  annex_names1(c, i.increment(c).print, level + 1)
@@ -79,8 +79,16 @@ module Metanorma
79
79
  name
80
80
  end
81
81
 
82
+ DOCUMENT_SCHEMES = [1951, 1972, 1979, 1987, 1989, 2012, 2013, 2024].freeze
83
+
82
84
  def document_scheme(node)
83
- node.attr("document-scheme") || "2024"
85
+ r = node.attr("document-scheme") and return r
86
+ r = node.attr("copyright-year")&.to_i or return "2024"
87
+ DOCUMENT_SCHEMES.each_index do |i|
88
+ i.zero? and next
89
+ r < DOCUMENT_SCHEMES[i] and return DOCUMENT_SCHEMES[i - 1].to_s
90
+ end
91
+ "2024"
84
92
  end
85
93
 
86
94
  def outputs(node, ret)
@@ -125,13 +125,6 @@ module Metanorma
125
125
  "#{@doctype} is not a recognised document type")
126
126
  end
127
127
 
128
- def script_validate(xmldoc)
129
- script = xmldoc&.at("//bibdata/script")&.text
130
- %w(Cyrl Latn).include?(script) or
131
- @log.add("Document Attributes", nil,
132
- "#{script} is not a recognised script")
133
- end
134
-
135
128
  def iteration_validate(xmldoc)
136
129
  iteration = xmldoc&.at("//bibdata/status/iteration")&.text or return
137
130
  /^\d+/.match(iteration) or
@@ -141,7 +134,6 @@ module Metanorma
141
134
 
142
135
  def bibdata_validate(doc)
143
136
  doctype_validate(doc)
144
- script_validate(doc)
145
137
  iteration_validate(doc)
146
138
  end
147
139
 
@@ -6,10 +6,10 @@ module Metanorma
6
6
  module ISO
7
7
  class Converter < Standoc::Converter
8
8
  def extract_text(node)
9
- return "" if node.nil?
10
-
9
+ node.nil? and return ""
11
10
  node1 = Nokogiri::XML.fragment(node.to_s)
12
- node1.xpath("//link | //locality | //localityStack").each(&:remove)
11
+ node1.xpath(".//link | .//locality | .//localityStack | .//stem")
12
+ .each(&:remove)
13
13
  ret = ""
14
14
  node1.traverse { |x| ret += x.text if x.text? }
15
15
  HTMLEntities.new.decode(ret)
@@ -17,30 +17,26 @@ module Metanorma
17
17
 
18
18
  # ISO/IEC DIR 2, 12.2
19
19
  def foreword_style(node)
20
- return if @novalid
21
-
20
+ @novalid and return
22
21
  style_no_guidance(node, extract_text(node), "Foreword")
23
22
  end
24
23
 
25
24
  # ISO/IEC DIR 2, 14.2
26
25
  def scope_style(node)
27
- return if @novalid
28
-
26
+ @novalid and return
29
27
  style_no_guidance(node, extract_text(node), "Scope")
30
28
  end
31
29
 
32
30
  # ISO/IEC DIR 2, 13.2
33
31
  def introduction_style(node)
34
- return if @novalid
35
-
32
+ @novalid and return
36
33
  r = requirement_check(extract_text(node))
37
34
  style_warning(node, "Introduction may contain requirement", r) if r
38
35
  end
39
36
 
40
37
  # ISO/IEC DIR 2, 16.5.6
41
38
  def definition_style(node)
42
- return if @novalid
43
-
39
+ @novalid and return
44
40
  r = requirement_check(extract_text(node))
45
41
  style_warning(node, "Definition may contain requirement", r) if r
46
42
  end
@@ -48,24 +44,21 @@ module Metanorma
48
44
  # ISO/IEC DIR 2, 16.5.7
49
45
  # ISO/IEC DIR 2, 25.5
50
46
  def example_style(node)
51
- return if @novalid
52
-
47
+ @novalid and return
53
48
  style_no_guidance(node, extract_text(node), "Example")
54
49
  style(node, extract_text(node))
55
50
  end
56
51
 
57
52
  # ISO/IEC DIR 2, 24.5
58
53
  def note_style(node)
59
- return if @novalid
60
-
54
+ @novalid and return
61
55
  style_no_guidance(node, extract_text(node), "Note")
62
56
  style(node, extract_text(node))
63
57
  end
64
58
 
65
59
  # ISO/IEC DIR 2, 26.5
66
60
  def footnote_style(node)
67
- return if @novalid
68
-
61
+ @novalid and return
69
62
  style_no_guidance(node, extract_text(node), "Footnote")
70
63
  style(node, extract_text(node))
71
64
  end
@@ -91,7 +84,7 @@ module Metanorma
91
84
 
92
85
  def style(node, text)
93
86
  @novalid and return
94
- style_number(node, text)
87
+ @novalid_number or style_number(node, text)
95
88
  style_percent(node, text)
96
89
  style_abbrev(node, text)
97
90
  style_units(node, text)
@@ -116,6 +109,8 @@ module Metanorma
116
109
  def style_ambig_words(node, text)
117
110
  r = ambig_words_check(text) and
118
111
  style_warning(node, "may contain ambiguous provision", r)
112
+ @lang == "en" and style_regex(/\b(?<num>billions?)\b/i,
113
+ "ambiguous number", node, text)
119
114
  end
120
115
 
121
116
  # ISO/IEC DIR 2, 9.1
@@ -124,11 +119,12 @@ module Metanorma
124
119
  def style_number(node, text)
125
120
  style_number_grouping(node, text)
126
121
  style_regex(/(?:^|\p{Zs})(?<num>[0-9]+\.[0-9]+)(?!\.[0-9])/i,
127
- "possible decimal point", node, text)
122
+ "possible decimal point: mark up numbers with stem:[]", node, text)
128
123
  @lang == "en" and style_regex(/\b(?<num>billions?)\b/i,
129
124
  "ambiguous number", node, text)
130
125
  style_regex(/(?:^|\p{Zs})(?<num>-[0-9][0-9,.]*)/i,
131
126
  "hyphen instead of minus sign U+2212", node, text)
127
+ @novalid_number = true
132
128
  end
133
129
 
134
130
  def style_number_grouping(node, text)
@@ -136,13 +132,13 @@ module Metanorma
136
132
  style_two_regex_not_prev(
137
133
  node, text, /^(?<num>-?[0-9]{4,}[,0-9]*)\Z/,
138
134
  %r{\b(ISO|IEC|IEEE|(in|January|February|March|April|May|June|August|September|October|November|December)\b)\Z},
139
- "number not broken up in threes"
135
+ "number not broken up in threes: mark up numbers with stem:[]"
140
136
  )
141
137
  else
142
138
  style_two_regex_not_prev(
143
139
  node, text, /^(?<num>-?(?:[0-9]{5,}[,0-9]*|[03-9]\d\d\d|1[0-8]\d\d|2[1-9]\d\d|20[5-9]\d))\Z/,
144
140
  %r{\b(ISO|IEC|IEEE|\b)\Z},
145
- "number not broken up in threes"
141
+ "number not broken up in threes: mark up numbers with stem:[]"
146
142
  )
147
143
  end
148
144
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "2.7.5".freeze
3
+ VERSION = "2.7.6".freeze
4
4
  end
5
5
  end
@@ -34,9 +34,7 @@ Gem::Specification.new do |spec|
34
34
 
35
35
  spec.add_dependency "metanorma-standoc", "~> 2.8.4"
36
36
  spec.add_dependency "mnconvert", "~> 1.14"
37
- spec.add_dependency "pubid-cen"
38
- spec.add_dependency "pubid-iec"
39
- spec.add_dependency "pubid-iso"
37
+ spec.add_dependency "pubid"
40
38
  spec.add_dependency "tokenizer", "~> 0.3.0"
41
39
 
42
40
  spec.add_development_dependency "debug"
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.7.5
4
+ version: 2.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-25 00:00:00.000000000 Z
11
+ date: 2024-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc
@@ -39,35 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.14'
41
41
  - !ruby/object:Gem::Dependency
42
- name: pubid-cen
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: pubid-iec
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: pubid-iso
42
+ name: pubid
71
43
  requirement: !ruby/object:Gem::Requirement
72
44
  requirements:
73
45
  - - ">="