metanorma-jis 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bf51e10fbc568a6c14c9e8b4192e16f90b5dd093aff54cdc0fbdb9ef11566bb
|
4
|
+
data.tar.gz: 060bddc60dd35141b7143e36a1cd66bc4ef89b9db9fc0b5d385ea9171d3baa8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa5e35fcdff0101c14bd5f3d713560aa8e5236e055288e328b4024268bc9e62b1fbd399d75a388b337a7779be50939fc96438cedf691106f6ef77aca56921dd6
|
7
|
+
data.tar.gz: 55665ed144401a91526a924d27a8b2134b818581627663e371fec91fe1ccf60afb384838364dfd3986798f093e03818cd9e0e9983f6371227d9b427f9b1aab5d
|
data/lib/html2doc/lists.rb
CHANGED
@@ -9,7 +9,7 @@ class Html2Doc
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def style_list(elem, level, liststyle, listnumber)
|
12
|
-
|
12
|
+
liststyle or return
|
13
13
|
elem["level"] = level
|
14
14
|
super
|
15
15
|
end
|
@@ -32,14 +32,6 @@ class Html2Doc
|
|
32
32
|
end
|
33
33
|
item.at("./p") or return
|
34
34
|
item.replace(item.children)
|
35
|
-
=begin
|
36
|
-
prev = p1.xpath("./preceding-sibling::* | ./preceding-sibling::text()")
|
37
|
-
if prev[-1].name == "span" && prev[-1]["style"] == "mso-tab-count:1" &&
|
38
|
-
prev.size == 2
|
39
|
-
p1.children.first.previous = prev[1]
|
40
|
-
p1.children.first.previous = prev[0]
|
41
|
-
end
|
42
|
-
=end
|
43
35
|
end
|
44
36
|
|
45
37
|
def list2para_unnest_para(para, first_p, last_p)
|
@@ -74,29 +66,29 @@ class Html2Doc
|
|
74
66
|
case listtype
|
75
67
|
when "ol"
|
76
68
|
ret = case depth
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
69
|
+
when "1" then "margin-left: 36.0pt;"
|
70
|
+
when "2" then "margin-left: 54.0pt;"
|
71
|
+
when "3" then "margin-left: 72.0pt;"
|
72
|
+
when "4" then "margin-left: 90.0pt;"
|
73
|
+
when "5" then "margin-left: 108.0pt;"
|
74
|
+
when "6" then "margin-left: 126.0pt;"
|
75
|
+
when "7" then "margin-left: 144.0pt;"
|
76
|
+
when "8" then "margin-left: 162.0pt;"
|
77
|
+
else "margin-left: 180.0pt;"
|
78
|
+
end
|
87
79
|
"#{ret}text-indent:-18.0pt;"
|
88
80
|
when "ul"
|
89
81
|
ret = case depth
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
82
|
+
when "1" then "margin-left: 36.0pt;"
|
83
|
+
when "2" then "margin-left: 45.95pt;"
|
84
|
+
when "3" then "margin-left: 72.0pt;"
|
85
|
+
when "4" then "margin-left: 90.0pt;"
|
86
|
+
when "5" then "margin-left: 108.0pt;"
|
87
|
+
when "6" then "margin-left: 126.0pt;"
|
88
|
+
when "7" then "margin-left: 144.0pt;"
|
89
|
+
when "8" then "margin-left: 162.0pt;"
|
90
|
+
else "margin-left: 180.0pt;"
|
91
|
+
end
|
100
92
|
"#{ret}text-indent:-18.0pt;"
|
101
93
|
|
102
94
|
end
|
@@ -112,11 +104,10 @@ class Html2Doc
|
|
112
104
|
u.replace(u.children)
|
113
105
|
end
|
114
106
|
unnest_list_paras(docxml)
|
115
|
-
indent_lists(docxml)
|
116
107
|
end
|
117
108
|
|
118
109
|
def unnest_list_paras(docxml)
|
119
|
-
docxml.xpath("//p[@class = '
|
110
|
+
docxml.xpath("//p[@class = 'MsoList' or @class = 'MsoListBullet']" \
|
120
111
|
"[.//p]").each do |p|
|
121
112
|
p.at("./p") and
|
122
113
|
list2para_unnest_para(p, p.at("./p"),
|
@@ -128,24 +119,6 @@ class Html2Doc
|
|
128
119
|
end
|
129
120
|
end
|
130
121
|
|
131
|
-
def indent_lists(docxml)
|
132
|
-
docxml.xpath("//div[@class = 'Note' or @class = 'Example' or " \
|
133
|
-
"@class = 'Quote']").each do |d|
|
134
|
-
d.xpath(".//p").each do |p|
|
135
|
-
indent_lists1(p)
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
def indent_lists1(para)
|
141
|
-
m = /^(ListContinue|ListNumber|MsoListContinue|MsoListNumber)(\d)$/
|
142
|
-
.match(para["class"]) or return
|
143
|
-
base = m[1].sub(/^Mso/, "")
|
144
|
-
level = m[2].to_i + 1
|
145
|
-
level = 5 if level > 5
|
146
|
-
para["class"] = "#{base}#{level}-"
|
147
|
-
end
|
148
|
-
|
149
122
|
def list_add(xpath, liststyles, listtype, level)
|
150
123
|
xpath.each do |l|
|
151
124
|
level == 1 and l["seen"] = true and @listnumber += 1
|
@@ -172,23 +145,6 @@ class Html2Doc
|
|
172
145
|
end
|
173
146
|
end
|
174
147
|
|
175
|
-
def listlabel(listtype, idx, level)
|
176
|
-
case listtype
|
177
|
-
when :ul then "—"
|
178
|
-
when :ol then "#{listidx(idx, level)})"
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
def listidx(idx, level)
|
183
|
-
case level
|
184
|
-
when "a" then (96 + idx).chr.to_s
|
185
|
-
when "1" then idx.to_s
|
186
|
-
when "i" then RomanNumerals.to_roman(idx).downcase
|
187
|
-
when "A" then (64 + idx).chr.to_s
|
188
|
-
when "I" then RomanNumerals.to_roman(idx).upcase
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
148
|
def cleanup(docxml)
|
193
149
|
super
|
194
150
|
docxml.xpath("//div[@class = 'Quote' or @class = 'Example' or " \
|
@@ -5,13 +5,32 @@ module IsoDoc
|
|
5
5
|
module JIS
|
6
6
|
module BaseConvert
|
7
7
|
def middle_title(_isoxml, out)
|
8
|
-
|
8
|
+
middle_title_hdr(out)
|
9
|
+
middle_title_main(out, "zzSTDTitle1")
|
9
10
|
middle_subtitle_main(out)
|
10
11
|
# middle_title_amd(out)
|
11
12
|
end
|
12
13
|
|
13
|
-
def
|
14
|
-
out.p(class: "
|
14
|
+
def middle_title_hdr(out)
|
15
|
+
out.p(class: "JapaneseIndustrialStandard") do |p|
|
16
|
+
p << @i18n.jis
|
17
|
+
@meta.get[:unpublished] and p << @i18n.l10n("(#{@i18n.draft_label})")
|
18
|
+
insert_tab(p, 7)
|
19
|
+
p << "<span class='JIS'>JIS</span>"
|
20
|
+
end
|
21
|
+
out.p(class: "StandardNumber") do |p|
|
22
|
+
insert_tab(p, 1)
|
23
|
+
p << @meta.get[:docnumber_undated]
|
24
|
+
if yr = @meta.get[:docyear]
|
25
|
+
p << ": "
|
26
|
+
p << "<span class='EffectiveYear'>#{yr}</span>"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
out.p(class: "IDT")
|
30
|
+
end
|
31
|
+
|
32
|
+
def middle_title_main(out, style)
|
33
|
+
out.p(class: style) do |p|
|
15
34
|
p << @meta.get[:doctitleintro]
|
16
35
|
p << " — " if @meta.get[:doctitleintro] && @meta.get[:doctitlemain]
|
17
36
|
p << @meta.get[:doctitlemain]
|
@@ -37,8 +56,23 @@ module IsoDoc
|
|
37
56
|
end
|
38
57
|
end
|
39
58
|
|
59
|
+
def commentary_title(_isoxml, out)
|
60
|
+
commentary_title_hdr(out)
|
61
|
+
middle_title_main(out, "CommentaryStandardName")
|
62
|
+
end
|
63
|
+
|
64
|
+
def commentary_title_hdr(out)
|
65
|
+
out.p(class: "CommentaryStandardNumber") do |p|
|
66
|
+
p << "JIS #{@meta.get[:docnumber_undated]}"
|
67
|
+
if yr = @meta.get[:docyear]
|
68
|
+
p << ": "
|
69
|
+
p << "<span class='CommentaryEffectiveYear'>#{yr}</span>"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
40
74
|
def termnote_parse(node, out)
|
41
|
-
name = node
|
75
|
+
name = node.at(ns("./name"))&.remove
|
42
76
|
out.div **note_attrs(node) do |div|
|
43
77
|
div.p do |p|
|
44
78
|
if name
|
@@ -59,13 +93,6 @@ module IsoDoc
|
|
59
93
|
end
|
60
94
|
end
|
61
95
|
|
62
|
-
def admitted_term_parse(node, out)
|
63
|
-
out.p class: "Terms", style: "text-align:left;" do |p|
|
64
|
-
p << l10n("#{@i18n.alternative}: ")
|
65
|
-
node.children.each { |c| parse(c, p) }
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
96
|
def para_class(node)
|
70
97
|
super || node["class"]
|
71
98
|
end
|
@@ -74,6 +101,46 @@ module IsoDoc
|
|
74
101
|
cell["border"] == "0" and bordered = false
|
75
102
|
super
|
76
103
|
end
|
104
|
+
|
105
|
+
def middle(isoxml, out)
|
106
|
+
middle_title(isoxml, out)
|
107
|
+
middle_admonitions(isoxml, out)
|
108
|
+
scope isoxml, out, 0
|
109
|
+
norm_ref isoxml, out, 0
|
110
|
+
clause_etc isoxml, out, 0
|
111
|
+
annex isoxml, out
|
112
|
+
bibliography isoxml, out
|
113
|
+
commentary isoxml, out
|
114
|
+
indexsect isoxml, out
|
115
|
+
end
|
116
|
+
|
117
|
+
def annex(isoxml, out)
|
118
|
+
amd(isoxml) and @suppressheadingnumbers = @oldsuppressheadingnumbers
|
119
|
+
isoxml.xpath(ns("//annex[not(@commentary = 'true')]")).each do |c|
|
120
|
+
page_break(out)
|
121
|
+
out.div **attr_code(annex_attrs(c)) do |s|
|
122
|
+
c.elements.each do |c1|
|
123
|
+
if c1.name == "title" then annex_name(c, c1, s)
|
124
|
+
else parse(c1, s)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
amd(isoxml) and @suppressheadingnumbers = true
|
130
|
+
end
|
131
|
+
|
132
|
+
def commentary(isoxml, out)
|
133
|
+
isoxml.xpath(ns("//annex[@commentary = 'true']")).each do |c|
|
134
|
+
page_break(out)
|
135
|
+
out.div **attr_code(annex_attrs(c)) do |s|
|
136
|
+
c.elements.each do |c1|
|
137
|
+
if c1.name == "title" then annex_name(c, c1, s)
|
138
|
+
else parse(c1, s)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
77
144
|
end
|
78
145
|
end
|
79
146
|
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module IsoDoc
|
2
|
+
module JIS
|
3
|
+
class WordConvert < IsoDoc::Iso::WordConvert
|
4
|
+
def figure_attrs(node)
|
5
|
+
attr_code(id: node["id"], class: "MsoTableGrid",
|
6
|
+
style: "border-collapse:collapse;" \
|
7
|
+
"border:none;mso-padding-alt: " \
|
8
|
+
"0cm 5.4pt 0cm 5.4pt;mso-border-insideh:none;" \
|
9
|
+
"mso-border-insidev:none;#{keep_style(node)}",
|
10
|
+
border: 0, cellspacing: 0, cellpadding: 0)
|
11
|
+
end
|
12
|
+
|
13
|
+
def figure_components(node)
|
14
|
+
{ units: node.at(ns("./note[@type = 'units']")),
|
15
|
+
notes_etc: figure_notes_examples_paras(node
|
16
|
+
.xpath(ns("./note[not(@type = 'units')] | ./example | ./p"))),
|
17
|
+
name: node.at(ns("./name")),
|
18
|
+
key: node.xpath(ns("./p[@class = 'ListTitle' or @class = 'dl']")),
|
19
|
+
img: node.at(ns("./image")),
|
20
|
+
aside: node.at(ns("./aside")),
|
21
|
+
source: node.at(ns("./source")),
|
22
|
+
subfigs: node.xpath(ns("./figure")).map { |n| figure_components(n) } }
|
23
|
+
end
|
24
|
+
|
25
|
+
def figure_notes_examples_paras(xpath)
|
26
|
+
xpath.empty? and return nil
|
27
|
+
curr = ""
|
28
|
+
xpath.each_with_object([]) do |e, m|
|
29
|
+
e.name == curr or m << []
|
30
|
+
curr = e.name
|
31
|
+
m[-1] << e
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def figure_parse1(node, out)
|
36
|
+
c = figure_components(node)
|
37
|
+
out.table **figure_attrs(node) do |div|
|
38
|
+
%i(units img subfigs key notes_etc aside source name).each do |key|
|
39
|
+
case key
|
40
|
+
when :subfigs then figure_subfigs(node, div, c[key])
|
41
|
+
when :notes_etc, :key
|
42
|
+
c[key]&.each { |n| figure_row(node, div, n, key) }
|
43
|
+
else figure_row(node, div, c, key) end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def figure_subfigs(node, div, elem)
|
49
|
+
elem.each do |n|
|
50
|
+
n[:subname] = n[:name]
|
51
|
+
figure_row(node, div, n, :img)
|
52
|
+
figure_row(node, div, n, :subname)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def figure_name_parse(_node, div, name)
|
57
|
+
name.nil? and return
|
58
|
+
div.p class: "Tabletitle", style: "text-align:center;" do |p|
|
59
|
+
name.children.each { |n| parse(n, p) }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def figure_row(node, table, hash, key)
|
64
|
+
key != :notes_etc && (
|
65
|
+
hash[key].nil? || (hash[key].is_a?(Array) && hash[key].empty?)) and
|
66
|
+
return
|
67
|
+
table.tr do |r|
|
68
|
+
r.td valign: "top", style: "padding:0cm 5.4pt 0cm 5.4pt" do |d|
|
69
|
+
figure_row1(node, d, hash, key)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def figure_row1(node, cell, hash, key)
|
75
|
+
case key
|
76
|
+
when :units then units_render(hash[key], cell)
|
77
|
+
when :notes_etc, :aside, :key then hash.each { |n| parse(n, cell) }
|
78
|
+
when :source then parse(hash[key], cell)
|
79
|
+
when :name then figure_name_parse(node, cell, hash[key])
|
80
|
+
when :img
|
81
|
+
cell.p class: "Figure" do |p|
|
82
|
+
parse(hash[key], p)
|
83
|
+
end
|
84
|
+
when :subname
|
85
|
+
cell.p class: "SubfigureCaption" do |p|
|
86
|
+
hash[key].children.each { |n| parse(n, p) }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def units_render(note, cell)
|
92
|
+
para = note.at(ns("./p")) and note = para
|
93
|
+
cell.p class: "UnitStatement" do |p|
|
94
|
+
note.children.each { |n| parse(n, p) }
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|