metanorma-jis 0.0.1 → 0.0.3
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 +41 -6
- data/lib/isodoc/jis/base_convert.rb +39 -1
- data/lib/isodoc/jis/html/isodoc.css +72 -151
- data/lib/isodoc/jis/html/isodoc.scss +82 -161
- data/lib/isodoc/jis/html/word_jis_intro.html +4 -3
- data/lib/isodoc/jis/html/word_jis_titlepage.html +6 -0
- data/lib/isodoc/jis/html/wordstyle.css +37 -109
- data/lib/isodoc/jis/html/wordstyle.scss +48 -132
- data/lib/isodoc/jis/html_convert.rb +20 -4
- data/lib/isodoc/jis/i18n-en.yaml +13 -0
- data/lib/isodoc/jis/i18n-ja.yaml +8 -204
- data/lib/isodoc/jis/i18n.rb +2 -2
- data/lib/isodoc/jis/jis.international-standard.xsl +11095 -0
- data/lib/isodoc/jis/metadata.rb +2 -0
- data/lib/isodoc/jis/presentation_xml_convert.rb +88 -0
- data/lib/isodoc/jis/word_cleanup.rb +143 -0
- data/lib/isodoc/jis/word_convert.rb +255 -80
- data/lib/isodoc/jis/xref.rb +7 -0
- data/lib/metanorma/jis/cleanup.rb +42 -0
- data/lib/metanorma/jis/converter.rb +10 -14
- data/lib/metanorma/jis/front.rb +36 -0
- data/lib/metanorma/jis/processor.rb +1 -1
- data/lib/metanorma/jis/relaton-jis.rng +3 -109
- data/lib/metanorma/jis/validate.rb +26 -0
- data/lib/metanorma/jis/version.rb +1 -1
- metadata +7 -2
data/lib/isodoc/jis/metadata.rb
CHANGED
@@ -4,6 +4,94 @@ require "isodoc"
|
|
4
4
|
module IsoDoc
|
5
5
|
module JIS
|
6
6
|
class PresentationXMLConvert < IsoDoc::Iso::PresentationXMLConvert
|
7
|
+
def inline(docxml)
|
8
|
+
super
|
9
|
+
strong(docxml)
|
10
|
+
end
|
11
|
+
|
12
|
+
JPAN = "\\p{Hiragana}\\p{Katakana}\\p{Han}".freeze
|
13
|
+
JPAN_BOLD = "<span style='font-family:\"MS Gothic\"'>".freeze
|
14
|
+
|
15
|
+
def strong(docxml)
|
16
|
+
docxml.xpath(ns("//strong")).each do |x|
|
17
|
+
(x.children.size == 1 && x.children.first.text?) or next # too hard
|
18
|
+
x.replace(strong1(x.text))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def strong1(text)
|
23
|
+
jpan = /^[#{JPAN}]/o.match?(text[0])
|
24
|
+
ret = jpan ? JPAN_BOLD : "<strong>"
|
25
|
+
text.split("").each do |n|
|
26
|
+
new = /^[#{JPAN}]/o.match?(n)
|
27
|
+
jpan && !new and ret += "</span><strong>"
|
28
|
+
!jpan && new and ret += "</strong>#{JPAN_BOLD}"
|
29
|
+
ret += n
|
30
|
+
jpan = new
|
31
|
+
end
|
32
|
+
ret += /[#{JPAN}]/o.match?(text[-1]) ? "</span>" : "</strong>"
|
33
|
+
ret
|
34
|
+
end
|
35
|
+
|
36
|
+
def block(docxml)
|
37
|
+
super
|
38
|
+
dl docxml
|
39
|
+
end
|
40
|
+
|
41
|
+
def dl(docxml)
|
42
|
+
docxml.xpath(ns("//table//dl | //figure//dl")).each do |l|
|
43
|
+
l.at(ns("./dl")) || l.at("./ancestor::xmlns:dl") and next
|
44
|
+
dl_to_para(l)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def dt_dd?(node)
|
49
|
+
%w{dt dd}.include? node.name
|
50
|
+
end
|
51
|
+
|
52
|
+
def dl_to_para(node)
|
53
|
+
ret = ""
|
54
|
+
e = node.at(ns("./name")) and
|
55
|
+
ret += "<p class='ListTitle' id='#{dlist['id']}'>" \
|
56
|
+
"#{e.children.to_xml}</p>"
|
57
|
+
node.elements.select { |n| dt_dd?(n) }.each_slice(2) do |dt, dd|
|
58
|
+
term = dt.children.to_xml.gsub(%r{</?p( [^>]*)>}, "")
|
59
|
+
defn = dd.children.to_xml.gsub(%r{</?p( [^>]*)>}, "")
|
60
|
+
ret += "<p id='#{dt['id']}'>#{term}: " \
|
61
|
+
"<bookmark id='#{dd['id']}'/>#{defn}</p>"
|
62
|
+
end
|
63
|
+
node.elements.each do |x|
|
64
|
+
%w(dt dd name).include?(x.name) and next
|
65
|
+
ret += x.to_xml
|
66
|
+
end
|
67
|
+
node.replace(ret.gsub(/ id=''/, ""))
|
68
|
+
end
|
69
|
+
|
70
|
+
def table1(node)
|
71
|
+
super
|
72
|
+
cols = 0
|
73
|
+
node.at(ns(".//tr")).xpath(ns("./td | ./th")).each do |x|
|
74
|
+
cols += x["colspan"]&.to_i || 1
|
75
|
+
end
|
76
|
+
name = node.at(ns("./name"))
|
77
|
+
h = node.at(ns("./thead")) || name.after("<thead> </thead>").next
|
78
|
+
unit_note = node.at(ns(".//note[@type = 'units']"))&.remove
|
79
|
+
unit_note and h.children.first.previous = full_row(cols, unit_row.to_xml)
|
80
|
+
name and h.children.first.previous =
|
81
|
+
full_row(cols, "<p class='TableTitle' style='text-align:center;'>#{name.remove.children.to_xml}</p>")
|
82
|
+
end
|
83
|
+
|
84
|
+
def full_row(cols, elem)
|
85
|
+
"<tr><td border='0' colspan='#{cols}'>#{elem}</td></tr>"
|
86
|
+
end
|
87
|
+
|
88
|
+
def annex1(elem)
|
89
|
+
lbl = @xrefs.anchor(elem["id"], :label)
|
90
|
+
if t = elem.at(ns("./title"))
|
91
|
+
t.children = "<strong>#{to_xml(t.children)}</strong>"
|
92
|
+
end
|
93
|
+
prefix_name(elem, "<br/>", lbl, "title")
|
94
|
+
end
|
7
95
|
|
8
96
|
include Init
|
9
97
|
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
require_relative "../../html2doc/lists"
|
2
|
+
|
3
|
+
module IsoDoc
|
4
|
+
module JIS
|
5
|
+
class WordConvert < IsoDoc::Iso::WordConvert
|
6
|
+
def postprocess(result, filename, dir)
|
7
|
+
filename = filename.sub(/\.doc$/, "")
|
8
|
+
header = generate_header(filename, dir)
|
9
|
+
result = from_xhtml(cleanup(to_xhtml(textcleanup(result))))
|
10
|
+
toWord(result, filename, dir, header)
|
11
|
+
@files_to_delete.each { |f| FileUtils.rm_f f }
|
12
|
+
end
|
13
|
+
|
14
|
+
def word_cleanup(docxml)
|
15
|
+
word_note_cleanup(docxml)
|
16
|
+
boldface(docxml)
|
17
|
+
super
|
18
|
+
move_to_inner_cover(docxml)
|
19
|
+
end
|
20
|
+
|
21
|
+
def move_to_inner_cover(docxml)
|
22
|
+
source = docxml.at("//div[@type = 'inner-cover-note']")
|
23
|
+
dest = docxml.at("//div[@id = 'boilerplate-inner-cover-note']")
|
24
|
+
source && dest and dest.replace(source)
|
25
|
+
source = docxml.at("//div[@type = 'contributors']")
|
26
|
+
dest = docxml.at("//div[@id = 'boilerplate-contributors']")
|
27
|
+
source && dest and dest.replace(source)
|
28
|
+
docxml
|
29
|
+
end
|
30
|
+
|
31
|
+
def word_intro(docxml, level)
|
32
|
+
intro = insert_toc(File.read(@wordintropage, encoding: "UTF-8"),
|
33
|
+
docxml, level)
|
34
|
+
intro = populate_template(intro, :word)
|
35
|
+
introxml = to_word_xhtml_fragment(intro)
|
36
|
+
docxml.at('//div[@class="WordSection2"]') << introxml
|
37
|
+
.to_xml(encoding: "US-ASCII")
|
38
|
+
end
|
39
|
+
|
40
|
+
def word_note_cleanup(docxml)
|
41
|
+
docxml.xpath("//p[@class = 'Note']").each do |p|
|
42
|
+
p.xpath("//following-sibling::p").each do |p2|
|
43
|
+
p2["class"] == "Note" and
|
44
|
+
p2["class"] = "NoteCont"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def boldface(docxml)
|
50
|
+
docxml.xpath("//b").each do |b|
|
51
|
+
b.name = "span"
|
52
|
+
b["class"] = "Strong"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def toWord(result, filename, dir, header)
|
57
|
+
result = word_split(word_cleanup(to_xhtml(result)))
|
58
|
+
@wordstylesheet = wordstylesheet_update
|
59
|
+
result.each do |k, v|
|
60
|
+
to_word1(v, "#{filename}#{k}", dir, header)
|
61
|
+
end
|
62
|
+
header&.unlink
|
63
|
+
@wordstylesheet.unlink if @wordstylesheet.is_a?(Tempfile)
|
64
|
+
end
|
65
|
+
|
66
|
+
def to_word1(result, filename, dir, header)
|
67
|
+
result or return
|
68
|
+
result = from_xhtml(result).gsub(/-DOUBLE_HYPHEN_ESCAPE-/, "--")
|
69
|
+
::Html2Doc::JIS.new(
|
70
|
+
filename: filename, imagedir: @localdir,
|
71
|
+
stylesheet: @wordstylesheet&.path,
|
72
|
+
header_file: header&.path, dir: dir,
|
73
|
+
asciimathdelims: [@openmathdelim, @closemathdelim],
|
74
|
+
liststyles: { ul: @ulstyle, ol: @olstyle }
|
75
|
+
).process(result)
|
76
|
+
end
|
77
|
+
|
78
|
+
def word_split(xml)
|
79
|
+
b = xml.dup
|
80
|
+
{ _cover: cover_split(xml), "": main_split(b) }
|
81
|
+
end
|
82
|
+
|
83
|
+
def cover_split(xml)
|
84
|
+
xml.at("//body").elements.each do |e|
|
85
|
+
e.name == "div" && e["class"] == "WordSection1" and next
|
86
|
+
e.remove
|
87
|
+
end
|
88
|
+
xml
|
89
|
+
end
|
90
|
+
|
91
|
+
def main_split(xml)
|
92
|
+
c = xml.at("//div[@class = 'WordSection1']")
|
93
|
+
c.next_element&.remove
|
94
|
+
c.remove
|
95
|
+
c = xml.at("//div[@class = 'WordSection2']")
|
96
|
+
c.elements.first.at("./br") and c.elements.first.remove
|
97
|
+
xml
|
98
|
+
end
|
99
|
+
|
100
|
+
STYLESMAP = {}.freeze
|
101
|
+
|
102
|
+
def style_cleanup(docxml)
|
103
|
+
new_styles(docxml)
|
104
|
+
index_cleanup(docxml)
|
105
|
+
end
|
106
|
+
|
107
|
+
def new_styles(docxml)
|
108
|
+
super
|
109
|
+
biblio_paras(docxml)
|
110
|
+
heading_to_para(docxml)
|
111
|
+
end
|
112
|
+
|
113
|
+
def biblio_paras(docxml)
|
114
|
+
docxml.xpath("//div[@class = 'normref_div']//" \
|
115
|
+
"p[not(@class) or @class = 'MsoNormal']").each do |p|
|
116
|
+
p["class"] = "NormRefText"
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def heading_to_para(docxml)
|
121
|
+
docxml.xpath("//h1[@class = 'ForewordTitle']").each do |p|
|
122
|
+
p.name = "p"
|
123
|
+
p.xpath("../div/p[not(@class) or @class = 'MsoNormal']").each do |n|
|
124
|
+
n["class"] = "ForewordText"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
docxml.xpath("//h1[@class = 'IntroTitle'] | //h1[@class = 'Annex'] | " \
|
128
|
+
"//h2[@class = 'Terms'] | " \
|
129
|
+
"//h3[@class = 'Terms'] | //h4[@class = 'Terms'] | " \
|
130
|
+
"//h5[@class = 'Terms'] | //h6[@class = 'Terms']").each do |p|
|
131
|
+
p.name = "p"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def word_annex_cleanup1(docxml, lvl)
|
136
|
+
docxml.xpath("//h#{lvl}[ancestor::*[@class = 'Section3']]").each do |h2|
|
137
|
+
h2.name = "p"
|
138
|
+
h2["class"] = ".h#{lvl}Annex"
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
@@ -1,19 +1,45 @@
|
|
1
|
-
require_relative "../../html2doc/lists"
|
2
1
|
require_relative "base_convert"
|
3
2
|
require "isodoc"
|
4
3
|
require_relative "init"
|
4
|
+
require_relative "word_cleanup"
|
5
5
|
|
6
6
|
module IsoDoc
|
7
7
|
module JIS
|
8
|
-
class WordConvert < IsoDoc::WordConvert
|
8
|
+
class WordConvert < IsoDoc::Iso::WordConvert
|
9
9
|
def initialize(options)
|
10
10
|
@libdir = File.dirname(__FILE__)
|
11
11
|
super
|
12
|
+
@libdir = File.dirname(__FILE__)
|
13
|
+
end
|
14
|
+
|
15
|
+
def init_dis(opt); end
|
16
|
+
|
17
|
+
def clause_attrs(node)
|
18
|
+
# capture the type of clause
|
19
|
+
{ id: node["id"], type: node["type"] }
|
12
20
|
end
|
13
21
|
|
14
|
-
def
|
15
|
-
|
16
|
-
|
22
|
+
def convert(input_filename, file = nil, debug = false,
|
23
|
+
output_filename = nil)
|
24
|
+
file = File.read(input_filename, encoding: "utf-8") if file.nil?
|
25
|
+
@openmathdelim, @closemathdelim = extract_delims(file)
|
26
|
+
docxml, filename, dir = convert_init(file, input_filename, debug)
|
27
|
+
result = convert1(docxml, filename, dir)
|
28
|
+
return result if debug
|
29
|
+
|
30
|
+
output_filename ||= "#{filename}.#{@suffix}"
|
31
|
+
postprocess(result, output_filename, dir)
|
32
|
+
FileUtils.rm_rf dir
|
33
|
+
end
|
34
|
+
|
35
|
+
def convert1(docxml, filename, dir)
|
36
|
+
@options.merge!(default_fonts({})) # updated @script
|
37
|
+
super
|
38
|
+
end
|
39
|
+
|
40
|
+
def default_fonts(_options)
|
41
|
+
{ bodyfont: (@script == "Jpan" ? '"MS Mincho",serif' : '"Times New Roman",serif'),
|
42
|
+
headerfont: (@script == "Jpan" ? '"MS Gothic",sans-serif' : '"Arial",sans-serif'),
|
17
43
|
monospacefont: '"Courier New",monospace',
|
18
44
|
normalfontsize: "10.0pt",
|
19
45
|
monospacefontsize: "9.0pt",
|
@@ -22,6 +48,7 @@ module IsoDoc
|
|
22
48
|
end
|
23
49
|
|
24
50
|
def default_file_locations(_options)
|
51
|
+
@libdir = File.dirname(__FILE__)
|
25
52
|
{ htmlstylesheet: html_doc_path("htmlstyle.scss"),
|
26
53
|
htmlcoverpage: html_doc_path("html_jis_titlepage.html"),
|
27
54
|
htmlintropage: html_doc_path("html_jis_intro.html"),
|
@@ -34,116 +61,264 @@ module IsoDoc
|
|
34
61
|
olstyle: "l8" }
|
35
62
|
end
|
36
63
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
64
|
+
def norm_ref(isoxml, out, num)
|
65
|
+
(f = isoxml.at(ns(norm_ref_xpath)) and f["hidden"] != "true") or
|
66
|
+
return num
|
67
|
+
out.div class: "normref_div" do |div|
|
68
|
+
num += 1
|
69
|
+
clause_name(f, f.at(ns("./title")), div, nil)
|
70
|
+
if f.name == "clause"
|
71
|
+
f.elements.each { |e| parse(e, div) unless e.name == "title" }
|
72
|
+
else biblio_list(f, div, false)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
num
|
76
|
+
end
|
77
|
+
|
78
|
+
def bibliography(isoxml, out)
|
79
|
+
(f = isoxml.at(ns(bibliography_xpath)) and f["hidden"] != "true") or
|
80
|
+
return
|
81
|
+
page_break(out)
|
82
|
+
out.div class: "bibliography" do |div|
|
83
|
+
div.h1 class: "Section3" do |h1|
|
84
|
+
f.at(ns("./title"))&.children&.each { |c2| parse(c2, h1) }
|
85
|
+
end
|
86
|
+
biblio_list(f, div, true)
|
87
|
+
end
|
43
88
|
end
|
44
89
|
|
45
|
-
def
|
46
|
-
|
47
|
-
|
48
|
-
|
90
|
+
def annex_name(_annex, name, div)
|
91
|
+
preceding_floating_titles(name, div)
|
92
|
+
return if name.nil?
|
93
|
+
|
94
|
+
div.h1 class: "Annex" do |t|
|
95
|
+
name.children.each { |c2| parse(c2, t) }
|
96
|
+
clause_parse_subtitle(name, t)
|
97
|
+
end
|
49
98
|
end
|
50
99
|
|
51
|
-
def
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
100
|
+
def preface(isoxml, out)
|
101
|
+
isoxml.xpath(ns("//preface/clause | //preface/references | " \
|
102
|
+
"//preface/definitions | //preface/terms")).each do |f|
|
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
|
56
109
|
end
|
57
110
|
end
|
58
111
|
end
|
59
112
|
|
60
|
-
def
|
61
|
-
|
62
|
-
|
113
|
+
def introduction(isoxml, out)
|
114
|
+
f = isoxml.at(ns("//introduction")) || return
|
115
|
+
out.div class: "Section3", id: f["id"] do |div|
|
116
|
+
clause_name(f, f.at(ns("./title")), div, { class: "IntroTitle" })
|
117
|
+
f.elements.each do |e|
|
118
|
+
parse(e, div) unless e.name == "title"
|
119
|
+
end
|
63
120
|
end
|
64
|
-
|
65
|
-
|
66
|
-
|
121
|
+
end
|
122
|
+
|
123
|
+
def make_body2(body, docxml)
|
124
|
+
body.div class: "WordSection2" do |div2|
|
125
|
+
boilerplate docxml, div2
|
126
|
+
preface_block docxml, div2
|
127
|
+
abstract docxml, div2
|
128
|
+
foreword docxml, div2
|
129
|
+
preface docxml, div2
|
130
|
+
acknowledgements docxml, div2
|
131
|
+
div2.p { |p| p << " " } # placeholder
|
67
132
|
end
|
133
|
+
section_break(body)
|
134
|
+
end
|
135
|
+
|
136
|
+
def middle(isoxml, out)
|
137
|
+
middle_title(isoxml, out)
|
138
|
+
middle_admonitions(isoxml, out)
|
139
|
+
introduction isoxml, out
|
140
|
+
scope isoxml, out, 0
|
141
|
+
norm_ref isoxml, out, 0
|
142
|
+
terms_defs isoxml, out, 0
|
143
|
+
symbols_abbrevs isoxml, out, 0
|
144
|
+
clause isoxml, out
|
145
|
+
annex isoxml, out
|
146
|
+
bibliography isoxml, out
|
147
|
+
# colophon isoxml, out
|
68
148
|
end
|
69
149
|
|
70
|
-
def
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
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
|
75
177
|
end
|
76
|
-
header&.unlink
|
77
|
-
@wordstylesheet.unlink if @wordstylesheet.is_a?(Tempfile)
|
78
178
|
end
|
79
179
|
|
80
|
-
def
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
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
|
90
199
|
end
|
91
200
|
|
92
|
-
def
|
93
|
-
|
94
|
-
|
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
|
95
206
|
end
|
96
207
|
|
97
|
-
def
|
98
|
-
|
99
|
-
|
100
|
-
|
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
|
101
216
|
end
|
102
|
-
xml
|
103
217
|
end
|
104
218
|
|
105
|
-
def
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
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
|
110
225
|
end
|
111
226
|
|
112
|
-
def
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
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) }
|
121
246
|
end
|
122
247
|
end
|
123
|
-
num
|
124
248
|
end
|
125
249
|
|
126
|
-
def
|
127
|
-
(
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
250
|
+
def footnote_parse(node, out)
|
251
|
+
return table_footnote_parse(node, out) if @in_table || @in_figure # &&
|
252
|
+
|
253
|
+
# !node.ancestors.map(&:name).include?("name")
|
254
|
+
|
255
|
+
fn = node["reference"] || UUIDTools::UUID.random_create.to_s
|
256
|
+
return seen_footnote_parse(node, out, fn) if @seen_footnote.include?(fn)
|
257
|
+
|
258
|
+
@fn_bookmarks[fn] = bookmarkid
|
259
|
+
out.span style: "mso-bookmark:_Ref#{@fn_bookmarks[fn]}" do |s|
|
260
|
+
s.a class: "FootnoteRef", "epub:type": "footnote",
|
261
|
+
href: "#ftn#{fn}" do |a|
|
262
|
+
a.sup { |sup| sup << fn }
|
133
263
|
end
|
134
|
-
biblio_list(f, div, true)
|
135
264
|
end
|
265
|
+
@in_footnote = true
|
266
|
+
@footnotes << make_generic_footnote_text(node, fn)
|
267
|
+
@in_footnote = false
|
268
|
+
@seen_footnote << fn
|
136
269
|
end
|
137
270
|
|
138
|
-
def
|
139
|
-
|
140
|
-
|
271
|
+
def make_table_footnote_target(out, fnid, fnref)
|
272
|
+
attrs = { id: fnid, class: "TableFootnoteRef" }
|
273
|
+
out.span do |s|
|
274
|
+
s << @i18n.table_footnote
|
275
|
+
out.span **attrs do |a|
|
276
|
+
a << "#{fnref})"
|
277
|
+
end
|
278
|
+
insert_tab(s, 1)
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
def table_title_parse(node, out); end
|
283
|
+
|
284
|
+
def table_attrs(node)
|
285
|
+
{ id: node["id"], title: node["alt"],
|
286
|
+
summary: node["summary"], width: node["width"],
|
287
|
+
class: (node.text.length > 4000 ? "MsoTableGridBig" : "MsoTableGrid"),
|
288
|
+
style: "border-collapse:collapse;" \
|
289
|
+
"mso-table-anchor-horizontal:column;mso-table-overlap:never;" \
|
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};"
|
141
308
|
end
|
142
309
|
|
143
|
-
def
|
144
|
-
|
145
|
-
|
310
|
+
def new_fullcolspan_row(table, tfoot)
|
311
|
+
# how many columns in the table?
|
312
|
+
cols = 0
|
313
|
+
table.at(".//tr").xpath("./td | ./th").each do |td|
|
314
|
+
cols += (td["colspan"] ? td["colspan"].to_i : 1)
|
146
315
|
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
|
147
322
|
end
|
148
323
|
|
149
324
|
include BaseConvert
|
data/lib/isodoc/jis/xref.rb
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
module IsoDoc
|
2
2
|
module JIS
|
3
3
|
class Xref < IsoDoc::Iso::Xref
|
4
|
+
def annex_name_lbl(clause, num)
|
5
|
+
obl = l10n("(#{@labels['inform_annex']})")
|
6
|
+
clause["obligation"] == "normative" and
|
7
|
+
obl = l10n("(#{@labels['norm_annex']})")
|
8
|
+
title = Common::case_with_markup(@labels["annex"], "capital", @script)
|
9
|
+
l10n("#{title} #{num}<br/>#{obl}")
|
10
|
+
end
|
4
11
|
end
|
5
12
|
end
|
6
13
|
end
|