metanorma-ieee 0.1.3 → 1.0.1

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.
@@ -94,7 +94,7 @@ module IsoDoc
94
94
  set(:full_doctitle, fulltitle(@metadata[:doctype], draft))
95
95
  set(:abbrev_doctitle, fulltitle(@metadata[:doctype_abbrev], draft))
96
96
  prov = isoxml&.at(ns("//bibdata/title[@type='provenance']")) and
97
- set(:provenance_doctitle, prov.children.to_xml)
97
+ set(:provenance_doctitle, Common::to_xml(prov.children))
98
98
  end
99
99
 
100
100
  def fulltitle(type, draft)
@@ -14,7 +14,7 @@ module IsoDoc
14
14
 
15
15
  def biblio_anchor_linkend(node, bib)
16
16
  if %w(techreport standard).include?(bib[:type])
17
- node["citeas"] + " #{bib[:ord]}"
17
+ [node["citeas"], bib[:ord]].compact.join(" ")
18
18
  else
19
19
  "#{bib[:author]} " + node["citeas"]
20
20
  end
@@ -30,7 +30,7 @@ module IsoDoc
30
30
  author: @author[b["id"]] || (b.at(ns("./title")) ||
31
31
  b.at(ns("./formattedref")))&.text,
32
32
  ord: b.at(ns("./docidentifier[@type = 'metanorma' or "\
33
- "@type = 'metanorma-ordinal']")).text }
33
+ "@type = 'metanorma-ordinal']"))&.text }
34
34
  end
35
35
  end
36
36
 
@@ -26,19 +26,19 @@ module IsoDoc
26
26
  if coll.all? do |c|
27
27
  c.elements.size == 1 && c.elements.first.name == "p"
28
28
  end
29
- ret = coll.map { |c| c.elements.first.children.to_xml }
29
+ ret = coll.map { |c| to_xml(c.elements.first.children) }
30
30
  return "<p>#{ret.join}</p>"
31
31
  end
32
- coll.map { |c| c.children.to_xml }.join
32
+ coll.map { |c| to_xml(c.children) }.join
33
33
  end
34
34
 
35
35
  def unwrap_definition(docxml)
36
- docxml.xpath(ns("//definition/verbal-definition")).each do |v|
36
+ docxml.xpath(ns(".//definition/verbal-definition")).each do |v|
37
37
  next unless v.elements.all? { |e| %w(termsource p).include?(e.name) }
38
38
 
39
39
  p = v.xpath(ns("./p"))
40
40
  v.children =
41
- "<p>#{p.map(&:children).map(&:to_xml).join("\n")}</p>" \
41
+ "<p>#{p.map(&:children).map { |x| to_xml(x) }.join("\n")}</p>" \
42
42
  "#{v.xpath(ns('./termsource')).to_xml}"
43
43
  end
44
44
  super
@@ -60,8 +60,8 @@ module IsoDoc
60
60
  prev = i and next
61
61
  end
62
62
 
63
- coll[prev].at(ns("./preferred")) << "; #{r.at(ns('./preferred'))
64
- .children.to_xml}"
63
+ coll[prev].at(ns("./preferred")) << "; #{to_xml(r.at(ns('./preferred'))
64
+ .children)}"
65
65
  r.remove
66
66
  end
67
67
  end
@@ -129,10 +129,10 @@ module IsoDoc
129
129
  new = adm.dup
130
130
  adm["type"] = "equivalent"
131
131
  adm.name = "related"
132
- adm.children = "<preferred>#{adm.children.to_xml}</preferred>"
132
+ adm.children = "<preferred>#{to_xml(adm.children)}</preferred>"
133
133
  adm.parent.next = <<~TERM
134
- <term><preferred>#{new.children.to_xml}</preferred>
135
- <related type='see'><preferred>#{pref.children.to_xml}</preferred></related></term>
134
+ <term><preferred>#{to_xml(new.children)}</preferred>
135
+ <related type='see'><preferred>#{to_xml(pref.children)}</preferred></related></term>
136
136
  TERM
137
137
  end
138
138
 
@@ -172,8 +172,8 @@ module IsoDoc
172
172
  def collapse_term_related(rels)
173
173
  ret = rels.map do |r|
174
174
  p = r.at(ns("./preferred"))
