metanorma-jis 0.0.3 → 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/lib/html2doc/lists.rb +22 -66
- data/lib/isodoc/jis/base_convert.rb +78 -11
- data/lib/isodoc/jis/figure.rb +99 -0
- data/lib/isodoc/jis/html/header.html +210 -818
- data/lib/isodoc/jis/html/isodoc.css +8 -37
- data/lib/isodoc/jis/html/isodoc.scss +8 -36
- data/lib/isodoc/jis/html/wordstyle.css +54 -0
- data/lib/isodoc/jis/html/wordstyle.scss +51 -0
- data/lib/isodoc/jis/i18n-en.yaml +6 -0
- data/lib/isodoc/jis/i18n-ja.yaml +8 -1
- data/lib/isodoc/jis/jis.international-standard.xsl +230 -35
- data/lib/isodoc/jis/metadata.rb +7 -0
- data/lib/isodoc/jis/presentation_xml_convert.rb +105 -24
- data/lib/isodoc/jis/table.rb +58 -0
- data/lib/isodoc/jis/word_cleanup.rb +6 -6
- data/lib/isodoc/jis/word_convert.rb +27 -147
- data/lib/isodoc/jis/xref.rb +45 -0
- data/lib/metanorma/jis/cleanup.rb +2 -1
- data/lib/metanorma/jis/converter.rb +10 -0
- data/lib/metanorma/jis/front.rb +57 -15
- data/lib/metanorma/jis/isodoc.rng +29 -7
- data/lib/metanorma/jis/jis.rng +10 -0
- data/lib/metanorma/jis/processor.rb +2 -2
- data/lib/metanorma/jis/version.rb +1 -1
- data/metanorma-jis.gemspec +2 -2
- metadata +7 -5
@@ -22,7 +22,7 @@ module IsoDoc
|
|
22
22
|
def strong1(text)
|
23
23
|
jpan = /^[#{JPAN}]/o.match?(text[0])
|
24
24
|
ret = jpan ? JPAN_BOLD : "<strong>"
|
25
|
-
text.
|
25
|
+
text.chars.each do |n|
|
26
26
|
new = /^[#{JPAN}]/o.match?(n)
|
27
27
|
jpan && !new and ret += "</span><strong>"
|
28
28
|
!jpan && new and ret += "</strong>#{JPAN_BOLD}"
|
@@ -33,6 +33,10 @@ module IsoDoc
|
|
33
33
|
ret
|
34
34
|
end
|
35
35
|
|
36
|
+
def admits(elem)
|
37
|
+
elem.children.first.previous = @i18n.l10n("#{@i18n.admitted}: ")
|
38
|
+
end
|
39
|
+
|
36
40
|
def block(docxml)
|
37
41
|
super
|
38
42
|
dl docxml
|
@@ -50,35 +54,74 @@ module IsoDoc
|
|
50
54
|
end
|
51
55
|
|
52
56
|
def dl_to_para(node)
|
57
|
+
ret = dl_to_para_name(node)
|
58
|
+
ret += dl_to_para_terms(node)
|
59
|
+
node.elements.reject { |n| %w(dt dd name).include?(n.name) }.each do |x|
|
60
|
+
ret += x.to_xml
|
61
|
+
end
|
62
|
+
dl_id_insert(node, ret)
|
63
|
+
end
|
64
|
+
|
65
|
+
def dl_id_insert(node, ret)
|
66
|
+
a = node.replace(ret)
|
67
|
+
p = a.at("./descendant-or-self::xmlns:p")
|
68
|
+
node["id"] and p << "<bookmark id='#{node['id']}'/>"
|
69
|
+
a.xpath("./descendant-or-self::*[@id = '']").each { |x| x.delete("id") }
|
70
|
+
end
|
71
|
+
|
72
|
+
def dl_to_para_name(node)
|
73
|
+
e = node.at(ns("./name"))
|
74
|
+
"<p class='ListTitle'>#{e&.children&.to_xml || @i18n.key}</p>"
|
75
|
+
end
|
76
|
+
|
77
|
+
def dl_to_para_terms(node)
|
53
78
|
ret = ""
|
54
|
-
e = node.at(ns("./name")) and
|
55
|
-
ret += "<p class='ListTitle' id='#{dlist['id']}'>" \
|
56
|
-
"#{e.children.to_xml}</p>"
|
57
79
|
node.elements.select { |n| dt_dd?(n) }.each_slice(2) do |dt, dd|
|
58
|
-
term = dt
|
59
|
-
defn = dd
|
60
|
-
|
61
|
-
|
80
|
+
term = strip_para(dt)
|
81
|
+
defn = strip_para(dd)
|
82
|
+
bkmk = dd["id"] ? "<bookmark id='#{dd['id']}'/>" : ""
|
83
|
+
ret += "<p class='dl' id='#{dt['id']}'>#{term}: #{bkmk}#{defn}</p>"
|
62
84
|
end
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
node.
|
85
|
+
ret
|
86
|
+
end
|
87
|
+
|
88
|
+
def strip_para(node)
|
89
|
+
node.children.to_xml.gsub(%r{</?p( [^>]*)?>}, "")
|
68
90
|
end
|
69
91
|
|
70
92
|
def table1(node)
|
71
93
|
super
|
94
|
+
cols = table_cols_count(node)
|
95
|
+
name = node.at(ns("./name"))
|
96
|
+
thead = table_thead_pt(node, name)
|
97
|
+
table_unit_note(node, thead, cols)
|
98
|
+
table_name(name, thead, cols)
|
99
|
+
end
|
100
|
+
|
101
|
+
def table_thead_pt(node, name)
|
102
|
+
node.at(ns("./thead")) ||
|
103
|
+
name&.after("<thead> </thead>")&.next ||
|
104
|
+
node.elements.first.before("<thead> </thead>").previous
|
105
|
+
end
|
106
|
+
|
107
|
+
def table_cols_count(node)
|
72
108
|
cols = 0
|
73
109
|
node.at(ns(".//tr")).xpath(ns("./td | ./th")).each do |x|
|
74
110
|
cols += x["colspan"]&.to_i || 1
|
75
111
|
end
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
112
|
+
cols
|
113
|
+
end
|
114
|
+
|
115
|
+
def table_unit_note(node, thead, cols)
|
116
|
+
unit_note = node.at(ns(".//note[@type = 'units']")) or return
|
117
|
+
thead.children.first.previous = full_row(cols, unit_note.remove.to_xml)
|
118
|
+
end
|
119
|
+
|
120
|
+
def table_name(name, thead, cols)
|
121
|
+
name or return
|
122
|
+
thead.children.first.previous =
|
123
|
+
full_row(cols, "<p class='TableTitle' style='text-align:center;'> " \
|
124
|
+
"#{name.remove.children.to_xml}</p>")
|
82
125
|
end
|
83
126
|
|
84
127
|
def full_row(cols, elem)
|
@@ -86,12 +129,50 @@ module IsoDoc
|
|
86
129
|
end
|
87
130
|
|
88
131
|
def annex1(elem)
|
89
|
-
|
90
|
-
|
91
|
-
t
|
132
|
+
elem["commentary"] == "true" and return
|
133
|
+
lbl = @xrefs.anchor(elem["id"], :label)
|
134
|
+
if t = elem.at(ns("./title"))
|
135
|
+
t.children = "<strong>#{to_xml(t.children)}</strong>"
|
136
|
+
end
|
137
|
+
prefix_name(elem, "<br/>", lbl, "title")
|
138
|
+
end
|
139
|
+
|
140
|
+
def annex(docxml)
|
141
|
+
super
|
142
|
+
move_commentaries_to_end(docxml)
|
143
|
+
end
|
144
|
+
|
145
|
+
def move_commentaries_to_end(docxml)
|
146
|
+
docxml.at(ns("//annex[@commentary = 'true']")) or return
|
147
|
+
b = docxml.at(ns("//bibliography")) ||
|
148
|
+
docxml.at(ns("//annex[last()]")).after(" ").next
|
149
|
+
docxml.xpath(ns("//annex[@commentary = 'true']")).reverse.each do |x|
|
150
|
+
b.next = x.remove
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def display_order(docxml)
|
155
|
+
i = 0
|
156
|
+
i = display_order_xpath(docxml, "//preface/*", i)
|
157
|
+
i = display_order_at(docxml, "//clause[@type = 'scope']", i)
|
158
|
+
i = display_order_at(docxml, @xrefs.klass.norm_ref_xpath, i)
|
159
|
+
i = display_order_at(docxml, "//sections/terms | " \
|
160
|
+
"//sections/clause[descendant::terms]", i)
|
161
|
+
i = display_order_at(docxml, "//sections/definitions", i)
|
162
|
+
i = display_order_xpath(docxml, @xrefs.klass.middle_clause(docxml), i)
|
163
|
+
i = display_order_xpath(docxml, "//annex[not(@commentary = 'true')]", i)
|
164
|
+
i = display_order_xpath(docxml, @xrefs.klass.bibliography_xpath, i)
|
165
|
+
i = display_order_xpath(docxml, "//annex[@commentary = 'true']", i)
|
166
|
+
i = display_order_xpath(docxml, "//indexsect", i)
|
167
|
+
display_order_xpath(docxml, "//colophon/*", i)
|
168
|
+
end
|
169
|
+
|
170
|
+
def tablesource(elem)
|
171
|
+
while elem&.next_element&.name == "source"
|
172
|
+
elem << "; #{to_xml(elem.next_element.remove.children)}"
|
173
|
+
end
|
174
|
+
elem.children = l10n("#{@i18n.source}: #{to_xml(elem.children).strip}")
|
92
175
|
end
|
93
|
-
prefix_name(elem, "<br/>", lbl, "title")
|
94
|
-
end
|
95
176
|
|
96
177
|
include Init
|
97
178
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module IsoDoc
|
2
|
+
module JIS
|
3
|
+
class WordConvert < IsoDoc::Iso::WordConvert
|
4
|
+
def make_table_footnote_target(out, fnid, fnref)
|
5
|
+
attrs = { id: fnid, class: "TableFootnoteRef" }
|
6
|
+
out.span do |s|
|
7
|
+
s << @i18n.table_footnote
|
8
|
+
out.span **attrs do |a|
|
9
|
+
a << "#{fnref})"
|
10
|
+
end
|
11
|
+
insert_tab(s, 1)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def table_title_parse(node, out); end
|
16
|
+
|
17
|
+
def table_attrs(node)
|
18
|
+
{ id: node["id"], title: node["alt"],
|
19
|
+
summary: node["summary"], width: node["width"],
|
20
|
+
class: (node.text.length > 4000 ? "MsoTableGridBig" : "MsoTableGrid"),
|
21
|
+
style: "border-collapse:collapse;" \
|
22
|
+
"mso-table-anchor-horizontal:column;mso-table-overlap:never;" \
|
23
|
+
"border:none;mso-padding-alt: " \
|
24
|
+
"0cm 5.4pt 0cm 5.4pt;mso-border-insideh:none;" \
|
25
|
+
"mso-border-insidev:none;#{keep_style(node)}",
|
26
|
+
border: 0, cellspacing: 0, cellpadding: 0 }
|
27
|
+
end
|
28
|
+
|
29
|
+
def make_tr_attr_style(cell, row, rowmax, totalrows, opt)
|
30
|
+
top = row.zero? ? "#{SW1} 1.5pt;" : "none;"
|
31
|
+
bottom = "#{SW1} #{rowmax >= totalrows ? '1.5' : '1.0'}pt;"
|
32
|
+
ret = <<~STYLE.gsub(/\n/, "")
|
33
|
+
border-top:#{top}mso-border-top-alt:#{top}
|
34
|
+
border-left:#{bottom}mso-border-top-alt:#{bottom}
|
35
|
+
border-right:#{bottom}mso-border-top-alt:#{bottom}
|
36
|
+
border-bottom:#{bottom}mso-border-bottom-alt:#{bottom}
|
37
|
+
STYLE
|
38
|
+
opt[:bordered] or ret = ""
|
39
|
+
pb = keep_rows_together(cell, rowmax, totalrows, opt) ? "avoid" : "auto"
|
40
|
+
"#{ret}page-break-after:#{pb};"
|
41
|
+
end
|
42
|
+
|
43
|
+
def new_fullcolspan_row(table, tfoot)
|
44
|
+
# how many columns in the table?
|
45
|
+
cols = 0
|
46
|
+
table.at(".//tr").xpath("./td | ./th").each do |td|
|
47
|
+
cols += (td["colspan"] ? td["colspan"].to_i : 1)
|
48
|
+
end
|
49
|
+
style = "border-top:0pt;mso-border-top-alt:0pt;" \
|
50
|
+
"border-bottom:#{SW1} 1.5pt;mso-border-bottom-alt:#{SW1} 1.5pt;" \
|
51
|
+
"border-left:#{SW1} 1.5pt;mso-border-left-alt:#{SW1} 1.5pt;" \
|
52
|
+
"border-right:#{SW1} 1.5pt;mso-border-right-alt:#{SW1} 1.5pt;"
|
53
|
+
tfoot.add_child("<tr><td colspan='#{cols}' style='#{style}'/></tr>")
|
54
|
+
tfoot.xpath(".//td").last
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -21,10 +21,10 @@ module IsoDoc
|
|
21
21
|
def move_to_inner_cover(docxml)
|
22
22
|
source = docxml.at("//div[@type = 'inner-cover-note']")
|
23
23
|
dest = docxml.at("//div[@id = 'boilerplate-inner-cover-note']")
|
24
|
-
source && dest and dest.replace(source)
|
24
|
+
source && dest and dest.replace(source.remove)
|
25
25
|
source = docxml.at("//div[@type = 'contributors']")
|
26
26
|
dest = docxml.at("//div[@id = 'boilerplate-contributors']")
|
27
|
-
source && dest and dest.replace(source)
|
27
|
+
source && dest and dest.replace(source.remove)
|
28
28
|
docxml
|
29
29
|
end
|
30
30
|
|
@@ -120,22 +120,22 @@ module IsoDoc
|
|
120
120
|
def heading_to_para(docxml)
|
121
121
|
docxml.xpath("//h1[@class = 'ForewordTitle']").each do |p|
|
122
122
|
p.name = "p"
|
123
|
-
p.xpath("
|
123
|
+
p.parent.xpath("./p[not(@class) or @class = 'MsoNormal']").each do |n|
|
124
124
|
n["class"] = "ForewordText"
|
125
125
|
end
|
126
126
|
end
|
127
127
|
docxml.xpath("//h1[@class = 'IntroTitle'] | //h1[@class = 'Annex'] | " \
|
128
128
|
"//h2[@class = 'Terms'] | " \
|
129
129
|
"//h3[@class = 'Terms'] | //h4[@class = 'Terms'] | " \
|
130
|
-
"//h5[@class = 'Terms'] | //h6[@class = 'Terms']").each do |
|
131
|
-
|
130
|
+
"//h5[@class = 'Terms'] | //h6[@class = 'Terms']").each do |n|
|
131
|
+
n.name = "p"
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
135
|
def word_annex_cleanup1(docxml, lvl)
|
136
136
|
docxml.xpath("//h#{lvl}[ancestor::*[@class = 'Section3']]").each do |h2|
|
137
137
|
h2.name = "p"
|
138
|
-
h2["class"] = "
|
138
|
+
h2["class"] = "h#{lvl}Annex"
|
139
139
|
end
|
140
140
|
end
|
141
141
|
end
|
@@ -2,6 +2,8 @@ require_relative "base_convert"
|
|
2
2
|
require "isodoc"
|
3
3
|
require_relative "init"
|
4
4
|
require_relative "word_cleanup"
|
5
|
+
require_relative "figure"
|
6
|
+
require_relative "table"
|
5
7
|
|
6
8
|
module IsoDoc
|
7
9
|
module JIS
|
@@ -139,112 +141,14 @@ module IsoDoc
|
|
139
141
|
introduction isoxml, out
|
140
142
|
scope isoxml, out, 0
|
141
143
|
norm_ref isoxml, out, 0
|
142
|
-
|
143
|
-
symbols_abbrevs isoxml, out, 0
|
144
|
-
clause isoxml, out
|
144
|
+
clause_etc isoxml, out, 0
|
145
145
|
annex isoxml, out
|
146
146
|
bibliography isoxml, out
|
147
|
-
# colophon isoxml, out
|
148
147
|
end
|
149
148
|
|
150
|
-
def
|
151
|
-
|
152
|
-
|
153
|
-
"border:none;mso-padding-alt: " \
|
154
|
-
"0cm 5.4pt 0cm 5.4pt;mso-border-insideh:none;" \
|
155
|
-
"mso-border-insidev:none;#{keep_style(node)}",
|
156
|
-
border: 0, cellspacing: 0, cellpadding: 0)
|
157
|
-
end
|
158
|
-
|
159
|
-
def figure_components(node)
|
160
|
-
{ units: node.at(ns("./note[@type = 'units']/p")),
|
161
|
-
notes_etc: figure_notes_examples_paras(node
|
162
|
-
.xpath(ns("./note[not(@type = 'units')] | ./example | ./p"))),
|
163
|
-
name: node.at(ns("./name")),
|
164
|
-
key: node.at(ns("./dl")),
|
165
|
-
img: node.at(ns("./image")),
|
166
|
-
aside: node.at(ns("./aside")),
|
167
|
-
subfigs: node.xpath(ns("./figure")).map { |n| figure_components(n) } }
|
168
|
-
end
|
169
|
-
|
170
|
-
def figure_notes_examples_paras(xpath)
|
171
|
-
xpath.empty? and return nil
|
172
|
-
curr = ""
|
173
|
-
xpath.each_with_object([]) do |e, m|
|
174
|
-
e.name == curr or m << []
|
175
|
-
curr = e.name
|
176
|
-
m[-1] << e
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
def figure_parse1(node, out)
|
181
|
-
c = figure_components(node)
|
182
|
-
out.table **figure_attrs(node) do |div|
|
183
|
-
%i(units img subfigs key notes_etc aside name).each do |key|
|
184
|
-
case key
|
185
|
-
when :subfigs
|
186
|
-
c[key].each do |n|
|
187
|
-
n[:subname] = n[:name]
|
188
|
-
figure_row(node, div, n, :img)
|
189
|
-
figure_row(node, div, n, :subname)
|
190
|
-
end
|
191
|
-
when :notes_etc
|
192
|
-
c[key].each do |n|
|
193
|
-
figure_row(node, div, n, :notes_etc)
|
194
|
-
end
|
195
|
-
else figure_row(node, div, c, key)
|
196
|
-
end
|
197
|
-
end
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
def figure_name_parse(_node, div, name)
|
202
|
-
name.nil? and return
|
203
|
-
div.p class: "Tabletitle", style: "text-align:center;" do |p|
|
204
|
-
name.children.each { |n| parse(n, p) }
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
def figure_row(node, table, hash, key)
|
209
|
-
key != :notes_etc && (
|
210
|
-
hash[key].nil? || (hash[key].is_a?(Array) && hash[key].empty?)) and
|
211
|
-
return
|
212
|
-
table.tr do |r|
|
213
|
-
r.td valign: "top", style: "padding:0cm 5.4pt 0cm 5.4pt" do |d|
|
214
|
-
figure_row1(node, d, hash, key)
|
215
|
-
end
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
def fig_para(klass, row, nodes)
|
220
|
-
row.td valign: "top", style: "padding:0cm 5.4pt 0cm 5.4pt" do |d|
|
221
|
-
d.p class: klass do |p|
|
222
|
-
nodes.each { |n| parse(n, p) }
|
223
|
-
end
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
def figure_row1(node, cell, hash, key)
|
228
|
-
case key
|
229
|
-
when :units
|
230
|
-
cell.p class: "UnitStatement" do |p|
|
231
|
-
hash[key].children.each { |n| parse(n, p) }
|
232
|
-
end
|
233
|
-
when :key
|
234
|
-
figure_key(cell)
|
235
|
-
parse(hash[key], cell)
|
236
|
-
when :notes_etc, :aside
|
237
|
-
hash.each { |n| parse(n, cell) }
|
238
|
-
when :name then figure_name_parse(node, cell, hash[key])
|
239
|
-
when :img
|
240
|
-
cell.p class: "Figure" do |p|
|
241
|
-
parse(hash[key], p)
|
242
|
-
end
|
243
|
-
when :subname
|
244
|
-
cell.p class: "SubfigureCaption" do |p|
|
245
|
-
hash[key].children.each { |n| parse(n, p) }
|
246
|
-
end
|
247
|
-
end
|
149
|
+
def make_body3(body, docxml)
|
150
|
+
super
|
151
|
+
commentary docxml, body
|
248
152
|
end
|
249
153
|
|
250
154
|
def footnote_parse(node, out)
|
@@ -268,57 +172,33 @@ module IsoDoc
|
|
268
172
|
@seen_footnote << fn
|
269
173
|
end
|
270
174
|
|
271
|
-
def
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
out
|
276
|
-
a << "#{fnref})"
|
277
|
-
end
|
278
|
-
insert_tab(s, 1)
|
175
|
+
def annex(isoxml, out)
|
176
|
+
amd(isoxml) and @suppressheadingnumbers = @oldsuppressheadingnumbers
|
177
|
+
isoxml.xpath(ns("//annex[not(@commentary = 'true')]")).each do |c|
|
178
|
+
page_break(out)
|
179
|
+
render_annex(out, c)
|
279
180
|
end
|
181
|
+
amd(isoxml) and @suppressheadingnumbers = true
|
280
182
|
end
|
281
183
|
|
282
|
-
def
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
"border:none;mso-padding-alt: " \
|
291
|
-
"0cm 5.4pt 0cm 5.4pt;mso-border-insideh:none;" \
|
292
|
-
"mso-border-insidev:none;#{keep_style(node)}",
|
293
|
-
border: 0, cellspacing: 0, cellpadding: 0 }
|
294
|
-
end
|
295
|
-
|
296
|
-
def make_tr_attr_style(cell, row, rowmax, totalrows, opt)
|
297
|
-
top = row.zero? ? "#{SW1} 1.5pt;" : "none;"
|
298
|
-
bottom = "#{SW1} #{rowmax >= totalrows ? '1.5' : '1.0'}pt;"
|
299
|
-
ret = <<~STYLE.gsub(/\n/, "")
|
300
|
-
border-top:#{top}mso-border-top-alt:#{top}
|
301
|
-
border-left:#{bottom}mso-border-top-alt:#{bottom}
|
302
|
-
border-right:#{bottom}mso-border-top-alt:#{bottom}
|
303
|
-
border-bottom:#{bottom}mso-border-bottom-alt:#{bottom}
|
304
|
-
STYLE
|
305
|
-
opt[:bordered] or ret = ""
|
306
|
-
pb = keep_rows_together(cell, rowmax, totalrows, opt) ? "avoid" : "auto"
|
307
|
-
"#{ret}page-break-after:#{pb};"
|
184
|
+
def commentary(isoxml, out)
|
185
|
+
isoxml.xpath(ns("//annex[@commentary = 'true']")).each do |c|
|
186
|
+
section_break(out)
|
187
|
+
out.div class: "WordSectionCommentary" do |div|
|
188
|
+
commentary_title(isoxml, div)
|
189
|
+
render_annex(div, c)
|
190
|
+
end
|
191
|
+
end
|
308
192
|
end
|
309
193
|
|
310
|
-
def
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
194
|
+
def render_annex(out, clause)
|
195
|
+
out.div **attr_code(annex_attrs(clause)) do |s|
|
196
|
+
clause.elements.each do |c1|
|
197
|
+
if c1.name == "title" then annex_name(clause, c1, s)
|
198
|
+
else parse(c1, s)
|
199
|
+
end
|
200
|
+
end
|
315
201
|
end
|
316
|
-
style = "border-top:0pt;mso-border-top-alt:0pt;" \
|
317
|
-
"border-bottom:#{SW1} 1.5pt;mso-border-bottom-alt:#{SW1} 1.5pt;" \
|
318
|
-
"border-left:#{SW1} 1.5pt;mso-border-left-alt:#{SW1} 1.5pt;" \
|
319
|
-
"border-right:#{SW1} 1.5pt;mso-border-right-alt:#{SW1} 1.5pt;"
|
320
|
-
tfoot.add_child("<tr><td colspan='#{cols}' style='#{style}'/></tr>")
|
321
|
-
tfoot.xpath(".//td").last
|
322
202
|
end
|
323
203
|
|
324
204
|
include BaseConvert
|
data/lib/isodoc/jis/xref.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
module IsoDoc
|
2
2
|
module JIS
|
3
|
+
class Counter < IsoDoc::XrefGen::Counter
|
4
|
+
end
|
5
|
+
|
3
6
|
class Xref < IsoDoc::Iso::Xref
|
4
7
|
def annex_name_lbl(clause, num)
|
5
8
|
obl = l10n("(#{@labels['inform_annex']})")
|
@@ -8,6 +11,48 @@ module IsoDoc
|
|
8
11
|
title = Common::case_with_markup(@labels["annex"], "capital", @script)
|
9
12
|
l10n("#{title} #{num}<br/>#{obl}")
|
10
13
|
end
|
14
|
+
|
15
|
+
def back_anchor_names(xml)
|
16
|
+
if @parse_settings.empty? || @parse_settings[:clauses]
|
17
|
+
i = Counter.new("@")
|
18
|
+
xml.xpath(ns("//annex")).each do |c|
|
19
|
+
if c["commentary"] == "true"
|
20
|
+
commentary_names(c)
|
21
|
+
else
|
22
|
+
annex_names(c, i.increment(c).print)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
xml.xpath(ns(@klass.bibliography_xpath)).each do |b|
|
26
|
+
preface_names(b)
|
27
|
+
end
|
28
|
+
xml.xpath(ns("//colophon/clause")).each { |b| preface_names(b) }
|
29
|
+
xml.xpath(ns("//indexsect")).each { |b| preface_names(b) }
|
30
|
+
end
|
31
|
+
references(xml) if @parse_settings.empty? || @parse_settings[:refs]
|
32
|
+
end
|
33
|
+
|
34
|
+
def commentary_names(clause)
|
35
|
+
preface_name_anchors(clause, 1, clause_title(clause))
|
36
|
+
clause.xpath(ns(SUBCLAUSES)).each_with_object(Counter.new) do |c, i|
|
37
|
+
commentary_names1(c, clause["id"], i.increment(c).print, 2)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def commentary_names1(clause, root, num, level)
|
42
|
+
commentary_name_anchors(clause, num, root, level)
|
43
|
+
clause.xpath(ns(SUBCLAUSES)).each_with_object(Counter.new) do |c, i|
|
44
|
+
commentary_names1(c, root, "#{num}.#{i.increment(c).print}",
|
45
|
+
level + 1)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def commentary_name_anchors(clause, num, root, level)
|
50
|
+
@anchors[clause["id"]] =
|
51
|
+
{ label: num, xref: l10n("#{@labels['clause']} #{num}"),
|
52
|
+
container: root,
|
53
|
+
title: clause_title(clause), level: level, type: "clause",
|
54
|
+
elem: @labels["clause"] }
|
55
|
+
end
|
11
56
|
end
|
12
57
|
end
|
13
58
|
end
|
@@ -31,12 +31,13 @@ module Metanorma
|
|
31
31
|
xmldoc.xpath("//table | //figure").each do |t|
|
32
32
|
seen = {}
|
33
33
|
i = 0
|
34
|
-
#t.xpath(".//fn[not(ancestor::name)]").each do |fn|
|
35
34
|
t.xpath(".//fn").each do |fn|
|
36
35
|
i, seen = table_footnote_renumber1(fn, i, seen)
|
37
36
|
end
|
38
37
|
end
|
39
38
|
end
|
39
|
+
|
40
|
+
def docidentifier_cleanup(xmldoc); end
|
40
41
|
end
|
41
42
|
end
|
42
43
|
end
|
@@ -29,6 +29,16 @@ module Metanorma
|
|
29
29
|
File.join(@libdir, "jis_intro_jp.xml")
|
30
30
|
end
|
31
31
|
|
32
|
+
def section_attributes(node)
|
33
|
+
ret = super
|
34
|
+
if node.attr("style") == "appendix" && node.level == 1 &&
|
35
|
+
node.option?("commentary")
|
36
|
+
ret[:commentary] = true
|
37
|
+
node.set_attr("obligation", "informative")
|
38
|
+
end
|
39
|
+
ret
|
40
|
+
end
|
41
|
+
|
32
42
|
def html_converter(node)
|
33
43
|
if node.nil?
|
34
44
|
IsoDoc::JIS::HtmlConvert.new({})
|
data/lib/metanorma/jis/front.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "pubid-jis"
|
2
|
+
|
1
3
|
module Metanorma
|
2
4
|
module JIS
|
3
5
|
class Converter < ISO::Converter
|
@@ -59,28 +61,68 @@ module Metanorma
|
|
59
61
|
end
|
60
62
|
|
61
63
|
def metadata_id(node, xml)
|
64
|
+
node.attr("docidentifier") || node.attr("docnumber") or
|
65
|
+
@fatalerror << "No docnumber attribute supplied"
|
62
66
|
if id = node.attr("docidentifier")
|
63
|
-
xml.docidentifier id, **attr_code(type: "JIS")
|
67
|
+
xml.docidentifier id.sub(/^JIS /, ""), **attr_code(type: "JIS")
|
64
68
|
else iso_id(node, xml)
|
65
69
|
end
|
66
70
|
xml.docnumber node.attr("docnumber")
|
67
71
|
end
|
68
72
|
|
73
|
+
def get_typeabbr(node, amd: false)
|
74
|
+
amd || node.attr("amendment-number") and return :amd
|
75
|
+
case doctype(node)
|
76
|
+
when "technical-report" then :tr
|
77
|
+
when "technical-specification" then :ts
|
78
|
+
when "amendment" then :amd
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
69
82
|
def iso_id(node, xml)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
83
|
+
(!@amd && node.attr("docnumber")) || (@amd && node.attr("updates")) or
|
84
|
+
return
|
85
|
+
params = iso_id_params(node)
|
86
|
+
iso_id_out(xml, params, true)
|
87
|
+
end
|
88
|
+
|
89
|
+
def iso_id_params(node)
|
90
|
+
params = iso_id_params_core(node)
|
91
|
+
params2 = iso_id_params_add(node)
|
92
|
+
if node.attr("updates")
|
93
|
+
orig_id = Pubid::Jis::Identifier::Base.parse(node.attr("updates"))
|
94
|
+
orig_id.edition ||= 1
|
95
|
+
end
|
96
|
+
iso_id_params_resolve(params, params2, node, orig_id)
|
97
|
+
end
|
98
|
+
|
99
|
+
def iso_id_params_core(node)
|
100
|
+
pub = (node.attr("publisher") || "JIS").split(/[;,]/)
|
101
|
+
ret = { number: node.attr("docnumber") || "0",
|
102
|
+
part: node.attr("partnumber"),
|
103
|
+
series: node.attr("docseries"),
|
104
|
+
language: node.attr("language") == "en" ? "E" : nil,
|
105
|
+
type: get_typeabbr(node),
|
106
|
+
publisher: pub[0],
|
107
|
+
copublisher: pub[1..-1] }.compact
|
108
|
+
ret[:copublisher].empty? and ret.delete(:copublisher)
|
109
|
+
ret
|
110
|
+
end
|
111
|
+
|
112
|
+
def iso_id_params_add(node)
|
113
|
+
{ number: node.attr("amendment-number"),
|
114
|
+
year: iso_id_year(node) }.compact
|
115
|
+
end
|
116
|
+
|
117
|
+
def iso_id_out(xml, params, _with_prf)
|
118
|
+
id = iso_id_default(params).to_s(with_publisher: false)
|
119
|
+
xml.docidentifier id.strip, type: "JIS"
|
120
|
+
end
|
121
|
+
|
122
|
+
def iso_id_default(params)
|
123
|
+
Pubid::Jis::Identifier.create(**params)
|
124
|
+
rescue StandardError => e
|
125
|
+
clean_abort("Document identifier: #{e}", xml)
|
84
126
|
end
|
85
127
|
end
|
86
128
|
end
|