metanorma-jis 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/html2doc/lists.rb +22 -66
- data/lib/isodoc/jis/base_convert.rb +80 -11
- data/lib/isodoc/jis/figure.rb +99 -0
- data/lib/isodoc/jis/html/header.html +210 -818
- data/lib/isodoc/jis/html/html_jis_intro.html +0 -1
- data/lib/isodoc/jis/html/isodoc.css +9 -38
- data/lib/isodoc/jis/html/isodoc.scss +9 -37
- data/lib/isodoc/jis/html/word_jis_intro.html +0 -7
- data/lib/isodoc/jis/html/wordstyle.css +55 -1
- data/lib/isodoc/jis/html/wordstyle.scss +52 -1
- data/lib/isodoc/jis/html_convert.rb +1 -1
- 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 +660 -187
- data/lib/isodoc/jis/metadata.rb +7 -0
- data/lib/isodoc/jis/presentation_xml_convert.rb +127 -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 +38 -169
- 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 +41 -14
- data/lib/metanorma/jis/isostandard.rng +5 -8
- data/lib/metanorma/jis/jis.rng +16 -9
- 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
data/lib/isodoc/jis/metadata.rb
CHANGED
@@ -49,6 +49,13 @@ module IsoDoc
|
|
49
49
|
end
|
50
50
|
|
51
51
|
PART_LABEL = { en: "Part", ja: "その" }.freeze
|
52
|
+
|
53
|
+
def docid(isoxml, _out)
|
54
|
+
id = isoxml.at(ns("//bibdata/docidentifier[@type = 'JIS']"))&.text or
|
55
|
+
return
|
56
|
+
set(:docnumber, id)
|
57
|
+
set(:docnumber_undated, id.sub(/:\d{4}$/, ""))
|
58
|
+
end
|
52
59
|
end
|
53
60
|
end
|
54
61
|
end
|
@@ -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
|
-
|
62
|
-
end
|
63
|
-
node.elements.each do |x|
|
64
|
-
%w(dt dd name).include?(x.name) and next
|
65
|
-
ret += x.to_xml
|
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>"
|
66
84
|
end
|
67
|
-
|
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,72 @@ 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, "//sections/introduction", i)
|
158
|
+
i = display_order_at(docxml, "//clause[@type = 'scope']", i)
|
159
|
+
i = display_order_at(docxml, @xrefs.klass.norm_ref_xpath, i)
|
160
|
+
i = display_order_at(docxml, "//sections/terms | " \
|
161
|
+
"//sections/clause[descendant::terms]", i)
|
162
|
+
i = display_order_at(docxml, "//sections/definitions", i)
|
163
|
+
i = display_order_xpath(docxml, @xrefs.klass.middle_clause(docxml), i)
|
164
|
+
i = display_order_xpath(docxml, "//annex[not(@commentary = 'true')]", i)
|
165
|
+
i = display_order_xpath(docxml, @xrefs.klass.bibliography_xpath, i)
|
166
|
+
i = display_order_xpath(docxml, "//annex[@commentary = 'true']", i)
|
167
|
+
i = display_order_xpath(docxml, "//indexsect", i)
|
168
|
+
display_order_xpath(docxml, "//colophon/*", i)
|
169
|
+
end
|
170
|
+
|
171
|
+
def tablesource(elem)
|
172
|
+
while elem&.next_element&.name == "source"
|
173
|
+
elem << "; #{to_xml(elem.next_element.remove.children)}"
|
174
|
+
end
|
175
|
+
elem.children = l10n("#{@i18n.source}: #{to_xml(elem.children).strip}")
|
176
|
+
end
|
177
|
+
|
178
|
+
def toc_title_insert_pt(docxml)
|
179
|
+
ins = docxml.at(ns("//preface")) ||
|
180
|
+
docxml.at(ns("//sections | //annex | //bibliography"))
|
181
|
+
&.before("<preface> </preface>")
|
182
|
+
&.previous_element or return nil
|
183
|
+
ins.children.last.after(" ").next
|
184
|
+
end
|
185
|
+
|
186
|
+
def preface_rearrange(doc)
|
187
|
+
move_introduction(doc)
|
188
|
+
super
|
189
|
+
end
|
190
|
+
|
191
|
+
def move_introduction(doc)
|
192
|
+
source = doc.at(ns("//preface/introduction")) or return
|
193
|
+
dest = doc.at(ns("//sections")) ||
|
194
|
+
doc.at(ns("//preface")).after("<sections> </sections>").next_element
|
195
|
+
dest.children.empty? and dest.children = " "
|
196
|
+
dest.children.first.next = source
|
92
197
|
end
|
93
|
-
prefix_name(elem, "<br/>", lbl, "title")
|
94
|
-
end
|
95
198
|
|
96
199
|
include Init
|
97
200
|
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
|
@@ -97,24 +99,16 @@ module IsoDoc
|
|
97
99
|
end
|
98
100
|
end
|
99
101
|
|
100
|
-
def
|
101
|
-
|
102
|
-
|
103
|
-
out.div **attr_code(class: "Section3", id: f["id"],
|
104
|
-
type: f["type"]) do |div|
|
105
|
-
clause_name(f, f&.at(ns("./title")), div, { class: "IntroTitle" })
|
106
|
-
f.elements.each do |e|
|
107
|
-
parse(e, div) unless e.name == "title"
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
102
|
+
def preface_attrs(node)
|
103
|
+
{ id: node["id"], type: node["type"],
|
104
|
+
class: node["type"] == "toc" ? "TOC" : "Section3" }
|
111
105
|
end
|
112
106
|
|
113
|
-
def introduction(
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
107
|
+
def introduction(clause, out)
|
108
|
+
out.div class: "Section3", id: clause["id"] do |div|
|
109
|
+
clause_name(clause, clause.at(ns("./title")), div,
|
110
|
+
{ class: "IntroTitle" })
|
111
|
+
clause.elements.each do |e|
|
118
112
|
parse(e, div) unless e.name == "title"
|
119
113
|
end
|
120
114
|
end
|
@@ -123,11 +117,7 @@ module IsoDoc
|
|
123
117
|
def make_body2(body, docxml)
|
124
118
|
body.div class: "WordSection2" do |div2|
|
125
119
|
boilerplate docxml, div2
|
126
|
-
|
127
|
-
abstract docxml, div2
|
128
|
-
foreword docxml, div2
|
129
|
-
preface docxml, div2
|
130
|
-
acknowledgements docxml, div2
|
120
|
+
front docxml, div2
|
131
121
|
div2.p { |p| p << " " } # placeholder
|
132
122
|
end
|
133
123
|
section_break(body)
|
@@ -136,115 +126,18 @@ module IsoDoc
|
|
136
126
|
def middle(isoxml, out)
|
137
127
|
middle_title(isoxml, out)
|
138
128
|
middle_admonitions(isoxml, out)
|
139
|
-
|
129
|
+
i = isoxml.at(ns("//sections/introduction")) and
|
130
|
+
introduction i, out
|
140
131
|
scope isoxml, out, 0
|
141
132
|
norm_ref isoxml, out, 0
|
142
|
-
|
143
|
-
symbols_abbrevs isoxml, out, 0
|
144
|
-
clause isoxml, out
|
133
|
+
clause_etc isoxml, out, 0
|
145
134
|
annex isoxml, out
|
146
135
|
bibliography isoxml, out
|
147
|
-
# colophon isoxml, out
|
148
|
-
end
|
149
|
-
|
150
|
-
def figure_attrs(node)
|
151
|
-
attr_code(id: node["id"], class: "MsoTableGrid",
|
152
|
-
style: "border-collapse:collapse;" \
|
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
136
|
end
|
226
137
|
|
227
|
-
def
|
228
|
-
|
229
|
-
|
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
|
138
|
+
def make_body3(body, docxml)
|
139
|
+
super
|
140
|
+
commentary docxml, body
|
248
141
|
end
|
249
142
|
|
250
143
|
def footnote_parse(node, out)
|
@@ -268,57 +161,33 @@ module IsoDoc
|
|
268
161
|
@seen_footnote << fn
|
269
162
|
end
|
270
163
|
|
271
|
-
def
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
out
|
276
|
-
a << "#{fnref})"
|
277
|
-
end
|
278
|
-
insert_tab(s, 1)
|
164
|
+
def annex(isoxml, out)
|
165
|
+
amd(isoxml) and @suppressheadingnumbers = @oldsuppressheadingnumbers
|
166
|
+
isoxml.xpath(ns("//annex[not(@commentary = 'true')]")).each do |c|
|
167
|
+
page_break(out)
|
168
|
+
render_annex(out, c)
|
279
169
|
end
|
170
|
+
amd(isoxml) and @suppressheadingnumbers = true
|
280
171
|
end
|
281
172
|
|
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};"
|
173
|
+
def commentary(isoxml, out)
|
174
|
+
isoxml.xpath(ns("//annex[@commentary = 'true']")).each do |c|
|
175
|
+
section_break(out)
|
176
|
+
out.div class: "WordSectionCommentary" do |div|
|
177
|
+
commentary_title(isoxml, div)
|
178
|
+
render_annex(div, c)
|
179
|
+
end
|
180
|
+
end
|
308
181
|
end
|
309
182
|
|
310
|
-
def
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
183
|
+
def render_annex(out, clause)
|
184
|
+
out.div **attr_code(annex_attrs(clause)) do |s|
|
185
|
+
clause.elements.each do |c1|
|
186
|
+
if c1.name == "title" then annex_name(clause, c1, s)
|
187
|
+
else parse(c1, s)
|
188
|
+
end
|
189
|
+
end
|
315
190
|
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
191
|
end
|
323
192
|
|
324
193
|
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({})
|