metanorma-ieee 1.5.4 → 1.5.5

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.
@@ -86,6 +86,7 @@ module IsoDoc
86
86
 
87
87
  def omit_docid_prefix(prefix)
88
88
  prefix == "DOI" and return true
89
+ prefix == "title" and return true
89
90
  super
90
91
  end
91
92
 
@@ -18,7 +18,7 @@ module IsoDoc
18
18
  # Style manual 19
19
19
  def anchor_linkend(node, linkend)
20
20
  if node["citeas"] && i = @bibanchors[node["bibitemid"]]
21
- biblio_anchor_linkend(node, i)
21
+ biblio_anchor_linkend(node, i, linkend)
22
22
  elsif node["citeas"] && (i = @normrefanchors[node["bibitemid"]])
23
23
  cit = normref_anchor_linkend(node, i)
24
24
  cit || super
@@ -28,28 +28,47 @@ module IsoDoc
28
28
 
29
29
  # force Author-Date referencing on non-standards in norm ref
30
30
  def normref_anchor_linkend(node, bib)
31
- @ref_renderings or return nil
32
- %w(techreport standard).include?(bib[:type]) and return nil
31
+ @ref_renderings or return nil
32
+ %w(standard).include?(bib[:type]) and return nil
33
33
  cit = @ref_renderings[node["bibitemid"]][:citation]&.strip
34
34
  cit.empty? and cit = nil
35
35
  cit
36
36
  end
37
37
 
38
- def biblio_anchor_linkend(node, bib)
39
- if %w(techreport standard).include?(bib[:type])
40
- if !node.children.empty?
41
- to_xml(node.children).strip
42
- elsif node["citeas"] == bib[:ord] then node["citeas"]
43
- else [node["citeas"], bib[:ord]].compact.join(" ")
44
- end
38
+ def biblio_anchor_linkend(node, bib, linkend)
39
+ if %w(standard).include?(bib[:type])
40
+ biblio_anchor_linkend_std(node, bib, linkend)
45
41
  else biblio_anchor_linkend_nonstd(node, bib)
46
42
  end
47
43
  end
48
44
 
45
+ def linkend_content(node)
46
+ c1 = non_locality_elems(node).select { |c| !c.text? || /\S/.match(c) }
47
+ c2 = node.xpath(ns("./locality | ./localityStack"))
48
+ [c1, c2]
49
+ end
50
+
51
+ def biblio_anchor_linkend_std(node, bib, linkend)
52
+ c1, c2 = linkend_content(node)
53
+ node["style"] == "no-biblio-tag" or tag = bib[:ord]
54
+ if !c1.empty?
55
+ c2.each(&:remove)
56
+ c1.map(&:to_xml).join
57
+ elsif node.at(ns("./location"))
58
+ linkend
59
+ elsif node["citeas"] == bib[:ord] then node["citeas"]
60
+ else [linkend, tag].compact.join(" ")
61
+ end
62
+ end
63
+
49
64
  def biblio_anchor_linkend_nonstd(node, bib)
65
+ c1, c2 = linkend_content(node)
50
66
  node["style"] == "no-biblio-tag" or tag = node["citeas"]
51
- if !node.children.empty?
52
- "#{to_xml(node.children)} #{tag}".strip
67
+ if !c1.empty?
68
+ c2.each(&:remove)
69
+ "#{c1.map(&:to_xml).join} #{tag}".strip
70
+ elsif node.at(ns("./location"))
71
+ tag
53
72
  elsif node["style"] == "title" && bib[:title]
54
73
  "#{bib[:title]} #{tag}".strip
55
74
  elsif bib[:author] # default, also if node["style"] == "title"
@@ -125,11 +125,7 @@ module IsoDoc
125
125
  end
126
126
  end
127
127
 
128
- def middle_title(docxml)
129
- s = middle_title_insert(docxml) or return
130
- s.previous = middle_title_body
131
- end
132
-
128
+ # KILL
133
129
  def middle_title_body
