metanorma-ieee 1.3.4 → 1.3.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,7 @@ module IsoDoc
2
2
  module Ieee
3
3
  class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
4
4
  def multidef(elem)
5
+ # require "debug"; binding.b
5
6
  number_multidef(elem)
6
7
  collapse_multidef(elem)
7
8
  end
@@ -35,9 +36,11 @@ module IsoDoc
35
36
  docxml.xpath(ns(".//definition/verbal-definition")).each do |v|
36
37
  v.elements.all? { |e| %w(termsource p).include?(e.name) } or next
37
38
  p = v.xpath(ns("./p"))
39
+ s = v.xpath(ns('./termsource'))
40
+ s.empty? or
41
+ s = " (#{s.map { |x| to_xml(x) }.join("\n")})"
38
42
  v.children =
39
- "<p>#{p.map(&:children).map { |x| to_xml(x) }.join("\n")}</p>" \
40
- "#{v.xpath(ns('./termsource')).to_xml}"
43
+ "<p>#{p.map(&:children).map { |x| to_xml(x) }.join("\n")}#{s}</p>"
41
44
  end
42
45
  super
43
46
  end
@@ -241,18 +244,14 @@ module IsoDoc
241
244
  pref << " (#{tail})"
242
245
  end
243
246
 
244
- def termnote_delim(_elem)
245
- "&#x2014;"
246
- end
247
-
248
247
  def termnote1(elem)
249
248
  lbl = termnote_label(elem)
250
- prefix_name(elem, block_delim, lower2cap(lbl), "name")
249
+ prefix_name(elem, { label: block_delim }, lower2cap(lbl), "name")
251
250
  end
252
251
 
253
252
  def termnote_label(elem)
254
253
  lbl = l10n(@xrefs.anchor(elem["id"], :label)&.strip || "???")
255
- l10n "#{lbl}#{termnote_delim(elem)}"
254
+ l10n lbl
256
255
  end
257
256
 
258
257
  def term(docxml); end
@@ -58,12 +58,18 @@ module IsoDoc
58
58
  @xrefs.anchor(node["target"], :type) == "clause" &&
59
59
  @xrefs.anchor(node["target"], :level) > 1 &&
60
60
  !start_of_sentence(node) and
61
- linkend = linkend.sub(/^Clause /, "")
61
+ linkend = strip_initial_clause(linkend)
62
62
  container = @xrefs.anchor(node["target"], :container, false)
63
63
  linkend = prefix_container(container, linkend, node, node["target"])
64
64
  capitalise_xref(node, linkend, anchor_value(node["target"]))
65
65
  end
66
66
 
67
+ def strip_initial_clause(linkend)
68
+ x = Nokogiri::XML("<a>#{linkend}</a>")
69
+ x.at(".//span[@class = 'fmt-element-name']")&.remove
70
+ to_xml(x.elements.first.children).strip
71
+ end
72
+
67
73
  def eref_locality_populate(type, node, number)
68
74
  type == "page" and return ""
69
75
  super
@@ -81,25 +87,33 @@ module IsoDoc
81
87
  if @doctype == "whitepaper"
82
88
  annex1_whitepaper(elem)
83
89
  else
84
- annex1_default(elem)
90
+ super
85
91
  end
86
92
  end
87
93
 
88
94
  def annex1_whitepaper(elem)
89
95
  lbl = @xrefs.anchor(elem["id"], :label)
90
96
  if t = elem.at(ns("./title"))
91
- t.name = "variant-title"
92
- t["type"] = "sub"
97
+ d = t.dup
98
+ # TODO fmt-variant-title
99
+ d.name = "variant-title"
100
+ d["type"] = "sub"
101
+ t.next = d
93
102
  end
94
- elem.add_first_child "<title>#{lbl}</title>"
103
+ elem.add_first_child "<fmt-title>#{lbl}</fmt-title>"
95
104
  end
96
105
 
106
+ def annex_delim(_elem)
107
+ "<br/>"
108
+ end
109
+
110
+ # KILL
97
111
  def annex1_default(elem)
98
112
  lbl = @xrefs.anchor(elem["id"], :label)
99
113
  if t = elem.at(ns("./title"))
