metanorma-ieee 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- 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/html_ieee_titlepage.html +11 -0
- 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 +23 -255
- data/lib/isodoc/ieee/html/ieee.scss +22 -239
- data/lib/isodoc/ieee/html/word_ieee_intro.html +1 -1
- data/lib/isodoc/ieee/html/wordstyle.css +20 -23
- data/lib/isodoc/ieee/html/wordstyle.scss +20 -17
- data/lib/isodoc/ieee/i18n-en.yaml +4 -0
- data/lib/isodoc/ieee/ieee.amendment.xsl +1835 -736
- data/lib/isodoc/ieee/ieee.standard.xsl +1835 -736
- data/lib/isodoc/ieee/metadata.rb +25 -4
- data/lib/isodoc/ieee/presentation_terms.rb +15 -2
- data/lib/isodoc/ieee/presentation_xml_convert.rb +85 -0
- data/lib/isodoc/ieee/word_authority.rb +54 -0
- 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 +86 -2
- data/lib/isodoc/ieee/xref.rb +31 -0
- data/lib/metanorma/ieee/boilerplate.xml +4 -4
- data/lib/metanorma/ieee/cleanup.rb +37 -73
- data/lib/metanorma/ieee/cleanup_ref.rb +117 -0
- data/lib/metanorma/ieee/front.rb +14 -10
- data/lib/metanorma/ieee/isodoc.rng +16 -0
- data/lib/metanorma/ieee/validate.rb +50 -6
- data/lib/metanorma/ieee/validate_section.rb +14 -7
- data/lib/metanorma/ieee/validate_style.rb +5 -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
- metadata +8 -2
data/lib/isodoc/ieee/metadata.rb
CHANGED
@@ -46,7 +46,7 @@ module IsoDoc
|
|
46
46
|
|
47
47
|
def tc(xml)
|
48
48
|
tc = xml.at(ns("//bibdata/ext/editorialgroup/"\
|
49
|
-
"
|
49
|
+
"committee"))&.text || "<Committee Name>"
|
50
50
|
set(:technical_committee, tc)
|
51
51
|
end
|
52
52
|
|
@@ -126,10 +126,31 @@ module IsoDoc
|
|
126
126
|
super
|
127
127
|
draft = isoxml&.at(ns("//bibdata/version/draft"))
|
128
128
|
doctype(isoxml, _out)
|
129
|
-
|
130
|
-
|
129
|
+
set(:full_doctitle, fulltitle(@metadata[:doctype], draft))
|
130
|
+
set(:abbrev_doctitle, fulltitle(@metadata[:doctype_abbrev], draft))
|
131
|
+
end
|
132
|
+
|
133
|
+
def fulltitle(type, draft)
|
134
|
+
title = "#{type || '???'} for #{@metadata[:doctitle] || '???'}"
|
131
135
|
draft and title = "Draft #{title}"
|
132
|
-
|
136
|
+
title
|
137
|
+
end
|
138
|
+
|
139
|
+
def relations(isoxml, _out)
|
140
|
+
super
|
141
|
+
relations_get(isoxml, "updates")
|
142
|
+
relations_get(isoxml, "merges")
|
143
|
+
end
|
144
|
+
|
145
|
+
def relations_get(isoxml, type)
|
146
|
+
std = isoxml.xpath(ns("//bibdata/relation[@type = '#{type}']"))
|
147
|
+
return if std.empty?
|
148
|
+
|
149
|
+
ret = std.map do |x|
|
150
|
+
x.at(ns(".//docidentifier[@primary = 'true']"))&.text ||
|
151
|
+
x.at(ns(".//docidentifier"))&.text
|
152
|
+
end
|
153
|
+
set(type.to_sym, ret)
|
133
154
|
end
|
134
155
|
end
|
135
156
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative "../../relaton/render/general"
|
2
|
+
|
1
3
|
module IsoDoc
|
2
4
|
module IEEE
|
3
5
|
class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
|
@@ -131,11 +133,12 @@ module IsoDoc
|
|
131
133
|
|
132
134
|
def collapse_term_template(opt)
|
133
135
|
defn = collapse_unwrap_definition(opt[:def])
|
134
|
-
|
136
|
+
src = nil
|
137
|
+
opt[:source] and src = "(#{opt[:source].remove.children.to_xml.strip})"
|
135
138
|
<<~TERM
|
136
139
|
<p>#{opt[:pref].children.to_xml}: #{defn}
|
137
140
|
#{collapse_term_related(opt[:rels])}
|
138
|
-
#{
|
141
|
+
#{src}</p>
|
139
142
|
TERM
|
140
143
|
end
|
141
144
|
|
@@ -175,7 +178,17 @@ module IsoDoc
|
|
175
178
|
end
|
176
179
|
end
|
177
180
|
|
181
|
+
def termnote1(elem)
|
182
|
+
lbl = l10n(@xrefs.anchor(elem["id"], :label)&.strip || "???")
|
183
|
+
prefix_name(elem, block_delim, lower2cap(lbl), "name")
|
184
|
+
end
|
185
|
+
|
178
186
|
def term(docxml); end
|
187
|
+
|
188
|
+
def concept1(node)
|
189
|
+
concept_render(node, ital: "false", ref: "false",
|
190
|
+
linkref: "false", linkmention: "false")
|
191
|
+
end
|
179
192
|
end
|
180
193
|
end
|
181
194
|
end
|
@@ -53,6 +53,35 @@ module IsoDoc
|
|
53
53
|
l10n(ret)
|
54
54
|
end
|
55
55
|
|
56
|
+
# Style manual 19
|
57
|
+
def anchor_linkend(node, linkend)
|
58
|
+
@bibanchors ||= biblio_ids_titles(node.document)
|
59
|
+
if node["citeas"] && i = @bibanchors[node["bibitemid"]]
|
60
|
+
biblio_anchor_linkend(node, i)
|
61
|
+
else super
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def biblio_anchor_linkend(node, bib)
|
66
|
+
if %w(techreport standard).include?(bib[:type])
|
67
|
+
node["citeas"] + " #{bib[:ord]}"
|
68
|
+
else
|
69
|
+
"#{bib[:title]} " + node["citeas"]
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def biblio_ids_titles(xmldoc)
|
74
|
+
xmldoc.xpath(ns("//references[@normative = 'false']/bibitem"))
|
75
|
+
.each_with_object({}) do |b, m|
|
76
|
+
m[b["id"]] =
|
77
|
+
{ docid: pref_ref_code(b), type: b["type"],
|
78
|
+
title: b.at(ns("./title"))&.text ||
|
79
|
+
b.at(ns("./formattedref"))&.text,
|
80
|
+
ord: b.at(ns("./docidentifier[@type = 'metanorma' or "\
|
81
|
+
"@type = 'metanorma-ordinal']")).text }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
56
85
|
def anchor_linkend1(node)
|
57
86
|
linkend = @xrefs.anchor(node["target"], :xref)
|
58
87
|
@xrefs.anchor(node["target"], :type) == "clause" &&
|
@@ -69,6 +98,18 @@ module IsoDoc
|
|
69
98
|
"—"
|
70
99
|
end
|
71
100
|
|
101
|
+
def note1(elem)
|
102
|
+
return if elem.parent.name == "bibitem" || elem["notag"] == "true"
|
103
|
+
|
104
|
+
n = @xrefs.get[elem["id"]]
|
105
|
+
lbl = if n.nil? || n[:label].nil? || n[:label].empty?
|
106
|
+
@i18n.note
|
107
|
+
else
|
108
|
+
l10n("#{@i18n.note} #{n[:label]}")
|
109
|
+
end
|
110
|
+
prefix_name(elem, block_delim, lbl, "name")
|
111
|
+
end
|
112
|
+
|
72
113
|
def display_order(docxml)
|
73
114
|
i = 0
|
74
115
|
i = display_order_xpath(docxml, "//preface/*", i)
|
@@ -83,6 +124,50 @@ module IsoDoc
|
|
83
124
|
display_order_xpath(docxml, "//indexsect", i)
|
84
125
|
end
|
85
126
|
|
127
|
+
def bibrenderer
|
128
|
+
::Relaton::Render::IEEE::General.new(language: @lang,
|
129
|
+
i18nhash: @i18n.get)
|
130
|
+
end
|
131
|
+
|
132
|
+
def bibrender_relaton(xml)
|
133
|
+
bib = xml.dup
|
134
|
+
bib["suppress_identifier"] == true and
|
135
|
+
bib.xpath(ns("./docidentifier")).each(&:remove)
|
136
|
+
xml.children =
|
137
|
+
"#{bibrenderer.render(bib.to_xml)}"\
|
138
|
+
"#{xml.xpath(ns('./docidentifier | ./uri | ./note | ./title')).to_xml}"
|
139
|
+
end
|
140
|
+
|
141
|
+
def creatornames(bibitem)
|
142
|
+
::Relaton::Render::IEEE::General
|
143
|
+
.new(language: @lang, i18nhash: @i18n.get,
|
144
|
+
template: { (bibitem["type"] || "misc").to_sym =>
|
145
|
+
"{{ creatornames }}" })
|
146
|
+
.parse1(RelatonBib::XMLParser.from_xml(bibitem.to_xml))
|
147
|
+
end
|
148
|
+
|
149
|
+
def bibliography_bibitem_number1(bibitem, idx)
|
150
|
+
if mn = bibitem.at(ns(".//docidentifier[@type = 'metanorma']"))
|
151
|
+
/^\[?\d\]?$/.match?(mn&.text) and
|
152
|
+
idx = mn.text.sub(/^\[B?/, "").sub(/\]$/, "").to_i
|
153
|
+
end
|
154
|
+
unless bibliography_bibitem_number_skip(bibitem)
|
155
|
+
|
156
|
+
idx += 1
|
157
|
+
bibitem.at(ns(".//docidentifier")).previous =
|
158
|
+
"<docidentifier type='metanorma-ordinal'>[B#{idx}]</docidentifier>"
|
159
|
+
end
|
160
|
+
idx
|
161
|
+
end
|
162
|
+
|
163
|
+
def annex1(elem)
|
164
|
+
lbl = @xrefs.anchor(elem["id"], :label)
|
165
|
+
if t = elem.at(ns("./title"))
|
166
|
+
t.children = "<strong>#{t.children.to_xml}</strong>"
|
167
|
+
end
|
168
|
+
prefix_name(elem, "<br/>", lbl, "title")
|
169
|
+
end
|
170
|
+
|
86
171
|
include Init
|
87
172
|
end
|
88
173
|
end
|
@@ -125,6 +125,10 @@ module IsoDoc
|
|
125
125
|
docxml.at("//div[@class = 'boilerplate-feedback']")&.xpath("./div")
|
126
126
|
&.each_with_index do |div, i|
|
127
127
|
i.zero? or div.elements.first.previous = "<p> </p>"
|
128
|
+
i == 4 and
|
129
|
+
div.xpath(".//p[br]").each do |p|
|
130
|
+
p.replace(p.to_xml.gsub(%r{<br/>}, "</p><p>"))
|
131
|
+
end
|
128
132
|
feedback_style1(div, i)
|
129
133
|
end
|
130
134
|
end
|
@@ -155,6 +159,56 @@ module IsoDoc
|
|
155
159
|
end
|
156
160
|
end
|
157
161
|
end
|
162
|
+
|
163
|
+
def abstract_cleanup(docxml)
|
164
|
+
dest = docxml.at("div[@id = 'abstract-destination']") or return
|
165
|
+
if f = docxml.at("//div[@class = 'abstract']")
|
166
|
+
f.previous_element.remove
|
167
|
+
abstract_cleanup1(f, dest)
|
168
|
+
f.remove
|
169
|
+
elsif f = docxml.at("//div[@type = 'scope']")
|
170
|
+
abstract_cleanup1(f, dest)
|
171
|
+
abstract_header(dest)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
def abstract_cleanup1(source, dest)
|
176
|
+
source.elements.reject { |e| %w(h1 h2).include?(e.name) }.each do |e|
|
177
|
+
e1 = e.dup
|
178
|
+
e1.xpath(".//p").each do |p|
|
179
|
+
p["style"] ||= ""
|
180
|
+
p["style"] = 'font-family: "Arial", sans-serif;' + p["style"]
|
181
|
+
end
|
182
|
+
%w(ul ol).include?(e1.name) or e1["class"] = "IEEEStdsAbstractBody"
|
183
|
+
dest << e1
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def abstract_header(dest)
|
188
|
+
dest.elements.first.children.first.previous =
|
189
|
+
"<span class='IEEEStdsAbstractHeader'><span lang='EN-US'>"\
|
190
|
+
"Abstract:</span></span> "
|
191
|
+
end
|
192
|
+
|
193
|
+
def introduction_cleanup(docxml)
|
194
|
+
dest = docxml.at("div[@id = 'introduction-destination']") or return
|
195
|
+
unless i = docxml.at("//h1[@class = 'IntroTitle']")&.parent
|
196
|
+
dest.parent.remove
|
197
|
+
return
|
198
|
+
end
|
199
|
+
introduction_cleanup1(i, dest)
|
200
|
+
end
|
201
|
+
|
202
|
+
def introduction_cleanup1(intro, dest)
|
203
|
+
docxml = intro.document
|
204
|
+
intro.previous_element.remove
|
205
|
+
dest.replace(intro.remove)
|
206
|
+
i = docxml.at("//h1[@class = 'IntroTitle']")
|
207
|
+
if i.next_element.name == "div" &&
|
208
|
+
i.next_element["class"] == "IEEEStdsIntroduction"
|
209
|
+
i.next_element.name = "p"
|
210
|
+
end
|
211
|
+
end
|
158
212
|
end
|
159
213
|
end
|
160
214
|
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
|
@@ -35,8 +36,7 @@ module IsoDoc
|
|
35
36
|
header: html_doc_path("header.html"),
|
36
37
|
wordcoverpage: html_doc_path("word_ieee_titlepage.html"),
|
37
38
|
wordintropage: html_doc_path("word_ieee_intro.html"),
|
38
|
-
ulstyle: "
|
39
|
-
olstyle: "l2" }
|
39
|
+
ulstyle: "l11", olstyle: "l16" }
|
40
40
|
end
|
41
41
|
|
42
42
|
def abstract(isoxml, out)
|
@@ -68,6 +68,90 @@ module IsoDoc
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
def admonition_name_parse(_node, div, name)
|
72
|
+
div.p **{ class: "IEEEStdsWarning", style: "text-align:center;" } do |p|
|
73
|
+
p.b do |b|
|
74
|
+
name.children.each { |n| parse(n, b) }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def admonition_class(node)
|
80
|
+
if node["type"] == "editorial" then "zzHelp"
|
81
|
+
elsif node.ancestors("introduction").empty?
|
82
|
+
"IEEEStdsWarning"
|
83
|
+
else "IEEEStdsIntroduction"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def dt_dd?(node)
|
88
|
+
%w{dt dd}.include? node.name
|
89
|
+
end
|
90
|
+
|
91
|
+
def formula_where(dlist, out)
|
92
|
+
return unless dlist
|
93
|
+
|
94
|
+
dlist.elements.select { |n| dt_dd? n }.each_slice(2) do |dt, dd|
|
95
|
+
formula_where1(out, dt, dd)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def formula_where1(out, dterm, ddefn)
|
100
|
+
out.p **{ class: "IEEEStdsEquationVariableList" } do |p|
|
101
|
+
dterm.children.each { |n| parse(n, p) }
|
102
|
+
insert_tab(p, 1)
|
103
|
+
if ddefn.at(ns("./p"))
|
104
|
+
ddefn.elements.each do |e|
|
105
|
+
e.children.each { |n| parse(n, p) }
|
106
|
+
end
|
107
|
+
else ddefn.children.each { |n| parse(n, p) }
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def annex_attrs(node)
|
113
|
+
{ id: node["id"], class: "Annex" }
|
114
|
+
end
|
115
|
+
|
116
|
+
def annex_name(_annex, name, div)
|
117
|
+
preceding_floating_titles(name, div)
|
118
|
+
return if name.nil?
|
119
|
+
|
120
|
+
name&.at(ns("./strong"))&.remove # supplied by CSS list numbering
|
121
|
+
div.h1 **{ class: "Annex" } do |t|
|
122
|
+
annex_name1(name, t)
|
123
|
+
clause_parse_subtitle(name, t)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def annex_name1(name, out)
|
128
|
+
name.children.each do |c2|
|
129
|
+
if c2.name == "span" && c2["class"] == "obligation"
|
130
|
+
out.span **{ style: "font-weight:normal;" } do |s|
|
131
|
+
c2.children.each { |c3| parse(c3, s) }
|
132
|
+
end
|
133
|
+
else parse(c2, out)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def termnote_parse(node, out)
|
139
|
+
name = node&.at(ns("./name"))&.remove
|
140
|
+
out.div **note_attrs(node) do |div|
|
141
|
+
div.p do |p|
|
142
|
+
name and termnote_label(p, name)
|
143
|
+
para_then_remainder(node.first_element_child, node, p, div)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def termnote_label(para, name)
|
149
|
+
para.span **{ class: "note_label" } do |s|
|
150
|
+
name.children.each { |n| parse(n, s) }
|
151
|
+
s << termnote_delim
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
71
155
|
include BaseConvert
|
72
156
|
include Init
|
73
157
|
end
|