134
130
  ret = "<p class='zzSTDTitle1'>#{@meta.get[:full_doctitle]}"
135
131
  @meta.get[:amd] || @meta.get[:corr] and ret += "<br/>"
@@ -140,9 +136,14 @@ module IsoDoc
140
136
  ret
141
137
  end
142
138
 
143
- def middle_title_insert(docxml)
144
- s = docxml.at(ns("//sections")) or return
145
- s.children.first
139
+ def middle_title_template
140
+ <<~OUTPUT
141
+ <p class='zzSTDTitle1'>{{ full_doctitle -}}
142
+ {% if amd or corr %}<br/>{% endif -%}
143
+ {% if amd %}Amendment {{ amd }}{% endif -%}
144
+ {% if amd and corr %}&#x20;{% endif -%}
145
+ {% if corr %}Corrigenda {{ corr }}{% endif %}</p>
146
+ OUTPUT
146
147
  end
147
148
 
148
149
  def preface_rearrange(doc)
@@ -95,14 +95,13 @@ module Metanorma
95
95
  end
96
96
 
97
97
  def boilerplate_isodoc(xmldoc)
98
- x = xmldoc.dup
99
- x.root.add_namespace(nil, xml_namespace)
98
+ x = dup_with_namespace(xmldoc.root)
100
99
  xml = Nokogiri::XML(x.to_xml)
101
- i = isodoc(@lang, @script, @locale)
102
- i.bibdata_i18n(xml.at("//xmlns:bibdata"))
103
- i.localdir = @localdir
104
- i.info(xml, nil)
105
- i
100
+ @isodoc ||= isodoc(@lang, @script, @locale)
101
+ @isodoc.bibdata_i18n(xml.at("//xmlns:bibdata"))
102
+ @isodoc.localdir = @localdir
103
+ @isodoc.info(xml, nil)
104
+ @isodoc
106
105
  end
107
106
 
108
107
  def text_from_paras(node)
@@ -113,10 +112,18 @@ module Metanorma
113
112
  def bibdata_cleanup(xmldoc)
114
113
  super
115
114
  draft_id(xmldoc)
115
+ main_title(xmldoc)
116
116
  prefixed_title(xmldoc)
117
117
  provenance_title(xmldoc)
118
118
  end
119
119
 
120
+ def main_title(xmldoc)
121
+ t = xmldoc.at("//bibdata/title[@type = 'main']") and
122
+ t["type"] = "title-main"
123
+ t = xmldoc.at("//bibdata/title[@type = 'title-full']") and
124
+ t["type"] = "main"
125
+ end
126
+
120
127
  def prefixed_title(xmldoc)
121
128
  t, stage, trial = prefixed_title_prep(xmldoc)
122
129
  %w(main title-abbrev).reverse_each do |type|
@@ -40,15 +40,15 @@ module Metanorma
40
40
 
41
41
  def designator_or_name(bib)
42
42
  id = designator_docid(bib)
43
- ret = case bib["type"]
44
- when "standard", "techreport" then id
45
- else
46
- bib1 = bib.dup
47
- bib1.add_namespace(nil, xml_namespace)
48
- n = @i.creatornames(bib1)
49
- n.nil? && bib["type"].nil? and n = id
50
- n
51
- end
43
+ if %w(standard techreport).include?(bib["type"]) && id != "ZZZZ" &&
44
+ id != bib.at("./docidentifier[@type='metanorma']")&.text
45
+ ret = id
46
+ else
47
+ bib1 = dup_with_namespace(bib)
48
+ n = @i.creatornames(bib1)
49
+ n.nil? && bib["type"].nil? and n = id
50
+ ret = n
51
+ end
52
52
  [ret, id]
53
53
  end
54
54
 
@@ -121,6 +121,10 @@ module Metanorma
121
121
  "@type = 'metanorma-ordinal']")