100
114
  t.children = "<strong>#{to_xml(t.children)}</strong>"
101
115
  end
102
- prefix_name(elem, "<br/>", lbl, "title")
116
+ prefix_name(elem, { caption: "<br/>" }, lbl, "title")
103
117
  end
104
118
 
105
119
  def amend1(elem)
@@ -214,8 +228,8 @@ module IsoDoc
214
228
 
215
229
  def example1(elem)
216
230
  super
217
- n = elem.at(ns("./name")) or return
218
- n << l10n(":")
231
+ n = elem.at(ns("./fmt-name")) or return
232
+ n << l10n("<span class='fmt-caption-delim'>:</span>")
219
233
  n.children.wrap("<em></em>")
220
234
  end
221
235
 
@@ -78,25 +78,9 @@ module IsoDoc
78
78
  end
79
79
 
80
80
  def caption_cleanup(docxml)
81
- table_caption(docxml)
82
- figure_caption(docxml)
83
81
  example_caption(docxml)
84
82
  end
85
83
 
86
- def table_caption(docxml)
87
- docxml.xpath("//p[@class = 'TableTitle']").each do |s|
88
- s.children = to_xml(s.children)
89
- .sub(/^#{@i18n.table}(\s+[A-Z0-9.]+)?/, "")
90
- end
91
- end
92
-
93
- def figure_caption(docxml)
94
- docxml.xpath("//p[@class = 'FigureTitle']").each do |s|
95
- s.children = to_xml(s.children)
96
- .sub(/^#{@i18n.figure}(\s+[A-Z0-9.]+)?/, "")
97
- end
98
- end
99
-
100
84
  def example_caption(docxml)
101
85
  docxml.xpath("//p[@class = 'example-title']").each do |s|
102
86
  s["class"] = stylesmap[:MsoNormal]
@@ -67,9 +67,9 @@ module IsoDoc
67
67
  def abstract(clause, out)
68
68
  page_break(out)
69
69
  out.div **attr_code(id: clause["id"], class: "abstract") do |s|
70
- clause_name(clause, clause.at(ns("./title")), s,
70
+ clause_name(clause, clause.at(ns("./fmt-title")), s,
71
71
  { class: stylesmap[:AbstractTitle] })
72
- clause.elements.each { |e| parse(e, s) unless e.name == "title" }
72
+ clause.elements.each { |e| parse(e, s) unless e.name == "fmt-title" }
73
73
  end
74
74
  end
75
75
 
@@ -120,8 +120,7 @@ module IsoDoc
120
120
  formula_parse1(node, div)
121
121
  formula_where(node.at(ns("./dl")), div)
122
122
  node.children.each do |n|
123
- next if %w(stem dl name).include? n.name
124
-
123
+ %w(stem dl fmt-name).include? n.name and next
125
124
  parse(n, div)
126
125
  end
127
126
  end
@@ -132,8 +131,7 @@ module IsoDoc
132
131
  end
133
132
 
134
133
  def formula_where(dlist, out)
135
- return unless dlist
136
-
134
+ dlist or return
137
135
  dlist.elements.select { |n| dt_dd? n }.each_slice(2) do |dt, dd|
138
136
  formula_where1(out, dt, dd)
139
137
  end
@@ -158,33 +156,32 @@ module IsoDoc
158
156
  end
159
157
 
160
158
  def annex_name(_annex, name, div)
161
- return if name.nil?
162
-
163
- name&.at(ns("./strong"))&.remove # supplied by CSS list numbering
159
+ name.nil? and return
160
+ name&.at(ns(".//strong"))&.remove # supplied by CSS list numbering
164
161
  div.h1 class: "Annex" do |t|
165
- annex_name1(name, t)
162
+ # annex_name1(name, t)
163
+ children_parse(name, t)
166
164
  clause_parse_subtitle(name, t)
167
165
  end
168
166
  end
169
167
 
170
- def annex_name1(name, out)
171
- name.children.each do |c2|
172
- if c2.name == "span" && c2["class"] == "obligation"
173
- out.span style: "font-weight:normal;" do |s|
174
- c2.children.each { |c3| parse(c3, s) }
175
- end
176
- else parse(c2, out)
177
- end
168
+ def span_parse(node, out)
169
+ if node["class"] == "fmt-obligation"
170
+ node.delete("class")
171
+ node["style"] = "font-weight:normal;"
178
172
  end
173
+ super
179
174
  end
180
175
 
181
176
  def termnote_parse(node, out)
182
- name = node&.at(ns("./name"))&.remove
177
+ name = node.at(ns("./fmt-name"))
178
+ para = node.at(ns("./p"))
183
179
  out.div **note_attrs(node) do |div|
184
180
  div.p do |p|
185
181
  name and termnote_label(p, name)
186
- para_then_remainder(node.first_element_child, node, p, div)
182
+ children_parse(para, p)
187
183
  end
184
+ para.xpath("./following-sibling::*").each { |n| parse(n, div) }
188
185
  end
189
186
  end
190
187
 
@@ -197,14 +194,35 @@ module IsoDoc
197
194
  # STYLE
198
195
  def table_of_contents(clause, out)
199
196
  out.div class: "WordSectionContents" do |div|
200
- clause_name(clause, clause.at(ns("./title")), div,
197
+ clause_name(clause, clause.at(ns("./fmt-title")), div,
201
198
  { class: "IEEEStdsLevel1frontmatter" })
202
199
  clause.elements.each do |e|
203
- parse(e, div) unless e.name == "title"
200
+ parse(e, div) unless e.name == "fmt-title"
204
201
  end
205
202
  end
206
203
  end
207
204
 
205
+ # Figure 1— remove each of these
206
+ def figure_name_parse(_node, div, name)
207
+ name.nil? and return
208
+ name.at(".//xmlns:semx[@element = 'autonum']/"\
209
+ "preceding-sibling::*[normalize-space() = '']")&.remove
210
+ name.xpath(ns(".//span[@class = 'fmt-element-name'] | "\
211
+ ".//span[@class = 'fmt-caption-delim'] | "\
212
+ ".//semx[@element = 'autonum']")).each(&:remove)
213
+ super
214
+ end
215
+
216
+ def table_title_parse(node, out)
217
+ name = node.at(ns("./fmt-name")) or return
218
+ name.at(".//xmlns:semx[@element = 'autonum']/"\
219
+ "preceding-sibling::*[normalize-space() = '']")&.remove
220
+ name.xpath(ns(".//span[@class = 'fmt-element-name'] | "\
221
+ ".//span[@class = 'fmt-caption-delim'] | "\
222
+ ".//semx[@element = 'autonum']")).each(&:remove)
223
+ super
224
+ end
225
+
208
226
  include BaseConvert
209
227
  include Init
210
228
  end
@@ -85,10 +85,10 @@ module IsoDoc
85
85
  end
86
86
 
87
87
  def abstract_body(clause, out)
88
- clause_name(clause, clause.at(ns("./title")), out,
88
+ clause_name(clause, clause.at(ns("./fmt-title")), out,
89
89
  { class: stylesmap[:AbstractTitle],
90
90
  style: ABSTRACT_MARGIN })
91
- clause.elements.each { |e| parse(e, out) unless e.name == "title" }
91
+ clause.elements.each { |e| parse(e, out) unless e.name == "fmt-title" }
92
92
  end
93
93
 
94
94
  def clause(node, out)
@@ -98,9 +98,9 @@ module IsoDoc
98
98
 
99
99
  def figure_parse1(node, out)
100
100
  out.div **figure_attrs(node) do |div|
101
- figure_name_parse(node, div, node.at(ns("./name")))
101
+ figure_name_parse(node, div, node.at(ns("./fmt-name")))
102
102
  node.children.each do |n|
103
- parse(n, div) unless n.name == "name"
103
+ parse(n, div) unless n.name == "fmt-name"
104
104
  end
105
105
  end
106
106
  end
@@ -50,14 +50,13 @@ module IsoDoc
50
50
  "#{@klass.norm_ref_xpath} | //sections/terms | " \
51
51
  "//sections/definitions | //clause[parent::sections]"
52
52
  if @hierarchical_assets
53
- hierarchical_asset_names(doc.xpath("//xmlns:preface/child::*"),
54
- "Preface")
53
+ hierarchical_asset_names(doc.xpath("//xmlns:preface/child::*"), "Preface")
55
54
  doc.xpath(ns(middle_sections)).each do |c|
56
55
  hierarchical_asset_names(c, @anchors[c["id"]][:label])
57
56
  end
58
57
  else
59
- sequential_asset_names(doc.xpath(ns("//preface/*")))
60
- sequential_asset_names(doc.xpath(ns(middle_sections)))
58
+ sequential_asset_names(doc.xpath(ns("//preface/* | " + middle_sections)))
59
+ #sequential_asset_names(doc.xpath(ns(middle_sections)))
61
60
  end
62
61
  end
63
62
 
@@ -65,9 +64,9 @@ module IsoDoc
65
64
  c = Counter.new
66
65
  clause.xpath(ns(".//formula")).noblank.each do |t|
67
66
  @anchors[t["id"]] = anchor_struct(
68
- c.increment(t).print, container ? t : nil,
67
+ c.increment(t).print, t,
69
68
  t["inequality"] ? @labels["inequality"] : @labels["formula"],
70
- "formula", t["unnumbered"]
69
+ "formula", { container: container, unnumb: t["unnumbered"] }
71
70
  )
72
71
  end
73
72
  end
@@ -78,10 +77,20 @@ module IsoDoc
78
77
  sequence = UUIDTools::UUID.random_create.to_s
79
78
  notes = t.xpath(ns("./termnote"))
80
79
  notes.noblank.each do |n|
81
- @anchors[n["id"]] =
82
- anchor_struct("#{@labels['termnote']} #{increment_label(notes, n, c)}",
83
- n, @labels["note_xref"], "termnote", false)
80
+ @anchors[n["id"]] =
81
+ { label: termnote_label(n, increment_label(notes, n, c)), type: "termnote",
82
+ value: c.print, elem: @labels["termnote"],
83
+ container: t["id"],
84
+ xref: anchor_struct_xref(c.print, n, @labels["note_xref"]) }
85
+ .merge(sequence: sequence)
86
+ =begin
87
+ anchor_struct(
88
+ termnote_label(n, increment_label(notes, n, c)),
89
+ #labelled_autonum(@labels["termnote"], increment_label(notes, n, c)),
90
+ #"#{@labels['termnote']} #{increment_label(notes, n, c)}",
91
+ n, @labels["note_xref"], "termnote", { container: true })
84
92
  .merge(sequence: sequence)
93
+ =end
85
94
  end
86
95
  end
87
96
  end
@@ -93,7 +102,7 @@ module IsoDoc
93
102
 
94
103
  @anchors[n["id"]] =
95
104
  anchor_struct(increment_label(notes, n, counter), n,
96
- @labels["note_xref"], "note", false)
105
+ @labels["note_xref"], "note", { container: true })
97
106
  .merge(sequence: sequence)
98
107
  end
99
108
  end
@@ -102,9 +111,8 @@ module IsoDoc
102
111
  if @doctype == "whitepaper"
103
112
  title = Common::case_with_markup(@labels["annex"], "capital",
104
113
  @script)
105
- l10n("#{title} #{num}")
106
- else
107
- super.sub(%r{<br/>(.*)$}, "<br/><span class='obligation'>\\1</span>")
114
+ l10n(labelled_autonum(title, num))
115
+ else super
108
116
  end
109
117
  end
110
118
  end
@@ -1783,9 +1783,21 @@ that the `number` given for the series applies to the second iteration of number
1783
1783
  May be used to differentiate rendering of notes in bibliographies</a:documentation>
1784
1784
  </attribute>
1785
1785
  </optional>
1786
- <ref name="LocalizedMarkedUpString">
1786
+ <ref name="LocalizedStringAttributes">
1787
1787
  <a:documentation>The content of the note</a:documentation>
1788
1788
  </ref>
1789
+ <choice>
1790
+ <oneOrMore>
1791
+ <ref name="BasicBlockNoId">
1792
+ <a:documentation>Multiple blocks of content</a:documentation>
1793
+ </ref>
1794
+ </oneOrMore>
1795
+ <oneOrMore>
1796
+ <ref name="TextElement">
1797
+ <a:documentation>Single block of content</a:documentation>
1798
+ </ref>
1799
+ </oneOrMore>
1800
+ </choice>
1789
1801
  </element>
1790
1802
  </define>
1791
1803
  <define name="bibabstract">
@@ -235,7 +235,9 @@ module Metanorma
235
235
  def provenance_title1(updates, merges)
236
236
  ret = ""
237
237
  u = @isodoc.i18n.boolean_conj(tm_id_extract(updates), "and")
238
+ .gsub(%r{</?(conn|comma|enum-comma)>}, "")
238
239
  m = @isodoc.i18n.boolean_conj(tm_id_extract(merges), "and")
240
+ .gsub(%r{</?(conn|comma|enum-comma)>}, "")
239
241
  u.empty? or ret += "Revision of #{u}"
240
242
  !u.empty? && !m.empty? and ret += "<br/>"
241
243
  m.empty? or ret += "Incorporates #{m}"
@@ -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.4.0 -->
20
+ <!-- VERSION v1.4.1 -->
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">
@@ -326,7 +326,7 @@ normative or informative references, some split references into sections organiz
326
326
  <a:documentation>Content of note</a:documentation>
327
327
  <oneOrMore>
328
328
  <choice>
329
- <ref name="paragraph"/>
329
+ <ref name="paragraph-with-footnote"/>
330
330
  <ref name="ul"/>
331
331
  <ref name="ol"/>
332
332
  <ref name="dl"/>
@@ -412,7 +412,7 @@ normative or informative references, some split references into sections organiz
412
412
  <element name="note">
413
413
  <ref name="OptionalId"/>
414
414
  <oneOrMore>
415
- <ref name="paragraph"/>
415
+ <ref name="paragraph-with-footnote"/>
416
416
  </oneOrMore>
417
417
  </element>
418
418
  </define>
@@ -1977,7 +1977,7 @@ used in document amendments</a:documentation>
1977
1977
  <oneOrMore>
1978
1978
  <choice>
1979
1979
  <a:documentation>Content of the verbal representation of the term</a:documentation>
1980
- <ref name="paragraph"/>
1980
+ <ref name="paragraph-with-footnote"/>
1981
1981
  <ref name="dl"/>
1982
1982
  <ref name="ol"/>
1983
1983
  <ref name="ul"/>
@@ -2015,7 +2015,7 @@ used in document amendments</a:documentation>
2015
2015
  <oneOrMore>
2016
2016
  <choice>
2017
2017
  <a:documentation>Content of the term note</a:documentation>
2018
- <ref name="paragraph"/>
2018
+ <ref name="paragraph-with-footnote"/>
2019
2019
  <ref name="ul"/>
2020
2020
  <ref name="ol"/>
2021
2021
  <ref name="dl"/>
@@ -2037,7 +2037,7 @@ used in document amendments</a:documentation>
2037
2037
  <ref name="dl"/>
2038
2038
  <ref name="quote"/>
2039
2039
  <ref name="sourcecode"/>
2040
- <ref name="paragraph"/>
2040
+ <ref name="paragraph-with-footnote"/>
2041
2041
  <ref name="figure"/>
2042
2042
  </choice>
2043
2043
  </oneOrMore>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ieee
3
- VERSION = "1.3.4".freeze
3
+ VERSION = "1.3.6".freeze
4
4
  end
5
5
  end
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.require_paths = ["lib"]
26
26
  spec.required_ruby_version = Gem::Requirement.new(">= 3.1.0")
27
27
 
28
- spec.add_dependency "metanorma-standoc", "~> 2.10.0"
28
+ spec.add_dependency "metanorma-standoc", "~> 2.10.2"
29
29
  spec.add_dependency "mnconvert", "~> 1.20"
30
30
  spec.add_dependency "pubid"
31
31
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-ieee
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-11 00:00:00.000000000 Z
11
+ date: 2024-12-11 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.10.0
19
+ version: 2.10.2
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.10.0
26
+ version: 2.10.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mnconvert
29
29
  requirement: !ruby/object:Gem::Requirement