metanorma-ieee 1.5.3 → 1.5.4

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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/isodoc/ieee/html/header.html +3 -3
  3. data/lib/isodoc/ieee/html/html_ieee_titlepage.html +15 -2
  4. data/lib/isodoc/ieee/html/ieee.css +46 -1
  5. data/lib/isodoc/ieee/html/ieee.scss +42 -1
  6. data/lib/isodoc/ieee/html/word_ieee_titlepage.html +10 -2
  7. data/lib/isodoc/ieee/html/wordstyle.css +48 -0
  8. data/lib/isodoc/ieee/html/wordstyle.scss +44 -0
  9. data/lib/isodoc/ieee/html/wordstyle_wp.css +47 -0
  10. data/lib/isodoc/ieee/html/wordstyle_wp.scss +43 -0
  11. data/lib/isodoc/ieee/i18n-en.yaml +2 -0
  12. data/lib/isodoc/ieee/ieee.amendment.xsl +1131 -438
  13. data/lib/isodoc/ieee/ieee.standard.xsl +1131 -438
  14. data/lib/isodoc/ieee/metadata.rb +22 -11
  15. data/lib/isodoc/ieee/presentation_bibitem.rb +102 -0
  16. data/lib/isodoc/ieee/presentation_ref.rb +149 -96
  17. data/lib/isodoc/ieee/presentation_terms.rb +52 -12
  18. data/lib/isodoc/ieee/presentation_xml_convert.rb +15 -67
  19. data/lib/isodoc/ieee/word_authority.rb +37 -59
  20. data/lib/isodoc/ieee/word_cleanup.rb +83 -35
  21. data/lib/isodoc/ieee/word_cleanup_blocks.rb +0 -1
  22. data/lib/isodoc/ieee/word_convert.rb +19 -16
  23. data/lib/isodoc/ieee/word_toc.rb +46 -0
  24. data/lib/metanorma/ieee/boilerplate.adoc +6 -5
  25. data/lib/metanorma/ieee/boilerplate_wp.adoc +1 -2
  26. data/lib/metanorma/ieee/cleanup.rb +56 -9
  27. data/lib/metanorma/ieee/cleanup_boilerplate.rb +1 -4
  28. data/lib/metanorma/ieee/cleanup_ref.rb +0 -98
  29. data/lib/metanorma/ieee/cleanup_ref_fn.rb +116 -0
  30. data/lib/metanorma/ieee/front.rb +26 -0
  31. data/lib/metanorma/ieee/isodoc.rng +19 -1
  32. data/lib/metanorma/ieee/processor.rb +1 -0
  33. data/lib/metanorma/ieee/relaton-ieee.rng +4 -0
  34. data/lib/metanorma/ieee/validate.rb +1 -1
  35. data/lib/metanorma/ieee/version.rb +1 -1
  36. metadata +5 -2
@@ -65,7 +65,7 @@ module IsoDoc
65
65
  <span lang="EN-US" style='font-size:9.0pt;mso-bidi-font-size:10.0pt;font-family:
66
66
  "Times New Roman",serif;mso-fareast-font-family:"Times New Roman";mso-ansi-language:
67
67
  EN-US;mso-fareast-language:JA;mso-bidi-language:AR-SA'><br clear="all"
68
- style='page-break-before:auto;mso-break-type:section-break'></span>
68
+ style='page-break-before:auto;mso-break-type:section-break'/></span>
69
69
  BREAK
70
70
 
71
71
  def officemember_style(docxml)
@@ -98,13 +98,40 @@ module IsoDoc
98
98
  end
99
99
 
100
100
  def three_column_officemembers_split(div)
101
- prev = false
102
101
  div.xpath(".//div").each { |d| d.replace(d.children) }
102
+ ret = three_column_officemembers_split_main(false, div)
103
+ ret = three_column_officemembers_split_balance(ret)
104
+ ret.map do |r|
105
+ r.map { |r1| to_xml(r1) }
106
+ end.map(&:join)
107
+ end
108
+
109
+ def three_column_officemembers_split_main(prev, div)
103
110
  div.elements.each_with_object([[]]) do |e, m|
104
111
  member = e.name == "p" && e["type"] == "officemember"
105
- (prev == member and m[-1] << to_xml(e)) or m << [to_xml(e)]
112
+ if prev == member
113
+ !m[-1].empty? && m[-1][-1]["class"] == stylesmap[:nameslist] &&
114
+ e["class"] != stylesmap[:nameslist] and
115
+ m[-1] << Nokogiri::XML("<p>&#xa0;</p>").root
116
+ m[-1] << e
117
+ else
118
+ m << [e]
119
+ end
106
120
  prev = member
107
- end.map(&:join)
121
+ end
122
+ end
123
+
124
+ def three_column_officemembers_split_balance(ret)
125
+ blank = Nokogiri::XML("<p class='IEEEStdsNamesList'>&#xa0;</p>").root
126
+ ret.each do |r|
127
+ s = r.size
128
+ r[0].name == "p" && r[0]["type"] == "officemember" && s > 3 or next
129
+ extras = s % 3
130
+ extras == 1 and r.insert((s / 3).floor, blank)
131
+ extras == 2 and
132
+ r.insert((s / 3).ceil + (s / 3).floor + 1, blank)
133
+ end
134
+ ret
108
135
  end
109
136
 
110
137
  def three_column_officemembers_render(div, ret)
@@ -162,10 +189,12 @@ module IsoDoc
162
189
  def authority_cleanup1(docxml, klass)
163
190
  dest = docxml.at("//div[@id = 'boilerplate-#{klass}-destination']")
164
191
  auth = docxml.at("//div[@id = 'boilerplate-#{klass}' " \
165
- "or @class = 'boilerplate-#{klass}']")
166
- auth&.xpath(".//h1[not(text())] | .//h2[not(text())]")&.each(&:remove)
167
- authority_cleanup_hdr(auth)
168
- dest and auth and dest.replace(auth.remove)
192
+ "or @class = 'boilerplate-#{klass}']") or return
193
+ auth.xpath(".//h1[not(text())] | .//h2[not(text())]")&.each(&:remove)
194
+ authority_cleanup_hdr(auth.remove)
195
+ if dest && auth
196
+ dest.replace(auth)
197
+ end
169
198
  end
170
199
 
171
200
  def authority_cleanup_hdr(auth)
@@ -176,57 +205,6 @@ module IsoDoc
176
205
  end
177
206
  end
178
207
  end
179
-
180
- def abstract_cleanup(docxml)
181
- dest = docxml.at("div[@id = 'abstract-destination']") or return
182
- if f = docxml.at("//div[@class = 'abstract']")
183
- f.previous_element.remove
184
- abstract_cleanup1(f, dest)
185
- abstract_header(dest)
186
- f.remove
187
- elsif f = docxml.at("//div[@type = 'scope']")
188
- abstract_cleanup1(f, dest)
189
- abstract_header(dest)
190
- end
191
- end
192
-
193
- def abstract_cleanup1(source, dest)
194
- source.elements.reject { |e| %w(h1 h2).include?(e.name) }.each do |e|
195
- e1 = e.dup
196
- e1.xpath("self::p | .//p").each do |p|
197
- p["class"] = stylesmap[:abstract]
198
- p["style"] ||= ""
199
- p["style"] = "font-family: 'Arial', sans-serif;#{p['style']}"
200
- end
201
- dest and dest << e1
202
- end
203
- end
204
-
205
- def abstract_header(dest)
206
- dest.elements.first.add_first_child <<~XML
207
- <span class='IEEEStdsAbstractHeader'><span lang='EN-US'>Abstract:</span></span>
208
- XML
209
- end
210
-
211
- def introduction_cleanup(docxml)
212
- dest = docxml.at("div[@id = 'introduction-destination']") or return
213
- unless i = docxml.at("//h1[@class = 'IntroTitle']")&.parent
214
- dest.parent.remove
215
- return
216
- end
217
- introduction_cleanup1(i, dest)
218
- end
219
-
220
- def introduction_cleanup1(intro, dest)
221
- docxml = intro.document
222
- intro.previous_element.remove
223
- dest.replace(intro.remove)
224
- i = docxml.at("//h1[@class = 'IntroTitle']")
225
- if i.next_element.name == "div" &&
226
- i.next_element["class"] == stylesmap[:intro]
227
- i.next_element.name = "p"
228
- end
229
- end
230
208
  end
231
209
  end
232
210
  end
@@ -3,8 +3,7 @@ module IsoDoc
3
3
  class WordConvert < IsoDoc::WordConvert
4
4
  def toWord(result, filename, dir, header)
5
5
  ::Html2Doc::Ieee.new(
6
- filename: filename,
7
- imagedir: @localdir,
6
+ filename: filename, imagedir: @localdir,
8
7
  stylesheet: @wordstylesheet&.path,
9
8
  header_file: header&.path, dir: dir,
10
9
  asciimathdelims: [@openmathdelim, @closemathdelim],
@@ -33,21 +32,6 @@ module IsoDoc
33
32
  docxml
34
33
  end
35
34
 
36
- def make_WordToC(docxml, level)
37
- toc = ""
38
- if source = docxml.at("//div[@class = 'TOC']")
39
- toc = to_xml(source.children)
40
- end
41
- xpath = (1..level).each.map do |i|
42
- "//h#{i}[not(ancestor::*[@class = 'WordSection2'])]"
43
- end.join (" | ")
44
- docxml.xpath(xpath).each do |h|
45
- toc += word_toc_entry(h.name[1].to_i, header_strip(h))
46
- end
47
- toc.sub(/(<p class="MsoToc1">)/,
48
- %{\\1#{word_toc_preface(level)}}) + WORD_TOC_SUFFIX1
49
- end
50
-
51
35
  def biblio_cleanup(docxml)
52
36
  docxml.xpath("//p[@class = 'Biblio']").each do |p|
53
37
  headings_strip(p)
@@ -70,12 +54,11 @@ module IsoDoc
70
54
  if hdr.at("./ancestor::div[@class = 'Annex']")
71
55
  hdr.delete("class")
72
56
  hdr["style"] = "mso-list:l13 level#{idx} lfo33;"
73
- elsif hdr.at("./ancestor::div[@class = 'Section3' or @class = 'WordSectionContents']")
74
- hdr.name = "p"
75
- hdr["class"] = stylesmap["level#{idx}frontmatter".to_sym]
76
57
  else
77
58
  hdr.name = "p"
78
- hdr["class"] = stylesmap["level#{idx}header".to_sym]
59
+ front = hdr.at("./ancestor::div[@class = 'Section3' or @class = 'WordSectionContents']")
60
+ type = front ? "frontmatter" : "header"
61
+ hdr["class"] = stylesmap["level#{idx}#{type}".to_sym]
79
62
  end
80
63
  end
81
64
 
@@ -86,7 +69,6 @@ module IsoDoc
86
69
  end
87
70
  end
88
71
 
89
- # STYLE
90
72
  def div_cleanup(docxml)
91
73
  d = docxml.at("//div[@class = 'WordSection2']" \
92
74
  "[div[@class = 'WordSection2']]") and
@@ -101,8 +83,7 @@ module IsoDoc
101
83
  end
102
84
 
103
85
  def stylesmap
104
- {
105
- example: "IEEEStdsParagraph",
86
+ { example: "IEEEStdsParagraph",
106
87
  MsoNormal: "IEEEStdsParagraph",
107
88
  NormRef: "IEEEStdsParagraph",
108
89
  Biblio: "IEEEStdsBibliographicEntry",
@@ -114,6 +95,7 @@ module IsoDoc
114
95
  admonition: "IEEEStdsWarning",
115
96
  abstract: "IEEEStdsAbstractBody",
116
97
  AbstractTitle: "AbstractTitle",
98
+ TOCTitle: "IEEEStdsLevel1frontmatter",
117
99
  level1frontmatter: "IEEEStdsLevel1frontmatter",
118
100
  level2frontmatter: "IEEEStdsLevel2frontmatter",
119
101
  level3frontmatter: "IEEEStdsLevel3frontmatter",
@@ -132,20 +114,29 @@ module IsoDoc
132
114
  nameslist: "IEEEStdsNamesList",
133
115
  intro: "IEEEStdsIntroduction",
134
116
  surname: "au_surname",
135
- forename: "au_fname",
136
- }
117
+ forename: "au_fname" }
137
118
  end
138
119
 
139
- def table_toc_class
140
- ["IEEEStds Regular Table Caption", "TableTitle", "tabletitle"]
120
+ def caption_style_cleanup(docxml)
121
+ docxml.xpath("//*[@class = 'TableTitle']").each do |p|
122
+ p["class"] =
123
+ annex_caption?(p.parent) ? "TableCaption" : stylesmap[:TableTitle]
124
+ end
125
+ docxml.xpath("//*[@class = 'FigureTitle']").each do |p|
126
+ p["class"] =
127
+ annex_caption?(p.parent) ? "FigureCaption" : stylesmap[:FigureTitle]
128
+ end
141
129
  end
142
130
 
143
- def figure_toc_class
144
- ["IEEEStds Regular Figure Caption", "FigureTitle", "figuretitle"]
131
+ def annex_caption?(div)
132
+ annex = div["annex"]
133
+ div.delete("annex")
134
+ annex
145
135
  end
146
136
 
147
137
  def style_cleanup(docxml)
148
138
  note_style_cleanup(docxml)
139
+ caption_style_cleanup(docxml)
149
140
  docxml.xpath("//div[@class = 'formula']/p").each do |p|
150
141
  p["class"] = stylesmap[:formula]
151
142
  end
@@ -157,11 +148,68 @@ module IsoDoc
157
148
  end
158
149
  end
159
150
 
160
- def insert_toc(intro, docxml, level)
161
- toc = assemble_toc(docxml, level)
162
- source = docxml.at("//div[@class = 'WordSectionContents']") and
163
- source << toc
164
- intro
151
+ def abstract_cleanup(docxml)
152
+ dest = docxml.at("div[@id = 'abstract-destination']") or return
153
+ if f = docxml.at("//div[@class = 'abstract']")
154
+ f.previous_element.remove
155
+ abstract_cleanup1(f.remove, dest)
156
+ abstract_header(dest)
157
+ elsif f = docxml.at("//div[@type = 'scope']")
158
+ abstract_cleanup1(f, dest)
159
+ abstract_header(dest)
160
+ end
161
+ end
162
+
163
+ def abstract_cleanup1(source, dest)
164
+ source.elements.reject { |e| %w(h1 h2).include?(e.name) }.each do |e|
165
+ e1 = e.dup
166
+ e1.xpath("self::p | .//p").each do |p|
167
+ p["class"] = stylesmap[:abstract]
168
+ p["style"] ||= ""
169
+ p["style"] = "font-family: 'Arial', sans-serif;#{p['style']}"
170
+ end
171
+ dest and dest << e1
172
+ end
173
+ end
174
+
175
+ def abstract_header(dest)
176
+ dest.elements.first.add_first_child <<~XML
177
+ <span class='IEEEStdsAbstractHeader'><span lang='EN-US'>Abstract:</span></span>
178
+ XML
179
+ end
180
+
181
+ def introduction_cleanup(docxml)
182
+ dest = docxml.at("div[@id = 'introduction-destination']") or return
183
+ unless i = docxml.at("//h1[@class = 'IntroTitle']")&.parent
184
+ dest.parent.remove
185
+ return
186
+ end
187
+ introduction_cleanup1(i, dest)
188
+ end
189
+
190
+ def introduction_cleanup1(intro, dest)
191
+ introduction_to_frontispiece(intro, dest)
192
+ introduction_para_style(intro.document)
193
+ end
194
+
195
+ def introduction_to_frontispiece(intro, dest)
196
+ docxml = intro.document
197
+ intro.previous_element.remove
198
+ introcontent = docxml.xpath("//h1[@class = 'IntroTitle']")
199
+ .map(&:parent).uniq.map(&:remove)
200
+ introcontent.each do |node|
201
+ dest.add_previous_sibling(node)
202
+ end
203
+ dest.remove
204
+ end
205
+
206
+ def introduction_para_style(docxml)
207
+ docxml.xpath("//h1[@class = 'IntroTitle']").each do |i|
208
+ i.next_element or next
209
+ i.next_element.name == "div" &&
210
+ i.next_element["class"] == stylesmap[:intro] and
211
+ i.next_element.name = "p"
212
+ end
165
213
  end
166
214
  end
167
215
  end
@@ -128,7 +128,6 @@ module IsoDoc
128
128
  end
129
129
 
130
130
  # hardcoded list style for notes
131
- # STYLE
132
131
  def note_style_cleanup1(multi, div, seq)
133
132
  div.xpath(".//p[@class = 'Note' or not(@class)]")
134
133
  .each_with_index do |p, i|
@@ -2,6 +2,7 @@ require "isodoc"
2
2
  require_relative "init"
3
3
  require_relative "word_cleanup"
4
4
  require_relative "word_cleanup_blocks"
5
+ require_relative "word_toc"
5
6
  require_relative "word_authority"
6
7
  require_relative "word_wp_convert"
7
8
 
@@ -38,16 +39,8 @@ module IsoDoc
38
39
  end
39
40
 
40
41
  def default_fonts(options)
41
- { bodyfont: (if options[:script] == "Hans"
42
- '"Source Han Sans",serif'
43
- else
44
- '"Times New Roman",serif'
45
- end),
46
- headerfont: (if options[:script] == "Hans"
47
- '"Source Han Sans",sans-serif'
48
- else
49
- '"Arial",sans-serif'
50
- end),
42
+ { bodyfont: '"Times New Roman",serif',
43
+ headerfont: '"Arial",sans-serif',
51
44
  monospacefont: '"Courier New",monospace',
52
45
  normalfontsize: "12.0pt",
53
46
  footnotefontsize: "11.0pt",
@@ -209,24 +202,34 @@ module IsoDoc
209
202
  # Retain the em-dash delimiting caption
210
203
  def strip_caption_semx(name)
211
204
  name.xpath(".//xmlns:semx[@element = 'autonum']/"\
212
- "preceding-sibling::*[normalize-space() = '']").each do |s|
213
- s.ancestors("fn").empty? and s.remove
214
- end
205
+ "preceding-sibling::text()[normalize-space() = '']")
206
+ .each do |s|
207
+ s.ancestors("fn").empty? and s.remove
208
+ end
215
209
  name.xpath(ns(".//span[@class = 'fmt-element-name'] | "\
216
210
  ".//semx[@element = 'autonum']")).each do |s|
217
211
  s.ancestors("fn").empty? and s.remove
218
212
  end
219
213
  end
220
214
 
221
- def figure_name_parse(_node, div, name)
215
+ # Do not strip the caption in Annexes
216
+ def figure_name_parse(node, div, name)
222
217
  name.nil? and return
223
- strip_caption_semx(name)
218
+ if name.ancestors.map(&:name).include?("annex")
219
+ div.parent["annex"] = true
220
+ else
221
+ strip_caption_semx(name)
222
+ end
224
223
  super
225
224
  end
226
225
 
227
226
  def table_title_parse(node, out)
228
227
  name = node.at(ns("./fmt-name")) or return
229
- strip_caption_semx(name)
228
+ if name.ancestors.map(&:name).include?("annex")
229
+ out.parent["annex"] = true
230
+ else
231
+ strip_caption_semx(name)
232
+ end
230
233
  super
231
234
  end
232
235
 
@@ -0,0 +1,46 @@
1
+ module IsoDoc
2
+ module Ieee
3
+ class WordConvert < IsoDoc::WordConvert
4
+ def make_WordToC(docxml, level)
5
+ toc = ""
6
+ if source = docxml.at("//div[@class = 'TOC']")
7
+ toc = to_xml(source.children)
8
+ end
9
+ xpath = (1..level).each.map do |i|
10
+ "//h#{i}[not(ancestor::*[@class = 'WordSection2'])]"
11
+ end.join (" | ")
12
+ annexid = 0
13
+ docxml.xpath(xpath).each do |h|
14
+ x = ""
15
+ if h.name == "h1" && h["class"] == "Annex"
16
+ x, annexid = annex_toc(annexid)
17
+ end
18
+ toc += word_toc_entry(h.name[1].to_i, x + header_strip(h))
19
+ end
20
+ toc.sub(/(<p class="MsoToc1">)/,
21
+ %{\\1#{word_toc_preface(level)}}) + WORD_TOC_SUFFIX1
22
+ end
23
+
24
+ def annex_toc(annexid)
25
+ annexid += 1
26
+ x = "#{@i18n.annex} #{('@'.ord + annexid).chr} "
27
+ [x, annexid]
28
+ end
29
+
30
+ def table_toc_class
31
+ ["IEEEStds Regular Table Caption", "TableTitle", "tabletitle", "TableCaption"]
32
+ end
33
+
34
+ def figure_toc_class
35
+ ["IEEEStds Regular Figure Caption", "FigureTitle", "figuretitle", "FigureCaption"]
36
+ end
37
+
38
+ def insert_toc(intro, docxml, level)
39
+ toc = assemble_toc(docxml, level)
40
+ source = docxml.at("//div[@class = 'WordSectionContents']") and
41
+ source << toc
42
+ intro
43
+ end
44
+ end
45
+ end
46
+ end
@@ -9,6 +9,7 @@ New York, New York 10016-5997, USA
9
9
  All rights reserved.
10
10
 
11
11
  == license-statement
12
+ {% if unpublished %}
12
13
  === {blank}
13
14
  This document is an unapproved draft of a proposed IEEE Standard. As such, this document is subject to change. USE AT YOUR OWN RISK! IEEE copyright statements SHALL NOT BE REMOVED from draft or approved IEEE standards, or modified in any way. Because this is an unapproved draft, this document must not be utilized for any conformance/compliance purposes. Permission is hereby granted for officers from each IEEE Standards Working Group or Committee to reproduce the draft document developed by that Working Group for purposes of international standardization consideration. IEEE Standards Department must be informed of the submission for consideration prior to any reproduction for international standardization consideration (stds-ipr@ieee.org). Prior to adoption of this document, in whole or in part, by another standards development organization, permission must first be obtained from the IEEE Standards Department (stds-ipr@ieee.org). When requesting permission, IEEE Standards Department will require a copy of the standard development organization's document highlighting the use of IEEE content. Other entities seeking permission to reproduce this document, in whole or in part, must also obtain permission from the IEEE Standards Department.
14
15
 
@@ -16,6 +17,7 @@ This document is an unapproved draft of a proposed IEEE Standard. As such, this
16
17
  IEEE Standards Department +
17
18
  445 Hoes Lane +
18
19
  Piscataway, NJ 08854, USA
20
+ {% endif %}
19
21
 
20
22
  == legal-statement
21
23
  [[boilerplate-disclaimers]]
@@ -188,7 +190,7 @@ Technologies, application of technologies, and recommended procedures in various
188
190
 
189
191
  [[boilerplate-participants-wg]]
190
192
  ==== {blank}
191
- At the time this draft {{ doctype }} was completed, the {{ working_group }} had the following membership:
193
+ At the time this draft {{ doctype | downcase }} was completed, the {{ working_group }} had the following membership:
192
194
 
193
195
  ++++
194
196
  <membership>
@@ -234,7 +236,7 @@ role::: Member
234
236
 
235
237
  [[boilerplate-participants-bg]]
236
238
  ==== {blank}
237
- The following members of the {{ balloting_group_type }} {{ balloting_group }} Standards Association balloting group voted on this {{ doctype }}. Balloters may have voted for approval, disapproval, or abstention.
239
+ The following members of the {{ balloting_group_type }} {{ balloting_group }} Standards Association balloting group voted on this {{ doctype | downcase }}. Balloters may have voted for approval, disapproval, or abstention.
238
240
 
239
241
  ++++
240
242
  <membership>
@@ -275,7 +277,7 @@ role::: Member
275
277
  [[boilerplate-participants-sb]]
276
278
  ==== {blank}
277
279
 
278
- When the IEEE SA Standards Board approved this {{ doctype }} on {{ ieee_sasb_approveddate }}, it had the following membership:
280
+ When the IEEE SA Standards Board approved this {{ doctype | downcase }} on {{ ieee_sasb_approveddate }}, it had the following membership:
279
281
 
280
282
  ++++
281
283
  <membership>
@@ -335,8 +337,7 @@ The Institute of Electrical and Electronics Engineers, Inc. +
335
337
  3 Park Avenue, New York, NY 10016-5997, USA
336
338
 
337
339
  === {blank}
338
- Copyright © {{ docyear }} by The Institute of Electrical and Electronics Engineers, Inc.
339
-
340
+ Copyright © {{ docyear }} by The Institute of Electrical and Electronics Engineers, Inc. +
340
341
  All rights reserved. Published {{ issueddate }}. Printed in the United States of America.
341
342
 
342
343
  === {blank}
@@ -4,8 +4,7 @@
4
4
  The Institute of Electrical and Electronics Engineers, Inc. 3 Park Avenue, New York, NY 10016-5997, USA
5
5
 
6
6
  === {blank}
7
- Copyright © {{ docyear }} by The Institute of Electrical and Electronics Engineers, Inc.
8
-
7
+ Copyright © {{ docyear }} by The Institute of Electrical and Electronics Engineers, Inc. +
9
8
  All rights reserved. {{ issueddate }}. Printed in the United States of America.
10
9
 
11
10
  === {blank}
@@ -1,4 +1,5 @@
1
1
  require_relative "cleanup_ref"
2
+ require_relative "cleanup_ref_fn"
2
3
  require_relative "cleanup_boilerplate"
3
4
  require_relative "term_lookup_cleanup"
4
5
 
@@ -45,13 +46,13 @@ module Metanorma
45
46
 
46
47
  def note_cleanup(xmldoc)
47
48
  super
48
- n = xmldoc.at("//preface//note[not(@type = 'boilerplate')]" \
49
- "[not(./ancestor::abstract)] | " \
50
- "//sections//note[not(@type = 'boilerplate')] | " \
51
- "//annex//note[not(@type = 'boilerplate')]") or
52
- return
49
+ type = "[not(@type = 'boilerplate' or @type = 'Availability' or " \
50
+ "@type = 'license')]"
51
+ n = xmldoc.at("//preface//note#{type}[not(./ancestor::abstract)] | " \
52
+ "//sections//note#{type} | //termnote#{type} | " \
53
+ "//annex//note#{type}") or return
53
54
  ins = n.at("./p[last()]")
54
- ins << "<fn reference='_boilerplate_cleanup1'>" \
55
+ ins << "<fn reference='_note_cleanup1'>" \
55
56
  "<p>#{@i18n.note_inform_fn}</p></fn>"
56
57
  add_id(ins.last_element_child)
57
58
  end
@@ -99,6 +100,7 @@ module Metanorma
99
100
  xml = Nokogiri::XML(x.to_xml)
100
101
  i = isodoc(@lang, @script, @locale)
101
102
  i.bibdata_i18n(xml.at("//xmlns:bibdata"))
103
+ i.localdir = @localdir
102
104
  i.info(xml, nil)
103
105
  i
104
106
  end
@@ -110,17 +112,48 @@ module Metanorma
110
112
 
111
113
  def bibdata_cleanup(xmldoc)
112
114
  super
115
+ draft_id(xmldoc)
116
+ prefixed_title(xmldoc)
113
117
  provenance_title(xmldoc)
114
118
  end
115
119
 
120
+ def prefixed_title(xmldoc)
121
+ t, stage, trial = prefixed_title_prep(xmldoc)
122
+ %w(main title-abbrev).reverse_each do |type|
123
+ xmldoc.at("//bibdata/title[@type = '#{type}']") and next
124
+ p = prefixed_title1(stage, trial, type)
125
+ t.previous = <<~XML
126
+ <title type='#{type}' language='en'>#{p}#{to_xml(t.children)}</title>
127
+ XML
128
+ end
129
+ end
130
+
131
+ def prefixed_title1(stage, trial, type)
132
+ m = []
133
+ m << (stage == "draft" ? "Draft" : "IEEE")
134
+ trial and m << "Trial-Use"
135
+ doctype = @doctype.split(/[- ]/).map(&:capitalize).join(" ")
136
+ type == "title-abbrev" && a = @i18n.get["doctype_abbrev"][@doctype] and
137
+ doctype = a
138
+ m << doctype
139
+ m << "for"
140
+ "#{m.join(' ')} "
141
+ end
142
+
143
+ def prefixed_title_prep(xmldoc)
144
+ t = xmldoc.at("//bibdata/title[@type = 'title-main']")
145
+ stage = xmldoc.at("//status/stage")&.text
146
+ trial = xmldoc.at("//bibdata/ext/trial-use[text() = 'true']")
147
+ [t, stage, trial]
148
+ end
149
+
116
150
  def provenance_title(xmldoc)
117
151
  u = xmldoc.xpath("//bibdata/relation[@type = 'updates']")
118
152
  m = xmldoc.xpath("//bibdata/relation[@type = 'merges']")
119
153
  u.empty? and m.empty? and return
120
- ins = xmldoc.at("//bibdata/title")
154
+ ins = xmldoc.at("//bibdata/title[@type = 'title-main']")
121
155
  t = provenance_title1(u, m)
122
- ins.next = "<title type='provenance' language='en' " \
123
- "format='application/xml'>#{t}</title>"
156
+ ins.next = "<title type='provenance' language='en'>#{t}</title>"
124
157
  end
125
158
 
126
159
  def provenance_title1(updates, merges)
@@ -142,6 +175,20 @@ module Metanorma
142
175
  u.at("./bibitem/docidentifier")
143
176
  end.map(&:text)
144
177
  end
178
+
179
+ def published?(stage, _xmldoc)
180
+ %w(approved superseded withdrawn).include?(stage&.downcase)
181
+ end
182
+
183
+ # IEEE Draft Std 10000-2025/D1.2 => P10000/D1.2
184
+ # TODO: this needs to go to pubid-ieee
185
+ def draft_id(xmldoc)
186
+ published?(xmldoc.at("//bibdata/status/stage")&.text, xmldoc) and return
187
+ id = xmldoc.at("//bibdata/docidentifier[@type = 'IEEE']") or return
188
+ id.text.start_with?("IEEE Draft Std ") or return
189
+ n = id.text.sub(/^IEEE Draft Std /, "P").sub(/(\d)-(\d\d\d\d)/, "\\1")
190
+ id.next = %(<docidentifier type="IEEE-draft">#{n}</docidentifier>)
191
+ end
145
192
  end
146
193
  end
147
194
  end
@@ -19,10 +19,7 @@ module Metanorma
19
19
 
20
20
  def intro_boilerplate(xml, isodoc)
21
21
  intro = xml.at("//introduction/title") or return
22
- template = <<~ADM
23
- This introduction is not part of P{{ docnumeric }}{% if draft %}/D{{ draft }}{% endif %}, {{ full_doctitle }}
24
- ADM
25
- adm = isodoc.populate_template(template)
22
+ adm = isodoc.populate_template(@i18n.introduction_disclaimer)
26
23
  intro.next = "<admonition>#{adm}</admonition>"
27
24
  add_id(intro.next)
28
25
  end