122
122
  if /^\[?\d+\]?$/.match?(docid&.text)
123
123
  docid.children = "[B#{idx}]"
124
+ # fix metanorma to metanorma-ordinal if designation supplied
125
+ if bib.at("./docidentifier[@type = 'title']")
126
+ docid["type"] = "metanorma-ordinal"
127
+ end
124
128
  elsif docid = bib.at("./docidentifier") || bib.at("./title[last()]") ||
125
129
  bib.at("./formattedref")
126
130
  docid.next =
@@ -130,7 +134,7 @@ module Metanorma
130
134
 
131
135
  def select_docid(ref, type = nil)
132
136
  ret = super
133
- if %w(standard techreport).include?(ref["type"]) then ret
137
+ if %w(standard).include?(ref["type"]) then ret
134
138
  else
135
139
  ref.at("./docidentifier[@type = 'metanorma-ordinal']") || ret
136
140
  end
@@ -143,6 +147,22 @@ module Metanorma
143
147
 
144
148
  def bibitem_cleanup(xmldoc)
145
149
  super
150
+ supply_designations(xmldoc)
151
+ supply_withdrawn_notes(xmldoc)
152
+ end
153
+
154
+ # force existence of a designation for standards
155
+ def supply_designations(xmldoc)
156
+ xmldoc.xpath("//references/bibitem[@type = 'standard']").each do |b|
157
+ b.at("./docidentifier[not(@type = 'metanorma' or @type = 'DOI' or " \
158
+ "@type = 'metanorma-ordinal')]") and next
159
+ t = b.at("./title") or next
160
+ b.at("./title[last()]").next =
161
+ "<docidentifier type='title' primary='true'>#{t.text}</docidentifier>"
162
+ end
163
+ end
164
+
165
+ def supply_withdrawn_notes(xmldoc)
146
166
  f = File.join(File.dirname(__FILE__), "ieee-footnotes.yaml")
147
167
  @provenance_notes = YAML.safe_load(File.read(f))
148
168
  withdrawn_note(xmldoc, @provenance_notes)
@@ -157,6 +177,11 @@ module Metanorma
157
177
  bib.xpath("./contributor[role/@type = 'publisher']/organization/name")
158
178
  .map(&:text)
159
179
  end
180
+
181
+ def reference_names(xmldoc)
182
+ #require "debug"; binding.b
183
+ super
184
+ end
160
185
  end
161
186
  end
162
187
  end
@@ -7,11 +7,11 @@ module Metanorma
7
7
 
8
8
  def sorted_bibitem_no_avail(xmldoc)
9
9
  # Get normative references first, maintaining their order
10
- normative_bibitems = xmldoc.xpath("//references[@normative='true']/bibitem[not(note[@type = 'Availability'])]")
11
-
12
- # Get non-normative references second, maintaining their order
13
- non_normative_bibitems = xmldoc.xpath("//references[@normative='false']/bibitem[not(note[@type = 'Availability'])]")
14
-
10
+ normative_bibitems = xmldoc.xpath("//references[@normative='true']/" \
11
+ "bibitem[not(note[@type = 'Availability'])]")
12
+ # Get non-normative references second, maintaining their order
13
+ non_normative_bibitems = xmldoc.xpath("//references[@normative='false']/" \
14
+ "bibitem[not(note[@type = 'Availability'])]")
15
15
  # Return concatenated array with normative first
16
16
  normative_bibitems.to_a + non_normative_bibitems.to_a
17
17
  end
@@ -37,7 +37,8 @@ module Metanorma
37
37
 
38
38
  def available_note(xmldoc, provenance_notes)
39
39
  bibitems = sorted_bibitem_no_avail(xmldoc)
40
- iso_iec_available_note(bibitems, provenance_notes["iso-iec"], true, true)
40
+ iso_iec_available_note(bibitems, provenance_notes["iso-iec"], true,
41
+ true)
41
42
  iso_iec_available_note(bibitems, provenance_notes["iso"], true, false)