175
- "<em>#{@i18n.relatedterms[r['type']]}:</em> " \
176
- "#{p&.children&.to_xml || '**RELATED TERM NOT FOUND**'}"
175
+ rel = p ? to_xml(p.children) : "**RELATED TERM NOT FOUND**"
176
+ "<em>#{@i18n.relatedterms[r['type']]}:</em> #{rel}"
177
177
  end.join(". ")
178
178
  ret += "." unless ret.empty?
179
179
  ret
@@ -182,10 +182,10 @@ module IsoDoc
182
182
  def collapse_term_template(opt)
183
183
  defn = collapse_unwrap_definition(opt[:def])
184
184
  src = nil
185
- opt[:source] and src = "(#{opt[:source].remove.children.to_xml.strip})"
185
+ opt[:source] and src = "(#{to_xml(opt[:source].remove.children).strip})"
186
+ t = opt[:pref] ? to_xml(opt[:pref].children) : "**TERM NOT FOUND**"
186
187
  <<~TERM
187
- <p>#{opt[:pref]&.children&.to_xml || '**TERM NOT FOUND**'}: #{defn}
188
- #{collapse_term_related(opt[:rels])} #{src}</p>
188
+ <p>#{t}: #{defn} #{collapse_term_related(opt[:rels])} #{src}</p>
189
189
  TERM
190
190
  end
191
191
 
@@ -194,7 +194,8 @@ module IsoDoc
194
194
 
195
195
  s = defn.remove.xpath(ns("./termsource"))
196
196
  p = defn.at(ns("./p"))
197
- !s.empty? && p and p << s.map(&:remove).map(&:children).map(&:to_xml).join
197
+ !s.empty? && p and p << s.map(&:remove).map(&:children)
198
+ .map { |x| to_xml(x) }.join
198
199
  if defn.elements.size == 1 && defn.elements.first.name == "p"
199
200
  defn.elements.first.children
200
201
  else defn.elements
@@ -203,10 +204,10 @@ module IsoDoc
203
204
 
204
205
  def termsource1(elem)
205
206
  while elem&.next_element&.name == "termsource"
206
- elem << "; #{elem.next_element.remove.children.to_xml}"
207
+ elem << "; #{to_xml(elem.next_element.remove.children)}"
207
208
  end
208
209
  adapt = termsource_adapt(elem["status"]) and
209
- elem.children = l10n("#{adapt}#{elem.children.to_xml.strip}")
210
+ elem.children = l10n("#{adapt}#{to_xml(elem.children).strip}")
210
211
  end
211
212
 
212
213
  def termsource_adapt(status)
@@ -218,7 +219,7 @@ module IsoDoc
218
219
  def designation_field(desgn, name)
219
220
  if desgn.name == "preferred"
220
221
  f = desgn.xpath(ns("./../domain | ./../subject")).map(&:remove)
221
- .map { |u| u.children.to_xml }.join(", ")
222
+ .map { |u| to_xml(u.children) }.join(", ")
222
223
  name << ", &#x3c;#{f}&#x3e;" unless f.empty?
223
224
  end
224
225
  super
@@ -231,7 +232,7 @@ module IsoDoc
231
232
  "./admitted[expression/name][abbreviation-type]"))
232
233
  (pref && !x.empty?) or return
233
234
  tail = x.map do |p|
234
- p.remove.at(ns("./expression/name")).children.to_xml.strip
235
+ to_xml(p.remove.at(ns("./expression/name")).children).strip
235
236
  end.join(", ")
236
237
  pref << " (#{tail})"
237
238
  end
@@ -244,7 +245,7 @@ module IsoDoc
244
245
  def term(docxml); end
245
246
 
246
247
  def concept1(node)
