metanorma-iso 2.4.7 → 2.5.0

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.
@@ -46,12 +46,6 @@ module IsoDoc
46
46
  { class: "TableTitle", style: "text-align:center;" }
47
47
  end
48
48
 
49
- def span_parse(node, out)
50
- out.span class: node["class"] do |x|
51
- node.children.each { |n| parse(n, x) }
52
- end
53
- end
54
-
55
49
  def word_toc_preface(level)
56
50
  <<~TOC.freeze
57
51
  <span lang="EN-GB"><span
@@ -68,7 +62,7 @@ module IsoDoc
68
62
 
69
63
  def toWord(result, filename, dir, header)
70
64
  result = from_xhtml(word_cleanup(to_xhtml(result)))
71
- .gsub(/-DOUBLE_HYPHEN_ESCAPE-/, "--")
65
+ .gsub("-DOUBLE_HYPHEN_ESCAPE-", "--")
72
66
  @wordstylesheet = wordstylesheet_update
73
67
  ::Html2Doc::IsoDIS.new(
74
68
  filename: filename,
@@ -86,30 +80,39 @@ module IsoDoc
86
80
  middle_title_dis(out)
87
81
  end
88
82
 
89
- def middle_title_dis(out)
83
+ def middle_title_dis(node, out)
90
84
  out.p(class: "zzSTDTitle") do |p|
91
- p << @meta.get[:doctitleintro]
92
- @meta.get[:doctitleintro] && @meta.get[:doctitlemain] and p << " &#x2014; "
93
- p << @meta.get[:doctitlemain]
94
- @meta.get[:doctitlemain] && @meta.get[:doctitlepart] and p << " &#x2014; "
95
- if @meta.get[:doctitlepart]
96
- b = @meta.get[:doctitlepartlabel] and
97
- p << "<span style='font-weight:normal'>#{b}:</span> "
98
- p << " #{@meta.get[:doctitlepart]}"
85
+ node.children.each { |n| parse(n, p) }
86
+ end
87
+ end
88
+
89
+ def middle_title_amd(node, out)
90
+ out.p(class: "zzSTDTitle2") do |p|
91
+ p.span(style: "font-weight:normal") do |s|
92
+ node.children.each { |n| parse(n, s) }
99
93
  end
100
- @meta.get[:doctitleamdlabel] || @meta.get[:doctitleamd] ||
101
- @meta.get[:doctitlecorrlabel] and middle_title_dis_amd(p)
102
94
  end
103
95
  end
104
96
 
105
- def middle_title_dis_amd(para)
106
- para.span(style: "font-weight:normal") do |p|
107
- if a = @meta.get[:doctitleamdlabel]
108
- p << " #{a}"
109
- a = @meta.get[:doctitleamd] and p << ": #{a}"
97
+ def para_parse(node, out)
98
+ case node["class"]
99
+ when "zzSTDTitle1" then middle_title_dis(node, out)
100
+ when "zzSTDTitle2" then middle_title_amd(node, out)
101
+ else super
102
+ end
103
+ end
104
+
105
+ def span_parse(node, out)
106
+ case node["class"]
107
+ when "nonboldtitle"
108
+ out.span(style: "font-weight:normal") do |s|
109
+ node.children.each { |n| parse(n, s) }
110
110
  end
111
- if a = @meta.get[:doctitlecorrlabel]
112
- p << " #{a}"
111
+ when "boldtitle"
112
+ node.children.each { |n| parse(n, out) }
113
+ else
114
+ out.span class: node["class"] do |x|
115
+ node.children.each { |n| parse(n, x) }
113
116
  end
114
117
  end
115
118
  end
@@ -43,7 +43,7 @@ module IsoDoc
43
43
  n = Counter.new
44
44
  n = section_names(doc.at(ns("//clause[@type = 'scope']")), n, 1)
45
45
  n = section_names(doc.at(ns(@klass.norm_ref_xpath)), n, 1)
46
- doc.xpath(ns("//sections/clause[not(@type = 'scope')] | " \
46
+ doc.xpath(ns("//sections/clause[not(@type = 'scope')][not(.//references)] | " \
47
47
  "//sections/terms | //sections/definitions")).each do |c|
48
48
  n = section_names(c, n, 1)
49
49
  end
@@ -12,15 +12,18 @@ module Metanorma
12
12
  def metadata_ext(node, xml)
13
13
  super
14
14
  structured_id(node, xml)
15
- id = iso_id_default(iso_id_params(node))
16
- id.stage and metadata_stage(id, xml)
15
+ metadata_stage(node, xml)
17
16
  @amd && a = node.attr("updates-document-type") and
18
17
  xml.updates_document_type a
19
18
  end
20
19
 
21
- def metadata_stage(id, xml)
22
- xml.stagename metadata_stagename(id)&.strip,
23
- **attr_code(abbreviation: id.typed_stage_abbrev&.strip)
20
+ def metadata_stage(node, xml)
21
+ id = iso_id_default(iso_id_params(node))
22
+ id.stage and
23
+ xml.stagename metadata_stagename(id)&.strip,
24
+ **attr_code(abbreviation: id.typed_stage_abbrev&.strip)
25
+ rescue Pubid::Core::Errors::HarmonizedStageCodeInvalidError,
26
+ Pubid::Core::Errors::TypeStageParseError
24
27
  end
25
28
 
26
29
  def metadata_stagename(id)
@@ -95,8 +98,17 @@ module Metanorma
95
98
  xml.status do |s|
96
99
  s.stage stage, **attr_code(abbreviation: abbrev)
97
100
  s.substage substage
98
- node.attr("iteration") && (s.iteration node.attr("iteration"))
101
+ i = node.attr("iteration") and s.iteration i
99
102
  end
103
+ rescue Pubid::Core::Errors::HarmonizedStageCodeInvalidError,
104
+ Pubid::Core::Errors::TypeStageParseError
105
+ report_illegal_stage(stage, substage)
106
+ end
107
+
108
+ def report_illegal_stage(stage, substage)
109
+ err = "Illegal document stage: #{stage}.#{substage}"
110
+ @log.add("Document Attributes", nil, err)
111
+ warn err
100
112
  end
101
113
 
102
114
  def metadata_committee(node, xml)
@@ -10,41 +10,6 @@ require "pubid-iso"
10
10
  module Metanorma
11
11
  module ISO
12
12
  class Converter < Standoc::Converter
13
- STAGE_ABBRS = {
14
- "00": "PWI",
15
- "10": "NP",
16
- "20": "WD",
17
- "30": "CD",
18
- "40": "DIS",
19
- "50": "FDIS",
20
- "60": "IS",
21
- "90": "(Review)",
22
- "95": "(Withdrawal)",
23
- }.freeze
24
-
25
- STAGE_NAMES = {
26
- "00": "Preliminary work item",
27
- "10": "New work item proposal",
28
- "20": "Working draft",
29
- "30": "Committee draft",
30
- "40": "Draft",
31
- "50": "Final draft",
32
- "60": "International standard",
33
- "90": "Review",
34
- "95": "Withdrawal",
35
- }.freeze
36
-
37
- def stage_abbr(stage, substage, _doctype)
38
- return nil if stage.to_i > 60
39
-
40
- ret = STAGE_ABBRS[stage.to_sym]
41
- ret = "PRF" if stage == "60" && substage == "00"
42
- ret = nil if stage == "60" && substage != "00"
43
- ret = "AWI" if stage == "10" && substage == "99"
44
- ret = "AWI" if stage == "20" && substage == "00"
45
- ret
46
- end
47
-
48
13
  def metadata_id(node, xml)
49
14
  if id = node.attr("docidentifier")
50
15
  xml.docidentifier id, **attr_code(type: "ISO")
@@ -103,23 +68,19 @@ module Metanorma
103
68
 
104
69
  def iso_id_params_add(node)
105
70
  stage = iso_id_stage(node)
106
-
107
71
  ret = { number: node.attr("amendment-number") ||
108
72
  node.attr("corrigendum-number"),
109
73
  year: iso_id_year(node),
110
74
  iteration: node.attr("iteration") }.compact
111
- stage and ret[:stage] = stage
112
- ret[:stage] == "60.00" and ret[:stage] = :PRF
75
+ if stage
76
+ ret[:stage] = stage
77
+ ret[:stage] == "60.00" and ret[:stage] = :PRF
78
+ end
113
79
  ret
114
80
  end
115
81
 
116
82
  def iso_id_stage(node)
117
- stage = stage_abbr(get_stage(node), get_substage(node),
118
- doctype(node))
119
- harmonised = "#{get_stage(node)}.#{get_substage(node)}"
120
- harmonised = nil unless /^\d\d\.\d\d/.match?(harmonised)
121
- { abbr: stage&.to_sym, harmonized_code: harmonised }
122
- harmonised || stage&.to_sym
83
+ "#{get_stage(node)}.#{get_substage(node)}"
123
84
  end
124
85
 
125
86
  def iso_id_year(node)
@@ -195,7 +156,7 @@ module Metanorma
195
156
  def structured_id(node, xml)
196
157
  return unless node.attr("docnumber")
197
158
 
198
- part, subpart = node&.attr("partnumber")&.split(/-/)
159
+ part, subpart = node&.attr("partnumber")&.split("-")
199
160
  xml.structuredidentifier do |i|
200
161
  i.project_number(node.attr("docnumber"), **attr_code(
201
162
  part: part, subpart: subpart,
@@ -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.3 -->
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>
@@ -132,20 +132,6 @@ module Metanorma
132
132
  "#{script} is not a recognised script")
133
133
  end
134
134
 
135
- def stage_validate(xmldoc)
136
- stage = xmldoc&.at("//bibdata/status/stage")&.text
137
- %w(00 10 20 30 40 50 60 90 95).include? stage or
138
- @log.add("Document Attributes", nil,
139
- "#{stage} is not a recognised stage")
140
- end
141
-
142
- def substage_validate(xmldoc)
143
- substage = xmldoc&.at("//bibdata/status/substage")&.text or return
144
- %w(00 20 60 90 92 93 98 99).include? substage or
145
- @log.add("Document Attributes", nil,
146
- "#{substage} is not a recognised substage")
147
- end
148
-
149
135
  def iteration_validate(xmldoc)
150
136
  iteration = xmldoc&.at("//bibdata/status/iteration")&.text or return
151
137
  /^\d+/.match(iteration) or
@@ -156,8 +142,6 @@ module Metanorma
156
142
  def bibdata_validate(doc)
157
143
  doctype_validate(doc)
158
144
  script_validate(doc)
159
- stage_validate(doc)
160
- substage_validate(doc)
161
145
  iteration_validate(doc)
162
146
  end
163
147
 
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "2.4.7".freeze
3
+ VERSION = "2.5.0".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.0"
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"
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.4.7
4
+ version: 2.5.0
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-07-06 00:00:00.000000000 Z
11
+ date: 2023-08-07 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.4.3
19
+ version: 2.5.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.4.3
26
+ version: 2.5.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mnconvert
29
29
  requirement: !ruby/object:Gem::Requirement