42
43
  iso_iec_available_note(bibitems, provenance_notes["iec"], false, true)
43
44
  itu_available_note(bibitems, provenance_notes["itut"], true)
@@ -194,24 +194,12 @@ module Metanorma
194
194
  end
195
195
  end
196
196
 
197
- def title_english(node, xml)
198
- title = node.attr("title") || node.attr("title-en") ||
199
- node.attr("doctitle")
200
- title_english1(title, "title-main", xml)
201
- title_english1(node.attr("title-full"), "main", xml)
202
- title_english1(node.attr("title-abbrev"), "title-abbrev", xml)
203
- end
204
-
205
- def title_english1(title, type, xml)
206
- title.nil? and return
207
- at = { language: "en", format: "text/plain" }
208
- title = Metanorma::Utils::asciidoc_sub(title)
209
- xml.title **attr_code(at.merge(type: type)) do |t|
210
- t << title
211
- end
197
+ def title_other(node, xml)
198
+ t = node.attr("title-full") and
199
+ add_title_xml(xml, t, @lang, "title-full")
200
+ t = node.attr("title-abbrev") and
201
+ add_title_xml(xml, t, @lang, "title-abbrev")
212
202
  end
213
-
214
- def title_otherlangs(node, xml); end
215
203
  end
216
204
  end
217
205
  end
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <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">
3
- <!-- VERSION v2.1.2 -->
3
+ <!-- VERSION v2.1.3 -->
4
4
 
5
5
  <!--
6
6
  ALERT: cannot have root comments, because of https://github.com/metanorma/metanorma/issues/437
@@ -455,14 +455,7 @@ normative or informative references, some split references into sections organiz
455
455
  </ref>
456
456
  </zeroOrMore>
457
457
  <zeroOrMore>
458
- <ref name="doc_bibitem">
459
- <a:documentation>Bibliographic item cited in the document</a:documentation>
460
- </ref>
461
- <zeroOrMore>
462
- <ref name="note">
463
- <a:documentation>Annotation of the bibliographic item</a:documentation>
464
- </ref>
465
- </zeroOrMore>
458
+ <ref name="ReferenceEntry"/>
466
459
  </zeroOrMore>
467
460
  <zeroOrMore>
468
461
  <ref name="references">
@@ -604,18 +597,21 @@ gives an explicit page orientation</a:documentation>
604
597
  </element>
605
598
  </optional>
606
599
  </define>
607
- </include>
608
- <!-- end overrides -->
609
- <define name="FnAttributes" combine="interleave">
610
- <ref name="RequiredId"/>
611
- <optional>
612
- <attribute name="hiddenref">
613
- <a:documentation>If true, number the footnote as normal, but suppress display of the footnote reference in the document body.
600
+ <define name="FnAttributes">
601
+ <ref name="RequiredId"/>
602
+ <optional>
603
+ <attribute name="hiddenref">
604
+ <a:documentation>If true, number the footnote as normal, but suppress display of the footnote reference in the document body.
614
605
  This is done if the footnote reference is already presented in some other form, e.g. within a figure image.</a:documentation>
615
- <data type="boolean"/>
606
+ <data type="boolean"/>
607
+ </attribute>
608
+ </optional>
609
+ <attribute name="reference">
610
+ <a:documentation>The number of the footnote, used to identify it visually</a:documentation>
616
611
  </attribute>
617
- </optional>
618
- </define>
612
+ </define>
613
+ </include>
614
+ <!-- end overrides -->
619
615
  <define name="TdAttributes" combine="interleave">
620
616
  <ref name="RequiredId"/>
621
617
  <optional>
@@ -853,6 +849,17 @@ titlecase, or lowercase</a:documentation>
853
849
  <value>informative</value>
854
850
  </choice>