247
- concept_render(node, ital: "false", ref: "false",
248
+ concept_render(node, ital: "false", ref: "false", bold: "false",
248
249
  linkref: "false", linkmention: "false")
249
250
  end
250
251
  end
@@ -17,9 +17,10 @@ module IsoDoc
17
17
  ret = resolve_eref_connectives(eref_locality_stacks(refs, target,
18
18
  node))
19
19
  node["droploc"] = droploc
20
- eref_localities1(target,
21
- prefix_clause(target, refs.first.at(ns("./locality"))),
22
- l10n(ret[1..-1].join), nil, node, @lang)
20
+ eref_localities1({ target: target, number: "pl",
21
+ type: prefix_clause(target, refs.first.at(ns("./locality"))),
22
+ from: l10n(ret[1..-1].join), node: node,
23
+ lang: @lang })
23
24
  end
24
25
 
25
26
  def prefix_clause(target, loc)
@@ -37,20 +38,18 @@ module IsoDoc
37
38
  target&.gsub(/<[^>]+>/, "")&.match(/^IEV$|^IEC 60050-/)
38
39
  end
39
40
 
40
- def eref_localities1(target, type, from, upto, node, lang = "en")
41
- return nil if type == "anchor"
41
+ def eref_localities1(opt)
42
+ return nil if opt[:type] == "anchor"
42
43
 
43
- type = type.downcase
44
- lang == "zh" and
45
- return l10n(eref_localities1_zh(target, type, from, upto,
46
- node))
44
+ opt[:type] = opt[:type].downcase
45
+ opt[:lang] == "zh" and return l10n(eref_localities1_zh(opt))
47
46
  ret = ""
48
- node["droploc"] != "true" && !subclause?(target, type,
49
- from) and
50
- ret = eref_locality_populate(type, node)
51
- ret += " #{from}" if from
52
- ret += "&#x2013;#{upto}" if upto
53
- ret += ")" if type == "list"
47
+ opt[:node]["droploc"] != "true" &&
48
+ !subclause?(opt[:target], opt[:type], opt[:from]) and
49
+ ret = eref_locality_populate(opt[:type], opt[:node], opt[:number])
50
+ ret += " #{opt[:from]}" if opt[:from]
51
+ ret += "&#x2013;#{opt[:upto]}" if opt[:upto]
52
+ ret += ")" if opt[:type] == "list"
54
53
  l10n(ret)
55
54
  end
56
55
 
@@ -85,7 +84,7 @@ module IsoDoc
85
84
  i = display_order_xpath(docxml, "//preface/*", i)
86
85
  i = display_order_at(docxml, "//clause[@type = 'overview']", i)
87
86
  i = display_order_at(docxml, @xrefs.klass.norm_ref_xpath, i)
88
- i = display_order_at(docxml, "//sections/terms | "\
87
+ i = display_order_at(docxml, "//sections/terms | " \
89
88
  "//sections/clause[descendant::terms]", i)
90
89
  i = display_order_at(docxml, "//sections/definitions", i)
91
90
  i = display_order_xpath(docxml, @xrefs.klass.middle_clause(docxml), i)
@@ -97,7 +96,7 @@ module IsoDoc
97
96
  def annex1(elem)
98
97
  lbl = @xrefs.anchor(elem["id"], :label)
99
98
  if t = elem.at(ns("./title"))
100
- t.children = "<strong>#{t.children.to_xml}</strong>"
99
+ t.children = "<strong>#{to_xml(t.children)}</strong>"
101
100
  end
102
101
  prefix_name(elem, "<br/>", lbl, "title")
103
102
  end
@@ -132,7 +131,7 @@ module IsoDoc
132
131
 
133
132
  def amend1(elem)
134
133
  elem.xpath(ns("./description/p")).each do |p|
135
- p.children = p.children.to_xml.strip
134
+ p.children = to_xml(p.children).strip
136
135
  amend_format(p)
137
136
  end
138
137
  super
@@ -144,7 +143,7 @@ module IsoDoc
144
143
  %(em strong).include?(para.children.first.name) and
145
144
  para.children = para.elements.first.children
146
145
  end
147
- para.children = "<strong><em>#{para.children.to_xml}</em></strong>"
146
+ para.children = "<strong><em>#{to_xml(para.children)}</em></strong>"
148
147
  end
149
148
 
150
149
  def section(docxml)
@@ -153,7 +152,7 @@ module IsoDoc
153
152
  end
154
153
 
155
154
  def boilerplate(docxml)
156
- docxml.xpath(ns("//clause[@id = 'boilerplate-participants']/"\
155
+ docxml.xpath(ns("//clause[@id = 'boilerplate-participants']/" \
157
156
  "clause/title")).each(&:remove)
158
157
  docxml.xpath(ns("//clause[@id = 'boilerplate-participants']/clause"))
159
158
  .each do |clause|
@@ -211,7 +210,7 @@ module IsoDoc
211
210
  def participant_officeholder_para(map, name, idx)
212
211
  name = "<strong>#{name}</strong>" if idx.zero?
213
212
  br = map["role"].size > 30 ? "<br/>" : ""
214
- "<p type='officeholder' align='center'>#{name}, #{br}"\
213
+ "<p type='officeholder' align='center'>#{name}, #{br}" \
215
214
  "<em>#{map['role']}</em></p>"
216
215
  end
217
216
 
@@ -15,7 +15,7 @@ module IsoDoc
15
15
  feedback_table(docxml)
16
16
  f = docxml.at("//div[@class = 'boilerplate-feedback']") or return
17
17
  docxml.at("//aside").previous = <<~FN
18
- <aside id="ftn0">#{f.remove.to_xml}</aside>
18
+ <aside id="ftn0">#{to_xml(f.remove)}</aside>
19
19
  FN
20
20
  end
21
21
 
@@ -103,7 +103,7 @@ module IsoDoc
103
103
  div.xpath(".//div").each { |d| d.replace(d.children) }
104
104
  div.elements.each_with_object([[]]) do |e, m|
105
105
  member = e.name == "p" && e["type"] == "officemember"
106
- (prev == member and m[-1] << e.to_xml) or m << [e.to_xml]
106
+ (prev == member and m[-1] << to_xml(e)) or m << [to_xml(e)]
107
107
  prev = member
108
108
  end.map(&:join)
109
109
  end
@@ -143,7 +143,7 @@ module IsoDoc
143
143
  i.zero? or div.elements.first.previous = "<p>&#xa0;</p>"
144
144
  i == 4 and
145
145
  div.xpath(".//p[br]").each do |p|
146
- p.replace(p.to_xml.gsub(%r{<br/>}, "</p><p>"))
146
+ p.replace(to_xml(p).gsub(%r{<br/>}, "</p><p>"))
147
147
  end
148
148
  feedback_style1(div, i)
149
149
  end
@@ -17,6 +17,10 @@ module IsoDoc
17
17
  @wordstylesheet.unlink if @wordstylesheet.is_a?(Tempfile)
18
18
  end
19
19
 
20
+ def sourcecode_style
21
+ "IEEEStdsComputerCode"
22
+ end
23
+
20
24
  def word_cleanup(docxml)
21
25
  super
22
26
  abstract_cleanup(docxml)
@@ -28,7 +28,7 @@ module IsoDoc
28
28
  end
29
29
  else
30
30
  t.children =
31
- "<p class='IEEEStdsTableColumnHead'>#{t.children.to_xml}</p>"
31
+ "<p class='IEEEStdsTableColumnHead'>#{to_xml(t.children)}</p>"
32
32
  end
33
33
  end
34
34
  end
@@ -45,9 +45,9 @@ module IsoDoc
45
45
 
46
46
  def tbody_head_cleanup(cell)
47
47
  cell.at("./p") or
48
- cell.children = "<p>#{cell.children.to_xml}</p>"
48
+ cell.children = "<p>#{to_xml(cell.children)}</p>"
49
49
  cell.xpath("./p").each do |p|
50
- p.replace p.to_xml.gsub(%r{<br/>}, "</p><p>")
50
+ p.replace to_xml(p).gsub(%r{<br/>}, "</p><p>")
51
51
  end
52
52
  end
53
53
 
@@ -58,7 +58,7 @@ module IsoDoc
58
58
  end
59
59
  else
60
60
  cell.children =
61
- "<p class='#{td_style(cell, 0)}'>#{cell.children.to_xml}</p>"
61
+ "<p class='#{td_style(cell, 0)}'>#{to_xml(cell.children)}</p>"
62
62
  end
63
63
  end
64
64
 
@@ -80,28 +80,28 @@ module IsoDoc
80
80
 
81
81
  def table_caption(docxml)
82
82
  docxml.xpath("//p[@class = 'TableTitle']").each do |s|
83
- s.children = s.children.to_xml
83
+ s.children = to_xml(s.children)
84
84
  .sub(/^#{@i18n.table}(\s+[A-Z0-9.]+)?/, "")
85
85
  end
86
86
  end
87
87
 
88
88
  def figure_caption(docxml)
89
89
  docxml.xpath("//p[@class = 'FigureTitle']").each do |s|
90
- s.children = s.children.to_xml
90
+ s.children = to_xml(s.children)
91
91
  .sub(/^#{@i18n.figure}(\s+[A-Z0-9.]+)?/, "")
92
92
  end
93
93
  end
94
94
 
95
95
  def example_caption(docxml)
96
96
  docxml.xpath("//p[@class = 'example-title']").each do |s|
97
- s.children = "<em>#{s.children.to_xml}</em>"
97
+ s.children = "<em>#{to_xml(s.children)}</em>"
98
98
  s["class"] = "IEEEStdsParagraph"
99
99
  end
100
100
  end
101
101
 
102
102
  def sourcecode_cleanup(docxml)
103
103
  docxml.xpath("//p[@class = 'Sourcecode']").each do |s|
104
- s.replace(s.to_xml.gsub(%r{<br/>}, "</p><p class='Sourcecode'>"))
104
+ s.replace(to_xml(s).gsub(%r{<br/>}, "</p><p class='Sourcecode'>"))
105
105
  end
106
106
  end
107
107
 
@@ -683,6 +683,9 @@
683
683
  </define>
684
684
  <define name="underline">
685
685
  <element name="underline">
686
+ <optional>
687
+ <attribute name="style"/>
688
+ </optional>
686
689
  <zeroOrMore>
687
690
  <ref name="PureTextElement"/>
688
691
  </zeroOrMore>
@@ -47,7 +47,7 @@
47
47
  </element>
48
48
  </define>
49
49
  <define name="DocumentType">
50
- <value>document</value>
50
+ <text/>
51
51
  </define>
52
52
  <define name="docsubtype">
53
53
  <element name="subdoctype">
@@ -571,6 +571,11 @@
571
571
  <ref name="MultilingualRenderingType"/>
572
572
  </attribute>
573
573
  </optional>
574
+ <optional>
575
+ <attribute name="linenums">
576
+ <data type="boolean"/>
577
+ </attribute>
578
+ </optional>
574
579
  <optional>
575
580
  <ref name="tname"/>
576
581
  </optional>
@@ -1238,6 +1243,11 @@
1238
1243
  </define>
1239
1244
  <define name="concept">
1240
1245
  <element name="concept">
1246
+ <optional>
1247
+ <attribute name="bold">
1248
+ <data type="boolean"/>
1249
+ </attribute>
1250
+ </optional>
1241
1251
  <optional>
1242
1252
  <attribute name="ital">
1243
1253
  <data type="boolean"/>
@@ -2653,6 +2663,7 @@
2653
2663
  <value>full</value>
2654
2664
  <value>short</value>
2655
2665
  <value>id</value>
2666
+ <text/>
2656
2667
  </choice>
2657
2668
  </define>
2658
2669
  <define name="erefTypeWithConnective">
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module IEEE
3
- VERSION = "0.1.3".freeze
3
+ VERSION = "1.0.1".freeze
4
4
  end
5
5
  end
@@ -2,6 +2,8 @@ nametemplate:
2
2
  one: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }} ,_{{initials[0] | join: '. '}} {% endif %}"
3
3
  two: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }} ,_{{initials[0] | join: '. '}}.{% endif %} , {{ labels['and'] }} {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{initials[1] | join: '. '}}. {{surname[1] }}{% endif %}"
4
4
  more: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }} ,_{{initials[0] | join: '. '}}.{% endif %} , {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{initials[1] | join: '. '}}. {{surname[1] }}{% endif %} , {{ labels['and'] }} {% if nonpersonal[2] %}{{ nonpersonal[2] }}{% else %}{{initials[2] | join: '. '}}. {{surname[2] }}{% endif %}"
5
+ etal_count: 10
6
+ etal_render: 7
5
7
  extenttemplate:
6
8
  misc: "{{ volume }}, {{issue}}, {{ page }}, {{ duration }}"
7
9
  template:
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.require_paths = ["lib"]
26
26
  spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
27
27
 
28
- spec.add_dependency "metanorma-standoc", "~> 2.2.4"
28
+ spec.add_dependency "metanorma-standoc", "~> 2.3.0"
29
29
  spec.add_dependency "mnconvert", "~> 1.20"
30
30
 
31
31
  spec.add_development_dependency "debug"
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: 0.1.3
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-11-21 00:00:00.000000000 Z
11
+ date: 2022-12-19 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.2.4
19
+ version: 2.3.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.2.4
26
+ version: 2.3.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mnconvert
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -299,7 +299,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
299
299
  - !ruby/object:Gem::Version
300
300
  version: '0'
301
301
  requirements: []
302
- rubygems_version: 3.3.7
302
+ rubygems_version: 3.3.26
303
303
  signing_key:
304
304
  specification_version: 4
305
305
  summary: Metanorma for the IEEE