metanorma-ieee 0.0.1 → 0.0.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.
- checksums.yaml +4 -4
- data/README.adoc +1 -1
- data/lib/html2doc/ieee/lists.rb +44 -0
- data/lib/html2doc/ieee/notes.rb +57 -0
- data/lib/html2doc/ieee.rb +4 -86
- data/lib/isodoc/ieee/base_convert.rb +56 -0
- data/lib/isodoc/ieee/html/header.html +1 -2
- data/lib/isodoc/ieee/html/header_amd.html +105 -0
- data/lib/isodoc/ieee/html/html_ieee_titlepage.html +14 -12
- data/lib/isodoc/ieee/html/htmlstyle.css +2 -1
- data/lib/isodoc/ieee/html/htmlstyle.scss +1 -0
- data/lib/isodoc/ieee/html/ieee.css +46 -273
- data/lib/isodoc/ieee/html/ieee.scss +46 -257
- data/lib/isodoc/ieee/html/word_ieee_intro.html +1 -1
- data/lib/isodoc/ieee/html/word_ieee_titlepage.html +12 -1
- data/lib/isodoc/ieee/html/wordstyle.css +20 -23
- data/lib/isodoc/ieee/html/wordstyle.scss +20 -17
- data/lib/isodoc/ieee/html_convert.rb +37 -1
- data/lib/isodoc/ieee/i18n-en.yaml +5 -0
- data/lib/isodoc/ieee/ieee.amendment.xsl +5488 -3540
- data/lib/isodoc/ieee/ieee.standard.xsl +5488 -3540
- data/lib/isodoc/ieee/metadata.rb +35 -51
- data/lib/isodoc/ieee/pdf_convert.rb +2 -2
- data/lib/isodoc/ieee/presentation_ref.rb +70 -0
- data/lib/isodoc/ieee/presentation_terms.rb +105 -32
- data/lib/isodoc/ieee/presentation_xml_convert.rb +136 -0
- data/lib/isodoc/ieee/word_authority.rb +73 -3
- data/lib/isodoc/ieee/word_cleanup.rb +55 -65
- data/lib/isodoc/ieee/word_cleanup_blocks.rb +151 -0
- data/lib/isodoc/ieee/word_convert.rb +98 -2
- data/lib/isodoc/ieee/xref.rb +31 -0
- data/lib/metanorma/ieee/boilerplate.xml +72 -23
- data/lib/metanorma/ieee/cleanup.rb +142 -77
- data/lib/metanorma/ieee/cleanup_ref.rb +126 -0
- data/lib/metanorma/ieee/converter.rb +8 -0
- data/lib/metanorma/ieee/front.rb +44 -53
- data/lib/metanorma/ieee/ieee.rng +44 -6
- data/lib/metanorma/ieee/isodoc.rng +32 -1
- data/lib/metanorma/ieee/reqt.rng +1 -1
- data/lib/metanorma/ieee/term_lookup_cleanup.rb +11 -0
- data/lib/metanorma/ieee/validate.rb +105 -57
- data/lib/metanorma/ieee/validate_section.rb +14 -7
- data/lib/metanorma/ieee/validate_style.rb +58 -1
- data/lib/metanorma/ieee/version.rb +1 -1
- data/lib/relaton/render/config.yml +44 -0
- data/lib/relaton/render/general.rb +13 -0
- data/metanorma-itu.gemspec +1 -1
- metadata +13 -4
@@ -46,6 +46,7 @@ module IsoDoc
|
|
46
46
|
officeholder_style(p)
|
47
47
|
end
|
48
48
|
officemember_style(docxml)
|
49
|
+
officeorgrep_style(docxml)
|
49
50
|
three_column_officemembers(docxml
|
50
51
|
.at("//div[@id = 'boilerplate-participants']"))
|
51
52
|
end
|
@@ -53,9 +54,9 @@ module IsoDoc
|
|
53
54
|
def officeholder_style(para)
|
54
55
|
n = para.next_element
|
55
56
|
p = para.previous_element
|
56
|
-
n && n.name == "p" && n["type"]
|
57
|
+
n && n.name == "p" && n["type"] != "officeholder" and
|
57
58
|
klass = "IEEEStdsNamesCtrCxSpLast"
|
58
|
-
p && p.name == "p" && p["type"]
|
59
|
+
p && p.name == "p" && p["type"] != "officeholder" and
|
59
60
|
klass = "IEEEStdsNamesCtrCxSpFirst"
|
60
61
|
para["class"] = klass || "IEEEStdsNamesCtrCxSpMiddle"
|
61
62
|
end
|
@@ -68,7 +69,8 @@ module IsoDoc
|
|
68
69
|
BREAK
|
69
70
|
|
70
71
|
def officemember_style(docxml)
|
71
|
-
docxml.xpath("//p[@type = 'officemember']")
|
72
|
+
docxml.xpath("//p[@type = 'officemember' or @type = 'officeorgmember']")
|
73
|
+
.each do |p|
|
72
74
|
p["class"] = "IEEEStdsNamesList"
|
73
75
|
end
|
74
76
|
docxml.xpath("//p[@type = 'emeritus_sign']").each do |p|
|
@@ -76,6 +78,19 @@ module IsoDoc
|
|
76
78
|
end
|
77
79
|
end
|
78
80
|
|
81
|
+
def officeorgrep_style(docxml)
|
82
|
+
docxml.xpath("//p[@type = 'officeorgrepmemberhdr']").each do |p|
|
83
|
+
p["class"] = "IEEEStdsNamesList"
|
84
|
+
p["style"] =
|
85
|
+
"margin-bottom:6.0pt;tab-stops:right 432.0pt;"
|
86
|
+
end
|
87
|
+
docxml.xpath("//p[@type = 'officeorgrepmember']").each do |p|
|
88
|
+
p["class"] = "IEEEStdsNamesList"
|
89
|
+
p["style"] =
|
90
|
+
"margin-top:6.0pt;tab-stops:right dotted 432.0pt;"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
79
94
|
def three_column_officemembers(div)
|
80
95
|
return unless div
|
81
96
|
|
@@ -85,6 +100,7 @@ module IsoDoc
|
|
85
100
|
|
86
101
|
def three_column_officemembers_split(div)
|
87
102
|
prev = false
|
103
|
+
div.xpath(".//div").each { |d| d.replace(d.children) }
|
88
104
|
div.elements.each_with_object([[]]) do |e, m|
|
89
105
|
member = e.name == "p" && e["type"] == "officemember"
|
90
106
|
(prev == member and m[-1] << e.to_xml) or m << [e.to_xml]
|
@@ -125,6 +141,10 @@ module IsoDoc
|
|
125
141
|
docxml.at("//div[@class = 'boilerplate-feedback']")&.xpath("./div")
|
126
142
|
&.each_with_index do |div, i|
|
127
143
|
i.zero? or div.elements.first.previous = "<p> </p>"
|
144
|
+
i == 4 and
|
145
|
+
div.xpath(".//p[br]").each do |p|
|
146
|
+
p.replace(p.to_xml.gsub(%r{<br/>}, "</p><p>"))
|
147
|
+
end
|
128
148
|
feedback_style1(div, i)
|
129
149
|
end
|
130
150
|
end
|
@@ -155,6 +175,56 @@ module IsoDoc
|
|
155
175
|
end
|
156
176
|
end
|
157
177
|
end
|
178
|
+
|
179
|
+
def abstract_cleanup(docxml)
|
180
|
+
dest = docxml.at("div[@id = 'abstract-destination']") or return
|
181
|
+
if f = docxml.at("//div[@class = 'abstract']")
|
182
|
+
f.previous_element.remove
|
183
|
+
abstract_cleanup1(f, dest)
|
184
|
+
f.remove
|
185
|
+
elsif f = docxml.at("//div[@type = 'scope']")
|
186
|
+
abstract_cleanup1(f, dest)
|
187
|
+
abstract_header(dest)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
def abstract_cleanup1(source, dest)
|
192
|
+
source.elements.reject { |e| %w(h1 h2).include?(e.name) }.each do |e|
|
193
|
+
e1 = e.dup
|
194
|
+
e1.xpath(".//p").each do |p|
|
195
|
+
p["style"] ||= ""
|
196
|
+
p["style"] = 'font-family: "Arial", sans-serif;' + p["style"]
|
197
|
+
end
|
198
|
+
%w(ul ol).include?(e1.name) or e1["class"] = "IEEEStdsAbstractBody"
|
199
|
+
dest << e1
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
def abstract_header(dest)
|
204
|
+
dest.elements.first.children.first.previous =
|
205
|
+
"<span class='IEEEStdsAbstractHeader'><span lang='EN-US'>"\
|
206
|
+
"Abstract:</span></span> "
|
207
|
+
end
|
208
|
+
|
209
|
+
def introduction_cleanup(docxml)
|
210
|
+
dest = docxml.at("div[@id = 'introduction-destination']") or return
|
211
|
+
unless i = docxml.at("//h1[@class = 'IntroTitle']")&.parent
|
212
|
+
dest.parent.remove
|
213
|
+
return
|
214
|
+
end
|
215
|
+
introduction_cleanup1(i, dest)
|
216
|
+
end
|
217
|
+
|
218
|
+
def introduction_cleanup1(intro, dest)
|
219
|
+
docxml = intro.document
|
220
|
+
intro.previous_element.remove
|
221
|
+
dest.replace(intro.remove)
|
222
|
+
i = docxml.at("//h1[@class = 'IntroTitle']")
|
223
|
+
if i.next_element.name == "div" &&
|
224
|
+
i.next_element["class"] == "IEEEStdsIntroduction"
|
225
|
+
i.next_element.name = "p"
|
226
|
+
end
|
227
|
+
end
|
158
228
|
end
|
159
229
|
end
|
160
230
|
end
|
@@ -17,70 +17,65 @@ module IsoDoc
|
|
17
17
|
@wordstylesheet.unlink if @wordstylesheet.is_a?(Tempfile)
|
18
18
|
end
|
19
19
|
|
20
|
-
def abstract_cleanup(docxml)
|
21
|
-
dest = docxml.at("div[@id = 'abstract-destination']") or return
|
22
|
-
if f = docxml.at("//div[@class = 'abstract']")
|
23
|
-
f.previous_element.remove
|
24
|
-
abstract_cleanup1(f, dest)
|
25
|
-
f.remove
|
26
|
-
elsif f = docxml.at("//div[@type = 'scope']")
|
27
|
-
abstract_cleanup1(f, dest)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def abstract_cleanup1(source, dest)
|
32
|
-
source.elements.each do |e|
|
33
|
-
next if %w(h1 h2).include?(e.name)
|
34
|
-
|
35
|
-
dest << e.dup
|
36
|
-
dest.elements.last["class"] = "IEEEStdsAbstractBody"
|
37
|
-
end
|
38
|
-
dest.elements.first.children.first.previous =
|
39
|
-
"<span class='IEEEStdsAbstractHeader'><span lang='EN-US'>"\
|
40
|
-
"Abstract:</span></span> "
|
41
|
-
end
|
42
|
-
|
43
|
-
def introduction_cleanup(docxml)
|
44
|
-
dest = docxml.at("div[@id = 'introduction-destination']") or return
|
45
|
-
unless i = docxml.at("//h1[@class = 'IntroTitle']")&.parent
|
46
|
-
dest.parent.remove
|
47
|
-
return
|
48
|
-
end
|
49
|
-
introduction_cleanup1(i, dest)
|
50
|
-
end
|
51
|
-
|
52
|
-
def introduction_cleanup1(intro, dest)
|
53
|
-
docxml = intro.document
|
54
|
-
intro.previous_element.remove
|
55
|
-
dest.replace(intro.remove)
|
56
|
-
i = docxml.at("//h1[@class = 'IntroTitle']")
|
57
|
-
i.next_element == "div" && i.next_element["class"] == "Admonition" and
|
58
|
-
i.next_element["class"] = "IEEEStdsIntroduction"
|
59
|
-
end
|
60
|
-
|
61
20
|
def word_cleanup(docxml)
|
62
21
|
super
|
63
22
|
abstract_cleanup(docxml)
|
64
23
|
introduction_cleanup(docxml)
|
24
|
+
sourcecode_cleanup(docxml)
|
65
25
|
div_cleanup(docxml)
|
26
|
+
biblio_cleanup(docxml)
|
66
27
|
headings_cleanup(docxml)
|
67
|
-
|
28
|
+
caption_cleanup(docxml)
|
29
|
+
table_cleanup(docxml)
|
68
30
|
style_cleanup(docxml)
|
69
31
|
para_type_cleanup(docxml)
|
70
32
|
docxml
|
71
33
|
end
|
72
34
|
|
35
|
+
def make_WordToC(docxml, level)
|
36
|
+
toc = ""
|
37
|
+
xpath = (1..level).each.map do |i|
|
38
|
+
"//h#{i}[not(ancestor::*[@class = 'WordSection2'])]"
|
39
|
+
end.join (" | ")
|
40
|
+
docxml.xpath(xpath).each do |h|
|
41
|
+
toc += word_toc_entry(h.name[1].to_i, header_strip(h))
|
42
|
+
end
|
43
|
+
toc.sub(/(<p class="MsoToc1">)/,
|
44
|
+
%{\\1#{word_toc_preface(level)}}) + WORD_TOC_SUFFIX1
|
45
|
+
end
|
46
|
+
|
47
|
+
def biblio_cleanup(docxml)
|
48
|
+
docxml.xpath("//p[@class = 'Biblio']").each do |p|
|
49
|
+
headings_strip(p)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
73
53
|
def headings_cleanup(docxml)
|
74
|
-
(1..
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
54
|
+
(1..9).each { |i| headings_cleanup1(docxml, i) }
|
55
|
+
docxml.xpath("//div[@class = 'Annex']").each { |a| a.delete("class") }
|
56
|
+
end
|
57
|
+
|
58
|
+
def headings_cleanup1(docxml, idx)
|
59
|
+
docxml.xpath("//h#{idx}").each do |h|
|
60
|
+
headings_strip(h)
|
61
|
+
headings_style(h, idx)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def headings_style(hdr, idx)
|
66
|
+
if hdr.at("./ancestor::div[@class = 'Annex']")
|
67
|
+
hdr.delete("class")
|
68
|
+
hdr["style"] = "mso-list:l13 level#{idx} lfo33;"
|
69
|
+
elsif hdr.at("./ancestor::div[@class = 'Section3']")
|
70
|
+
hdr.name = "p"
|
71
|
+
hdr["class"] = "IEEEStdsLevel#{idx}frontmatter"
|
72
|
+
else
|
73
|
+
hdr.name = "p"
|
74
|
+
hdr["class"] = "IEEEStdsLevel#{idx}Header"
|
80
75
|
end
|
81
76
|
end
|
82
77
|
|
83
|
-
def
|
78
|
+
def headings_strip(hdr)
|
84
79
|
if hdr.children.size > 1 && hdr.children[1].name == "span" &&
|
85
80
|
hdr.children[1]["style"] == "mso-tab-count:1"
|
86
81
|
2.times { hdr.children.first.remove }
|
@@ -100,28 +95,23 @@ module IsoDoc
|
|
100
95
|
end
|
101
96
|
end
|
102
97
|
|
103
|
-
def para_type_cleanup(html)
|
104
|
-
html.xpath("//p[@type]").each { |p| p.delete("type") }
|
105
|
-
end
|
106
|
-
|
107
|
-
def span_style_cleanup(html)
|
108
|
-
html.xpath("//strong").each do |s|
|
109
|
-
s.name = "span"
|
110
|
-
s["class"] = "IEEEStdsParaBold"
|
111
|
-
end
|
112
|
-
html.xpath("//em").each do |s|
|
113
|
-
s.name = "span"
|
114
|
-
s["class"] = "IEEEStdsAddItal"
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
98
|
STYLESMAP = {
|
99
|
+
example: "IEEEStdsParagraph",
|
119
100
|
MsoNormal: "IEEEStdsParagraph",
|
120
|
-
NormRef: "
|
101
|
+
NormRef: "IEEEStdsParagraph",
|
121
102
|
Biblio: "IEEEStdsBibliographicEntry",
|
103
|
+
figure: "IEEEStdsImage",
|
104
|
+
formula: "IEEEStdsEquation",
|
105
|
+
Sourcecode: "IEEEStdsComputerCode",
|
106
|
+
TableTitle: "IEEEStdsRegularTableCaption",
|
107
|
+
FigureTitle: "IEEEStdsRegularFigureCaption",
|
122
108
|
}.freeze
|
123
109
|
|
124
110
|
def style_cleanup(docxml)
|
111
|
+
note_style_cleanup(docxml)
|
112
|
+
docxml.xpath("//div[@class = 'formula']/p").each do |p|
|
113
|
+
p["class"] = "IEEEStdsEquation"
|
114
|
+
end
|
125
115
|
STYLESMAP.each do |k, v|
|
126
116
|
docxml.xpath("//*[@class = '#{k}']").each { |s| s["class"] = v }
|
127
117
|
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
module IsoDoc
|
2
|
+
module IEEE
|
3
|
+
class WordConvert < IsoDoc::WordConvert
|
4
|
+
def admonition_cleanup(docxml)
|
5
|
+
super
|
6
|
+
docxml.xpath("//div[@class = 'zzHelp']").each do |d|
|
7
|
+
d.xpath(".//p").each do |p|
|
8
|
+
%w(IEEEStdsWarning IEEEStdsParagraph).include?(p["class"]) ||
|
9
|
+
!p["class"] or next
|
10
|
+
|
11
|
+
p["class"] = "zzHelp"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
docxml
|
15
|
+
end
|
16
|
+
|
17
|
+
def table_cleanup(docxml)
|
18
|
+
thead_cleanup(docxml)
|
19
|
+
tbody_cleanup(docxml)
|
20
|
+
end
|
21
|
+
|
22
|
+
def thead_cleanup(docxml)
|
23
|
+
docxml.xpath("//thead").each do |h|
|
24
|
+
h.xpath(".//td | .//th").each do |t|
|
25
|
+
if t.at("./p")
|
26
|
+
t.xpath("./p").each do |p|
|
27
|
+
p["class"] = "IEEEStdsTableColumnHead"
|
28
|
+
end
|
29
|
+
else
|
30
|
+
t.children =
|
31
|
+
"<p class='IEEEStdsTableColumnHead'>#{t.children.to_xml}</p>"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def tbody_cleanup(docxml)
|
38
|
+
docxml.xpath("//tbody | //tfoot").each do |h|
|
39
|
+
next if h.at("./ancestor::div[@class = 'boilerplate-feedback']")
|
40
|
+
|
41
|
+
h.xpath(".//th").each { |t| tbody_head_cleanup(t) }
|
42
|
+
h.xpath(".//td | .//th").each { |t| tbody_cleanup1(t) }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def tbody_head_cleanup(cell)
|
47
|
+
cell.at("./p") or
|
48
|
+
cell.children = "<p>#{cell.children.to_xml}</p>"
|
49
|
+
cell.xpath("./p").each do |p|
|
50
|
+
p.replace p.to_xml.gsub(%r{<br/>}, "</p><p>")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def tbody_cleanup1(cell)
|
55
|
+
if cell.at("./p")
|
56
|
+
cell.xpath("./p").each_with_index do |p, i|
|
57
|
+
p["class"] = td_style(cell, i)
|
58
|
+
end
|
59
|
+
else
|
60
|
+
cell.children =
|
61
|
+
"<p class='#{td_style(cell, 0)}'>#{cell.children.to_xml}</p>"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def td_style(cell, idx)
|
66
|
+
if cell.name == "th" && idx.zero? then "IEEEStdsTableLineHead"
|
67
|
+
elsif cell.name == "th" then "IEEEStdsTableLineSubhead"
|
68
|
+
elsif cell["align"] == "center" ||
|
69
|
+
/text-align:center/.match?(cell["style"])
|
70
|
+
"IEEEStdsTableData-Center"
|
71
|
+
else "IEEEStdsTableData-Left"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def caption_cleanup(docxml)
|
76
|
+
table_caption(docxml)
|
77
|
+
figure_caption(docxml)
|
78
|
+
example_caption(docxml)
|
79
|
+
end
|
80
|
+
|
81
|
+
def table_caption(docxml)
|
82
|
+
docxml.xpath("//p[@class = 'TableTitle']").each do |s|
|
83
|
+
s.children = s.children.to_xml
|
84
|
+
.sub(/^#{@i18n.table}(\s+[A-Z0-9.]+)?/, "")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def figure_caption(docxml)
|
89
|
+
docxml.xpath("//p[@class = 'FigureTitle']").each do |s|
|
90
|
+
s.children = s.children.to_xml
|
91
|
+
.sub(/^#{@i18n.figure}(\s+[A-Z0-9.]+)?/, "")
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def example_caption(docxml)
|
96
|
+
docxml.xpath("//p[@class = 'example-title']").each do |s|
|
97
|
+
s.children = "<em>#{s.children.to_xml}</em>"
|
98
|
+
s["class"] = "IEEEStdsParagraph"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def sourcecode_cleanup(docxml)
|
103
|
+
docxml.xpath("//p[@class = 'Sourcecode']").each do |s|
|
104
|
+
s.replace(s.to_xml.gsub(%r{<br/>}, "</p><p class='Sourcecode'>"))
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def para_type_cleanup(html)
|
109
|
+
html.xpath("//p[@type]").each { |p| p.delete("type") }
|
110
|
+
end
|
111
|
+
|
112
|
+
def note_style_cleanup(docxml)
|
113
|
+
docxml.xpath("//span[@class = 'note_label']").each do |s|
|
114
|
+
multi = /^#{@i18n.note}\s+[A-Z0-9.]+/.match?(s.text)
|
115
|
+
div = s.at("./ancestor::div[@class = 'Note']")
|
116
|
+
if multi
|
117
|
+
s.remove
|
118
|
+
seq = notesequence(div)
|
119
|
+
else seq = nil
|
120
|
+
end
|
121
|
+
note_style_cleanup1(multi, div, seq)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def notesequence(div)
|
126
|
+
@notesequences ||= { max: 0, lookup: {} }
|
127
|
+
unless id = @notesequences[:lookup][@xrefs.anchor(div["id"],
|
128
|
+
:sequence)]
|
129
|
+
@notesequences[:max] += 1
|
130
|
+
id = @notesequences[:max]
|
131
|
+
@notesequences[:lookup][@xrefs.anchor(div["id"], :sequence)] =
|
132
|
+
id
|
133
|
+
end
|
134
|
+
id
|
135
|
+
end
|
136
|
+
|
137
|
+
# hardcoded list style for notes
|
138
|
+
def note_style_cleanup1(multi, div, seq)
|
139
|
+
div.xpath(".//p[@class = 'Note' or not(@class)]")
|
140
|
+
.each_with_index do |p, i|
|
141
|
+
p["class"] =
|
142
|
+
i.zero? && multi ? "IEEEStdsMultipleNotes" : "IEEEStdsSingleNote"
|
143
|
+
if multi
|
144
|
+
p["style"] ||= ""
|
145
|
+
p["style"] += "mso-list:l17 level1 lfo#{seq};"
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require "isodoc"
|
2
2
|
require_relative "init"
|
3
3
|
require_relative "word_cleanup"
|
4
|
+
require_relative "word_cleanup_blocks"
|
4
5
|
require_relative "word_authority"
|
5
6
|
|
6
7
|
module IsoDoc
|
@@ -11,6 +12,14 @@ module IsoDoc
|
|
11
12
|
super
|
12
13
|
end
|
13
14
|
|
15
|
+
def convert1(docxml, filename, dir)
|
16
|
+
doctype = docxml.at(ns("//bibdata/ext/doctype"))
|
17
|
+
if %w(amendment corrigendum).include?(doctype&.text)
|
18
|
+
@header = html_doc_path("header_amd.html")
|
19
|
+
end
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
14
23
|
def default_fonts(options)
|
15
24
|
{ bodyfont: (if options[:script] == "Hans"
|
16
25
|
'"Source Han Sans",serif'
|
@@ -35,8 +44,7 @@ module IsoDoc
|
|
35
44
|
header: html_doc_path("header.html"),
|
36
45
|
wordcoverpage: html_doc_path("word_ieee_titlepage.html"),
|
37
46
|
wordintropage: html_doc_path("word_ieee_intro.html"),
|
38
|
-
ulstyle: "
|
39
|
-
olstyle: "l2" }
|
47
|
+
ulstyle: "l11", olstyle: "l16" }
|
40
48
|
end
|
41
49
|
|
42
50
|
def abstract(isoxml, out)
|
@@ -65,6 +73,94 @@ module IsoDoc
|
|
65
73
|
def middle_title_ieee(_docxml, out)
|
66
74
|
out.p(**{ class: "IEEEStdsTitle", style: "margin-top:70.0pt" }) do |p|
|
67
75
|
p << @meta.get[:full_doctitle]
|
76
|
+
@meta.get[:amd] || @meta.get[:corr] and p << "<br/>"
|
77
|
+
@meta.get[:amd] and p << "Amendment #{@meta.get[:amd]}"
|
78
|
+
@meta.get[:amd] && @meta.get[:corr] and p << " "
|
79
|
+
@meta.get[:corr] and p << "Corrigenda #{@meta.get[:corr]}"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def admonition_name_parse(_node, div, name)
|
84
|
+
div.p **{ class: "IEEEStdsWarning", style: "text-align:center;" } do |p|
|
85
|
+
p.b do |b|
|
86
|
+
name.children.each { |n| parse(n, b) }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def admonition_class(node)
|
92
|
+
if node["type"] == "editorial" then "zzHelp"
|
93
|
+
elsif node.ancestors("introduction").empty?
|
94
|
+
"IEEEStdsWarning"
|
95
|
+
else "IEEEStdsIntroduction"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def dt_dd?(node)
|
100
|
+
%w{dt dd}.include? node.name
|
101
|
+
end
|
102
|
+
|
103
|
+
def formula_where(dlist, out)
|
104
|
+
return unless dlist
|
105
|
+
|
106
|
+
dlist.elements.select { |n| dt_dd? n }.each_slice(2) do |dt, dd|
|
107
|
+
formula_where1(out, dt, dd)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def formula_where1(out, dterm, ddefn)
|
112
|
+
out.p **{ class: "IEEEStdsEquationVariableList" } do |p|
|
113
|
+
dterm.children.each { |n| parse(n, p) }
|
114
|
+
insert_tab(p, 1)
|
115
|
+
if ddefn.at(ns("./p"))
|
116
|
+
ddefn.elements.each do |e|
|
117
|
+
e.children.each { |n| parse(n, p) }
|
118
|
+
end
|
119
|
+
else ddefn.children.each { |n| parse(n, p) }
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def annex_attrs(node)
|
125
|
+
{ id: node["id"], class: "Annex" }
|
126
|
+
end
|
127
|
+
|
128
|
+
def annex_name(_annex, name, div)
|
129
|
+
preceding_floating_titles(name, div)
|
130
|
+
return if name.nil?
|
131
|
+
|
132
|
+
name&.at(ns("./strong"))&.remove # supplied by CSS list numbering
|
133
|
+
div.h1 **{ class: "Annex" } do |t|
|
134
|
+
annex_name1(name, t)
|
135
|
+
clause_parse_subtitle(name, t)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def annex_name1(name, out)
|
140
|
+
name.children.each do |c2|
|
141
|
+
if c2.name == "span" && c2["class"] == "obligation"
|
142
|
+
out.span **{ style: "font-weight:normal;" } do |s|
|
143
|
+
c2.children.each { |c3| parse(c3, s) }
|
144
|
+
end
|
145
|
+
else parse(c2, out)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def termnote_parse(node, out)
|
151
|
+
name = node&.at(ns("./name"))&.remove
|
152
|
+
out.div **note_attrs(node) do |div|
|
153
|
+
div.p do |p|
|
154
|
+
name and termnote_label(p, name)
|
155
|
+
para_then_remainder(node.first_element_child, node, p, div)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def termnote_label(para, name)
|
161
|
+
para.span **{ class: "note_label" } do |s|
|
162
|
+
name.children.each { |n| parse(n, s) }
|
163
|
+
s << termnote_delim
|
68
164
|
end
|
69
165
|
end
|
70
166
|
|
data/lib/isodoc/ieee/xref.rb
CHANGED
@@ -72,6 +72,37 @@ module IsoDoc
|
|
72
72
|
)
|
73
73
|
end
|
74
74
|
end
|
75
|
+
|
76
|
+
def termnote_anchor_names(docxml)
|
77
|
+
docxml.xpath(ns("//*[termnote]")).each do |t|
|
78
|
+
c = Counter.new
|
79
|
+
sequence = UUIDTools::UUID.random_create.to_s
|
80
|
+
notes = t.xpath(ns("./termnote"))
|
81
|
+
notes.reject { |n| blank?(n["id"]) }.each do |n|
|
82
|
+
@anchors[n["id"]] =
|
83
|
+
anchor_struct("#{@labels['termnote']} #{increment_label(notes, n, c)}",
|
84
|
+
n,
|
85
|
+
@labels["note_xref"], "termnote", false)
|
86
|
+
.merge(sequence: sequence)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def note_anchor_names1(notes, counter)
|
92
|
+
sequence = UUIDTools::UUID.random_create.to_s
|
93
|
+
notes.each do |n|
|
94
|
+
next if @anchors[n["id"]] || blank?(n["id"])
|
95
|
+
|
96
|
+
@anchors[n["id"]] =
|
97
|
+
anchor_struct(increment_label(notes, n, counter), n,
|
98
|
+
@labels["note_xref"], "note", false)
|
99
|
+
.merge(sequence: sequence)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def annex_name_lbl(clause, num)
|
104
|
+
super.sub(%r{<br/>(.*)$}, "<br/><span class='obligation'>\\1</span>")
|
105
|
+
end
|
75
106
|
end
|
76
107
|
end
|
77
108
|
end
|