855
851
  </define>
852
+ <define name="ReferenceEntry">
853
+ <a:documentation>Entry in bibliography</a:documentation>
854
+ <ref name="doc_bibitem">
855
+ <a:documentation>Bibliographic item cited in the document</a:documentation>
856
+ </ref>
857
+ <zeroOrMore>
858
+ <ref name="note">
859
+ <a:documentation>Annotation of the bibliographic item</a:documentation>
860
+ </ref>
861
+ </zeroOrMore>
862
+ </define>
856
863
  <define name="doc_bibitem">
857
864
  <a:documentation>Standardisation document representation of bibliographic entry</a:documentation>
858
865
  <element name="bibitem">
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ieee
3
- VERSION = "1.5.4".freeze
3
+ VERSION = "1.5.5".freeze
4
4
  end
5
5
  end
@@ -3,13 +3,20 @@ nametemplate:
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
5
  etal: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }} ,_{{initials[0] | join: '. '}}.{% endif %} , {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{initials[1] | join: '. '}}. {{surname[1] }}{% endif %} , {% if nonpersonal[2] %}{{ nonpersonal[2] }}{% else %}{{initials[2] | join: '. '}}. {{surname[2] }}{% endif %} <em>et al.</em>"
6
- etal_count: 10
7
- etal_render: 7
6
+ etal_count: 6
7
+ etal_display: 3
8
+ authorcitetemplate:
9
+ one: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }} {% endif %}"
10
+ two: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }}{% endif %} , {{ labels['and'] }} {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{surname[1] }}{% endif %}"
11
+ more: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }}{% endif %} , {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{surname[1] }}{% endif %} , {{ labels['and'] }} {% if nonpersonal[2] %}{{ nonpersonal[2] }}{% else %}{{surname[2] }}{% endif %}"
12
+ etal: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }}{% endif %} , {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{surname[1] }}{% endif %} , {% if nonpersonal[2] %}{{ nonpersonal[2] }}{% else %}{{surname[2] }}{% endif %} <em>et al.</em>"
13
+ etal_count: 3
14
+ etal_display: 1
8
15
  extenttemplate:
9
16
  misc: "{{ volume }}, {{issue}}, {{ page }}, {{ duration }}"
10
17
  template:
11
18
  # skip authoritative_identifier, it is inserted in front of formattedref within metanorma
12
- standard: "{% if home_standard %}{{ title }}.{% else %}{{ creatornames }}, {{ title }},” {{ extent }}, {{ labels['version'] }}_{{ edition_raw }}, {{date}}, {{labels['updated'] | capitalize }}_{{date_updated}}, {{status }}, {{ authorizer }}, {% if uri %}{{ uri }}{% else %}{% if doi %}DOI: {{ doi | join: ', ' }}{% endif %}{% endif %} .{% endif %}"
19
+ standard: "{{ title }}{% if home_standard %}{%else%}, {% if uri %}{{ uri }}{% else %}{% if doi %}DOI: {{ doi | join: ', ' }}{% endif %}{% endif %}{% endif %}."
13
20
  article: "{{creatornames}}, “{{title}},” <em>{{ series }}</em>, {{ extent }}, {{ date }}, {{ labels['viewed'] }}_{{date_accessed}}, {% if uri %}{{ uri }}{% else %}{% if doi %}DOI: {{ doi | join: ', ' }}{% endif %}{% endif %} ."
14
21
  book: "{{creatornames}}, <em>{{title}}</em>, {{ edition }}, {{place}}: {{publisher}}, {{date}}, {{ labels['viewed'] }}_{{date_accessed}}, {% if uri %}{{ uri }}{% else %}{% if doi %}DOI: {{ doi | join: ', ' }}{% endif %}{% endif %} ."
15
22
  techreport: book
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.5.4
4
+ version: 1.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-09-01 00:00:00.000000000 Z
11
+ date: 2025-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc