metanorma-jis 0.0.10 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/isodoc/jis/base_convert.rb +15 -104
- data/lib/isodoc/jis/html/style-human.css +8 -8
- data/lib/isodoc/jis/html/style-human.scss +8 -8
- data/lib/isodoc/jis/html/style-iso.css +19 -19
- data/lib/isodoc/jis/html/style-iso.scss +19 -19
- data/lib/isodoc/jis/jis.international-standard.xsl +238 -63
- data/lib/isodoc/jis/presentation_xml_convert.rb +68 -16
- data/lib/isodoc/jis/word_convert.rb +22 -56
- data/lib/isodoc/jis/xref.rb +36 -11
- data/lib/metanorma/jis/front.rb +106 -18
- data/lib/metanorma/jis/isodoc.rng +29 -4
- data/lib/metanorma/jis/version.rb +1 -1
- data/metanorma-jis.gemspec +1 -3
- metadata +4 -4
@@ -63,34 +63,29 @@ module IsoDoc
|
|
63
63
|
olstyle: "l8" }
|
64
64
|
end
|
65
65
|
|
66
|
-
def norm_ref(
|
67
|
-
|
68
|
-
return num
|
66
|
+
def norm_ref(node, out)
|
67
|
+
node["hidden"] != "true" or return
|
69
68
|
out.div class: "normref_div" do |div|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
else biblio_list(f, div, false)
|
69
|
+
clause_name(node, node.at(ns("./title")), div, nil)
|
70
|
+
if node.name == "clause"
|
71
|
+
node.elements.each { |e| parse(e, div) unless e.name == "title" }
|
72
|
+
else biblio_list(node, div, false)
|
75
73
|
end
|
76
74
|
end
|
77
|
-
num
|
78
75
|
end
|
79
76
|
|
80
|
-
def bibliography(
|
81
|
-
|
82
|
-
return
|
77
|
+
def bibliography(node, out)
|
78
|
+
node["hidden"] != "true" or return
|
83
79
|
page_break(out)
|
84
80
|
out.div class: "bibliography" do |div|
|
85
81
|
div.h1 class: "Section3" do |h1|
|
86
|
-
|
82
|
+
node.at(ns("./title"))&.children&.each { |c2| parse(c2, h1) }
|
87
83
|
end
|
88
|
-
biblio_list(
|
84
|
+
biblio_list(node, div, true)
|
89
85
|
end
|
90
86
|
end
|
91
87
|
|
92
88
|
def annex_name(_annex, name, div)
|
93
|
-
preceding_floating_titles(name, div)
|
94
89
|
return if name.nil?
|
95
90
|
|
96
91
|
div.h1 class: "Annex" do |t|
|
@@ -114,32 +109,6 @@ module IsoDoc
|
|
114
109
|
end
|
115
110
|
end
|
116
111
|
|
117
|
-
def make_body2(body, docxml)
|
118
|
-
body.div class: "WordSection2" do |div2|
|
119
|
-
boilerplate docxml, div2
|
120
|
-
front docxml, div2
|
121
|
-
div2.p { |p| p << " " } # placeholder
|
122
|
-
end
|
123
|
-
section_break(body)
|
124
|
-
end
|
125
|
-
|
126
|
-
def middle(isoxml, out)
|
127
|
-
middle_title(isoxml, out)
|
128
|
-
middle_admonitions(isoxml, out)
|
129
|
-
i = isoxml.at(ns("//sections/introduction")) and
|
130
|
-
introduction i, out
|
131
|
-
scope isoxml, out, 0
|
132
|
-
norm_ref isoxml, out, 0
|
133
|
-
clause_etc isoxml, out, 0
|
134
|
-
annex isoxml, out
|
135
|
-
bibliography isoxml, out
|
136
|
-
end
|
137
|
-
|
138
|
-
def make_body3(body, docxml)
|
139
|
-
super
|
140
|
-
commentary docxml, body
|
141
|
-
end
|
142
|
-
|
143
112
|
def footnote_parse(node, out)
|
144
113
|
return table_footnote_parse(node, out) if @in_table || @in_figure # &&
|
145
114
|
|
@@ -161,23 +130,20 @@ module IsoDoc
|
|
161
130
|
@seen_footnote << fn
|
162
131
|
end
|
163
132
|
|
164
|
-
def annex(
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
amd(
|
133
|
+
def annex(node, out)
|
134
|
+
node["commentary"] == "true" and return commentary(node, out)
|
135
|
+
amd?(node.document.root) and
|
136
|
+
@suppressheadingnumbers = @oldsuppressheadingnumbers
|
137
|
+
page_break(out)
|
138
|
+
render_annex(out, node)
|
139
|
+
amd?(node.document.root) and @suppressheadingnumbers = true
|
171
140
|
end
|
172
141
|
|
173
|
-
def commentary(
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
commentary_title(isoxml, div)
|
179
|
-
render_annex(div, c)
|
180
|
-
end
|
142
|
+
def commentary(node, out)
|
143
|
+
out.span style: "mso-bookmark:PRECOMMENTARYPAGEREF"
|
144
|
+
section_break(out)
|
145
|
+
out.div class: "WordSectionCommentary" do |div|
|
146
|
+
render_annex(div, node)
|
181
147
|
end
|
182
148
|
end
|
183
149
|
|
data/lib/isodoc/jis/xref.rb
CHANGED
@@ -25,23 +25,48 @@ module IsoDoc
|
|
25
25
|
l10n("#{title} #{num}<br/>#{obl}")
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
def clause_order_main(docxml)
|
29
|
+
[
|
30
|
+
{ path: "//sections/introduction" },
|
31
|
+
{ path: "//clause[@type = 'scope']" },
|
32
|
+
{ path: @klass.norm_ref_xpath },
|
33
|
+
{ path: "//sections/terms | " \
|
34
|
+
"//sections/clause[descendant::terms]" },
|
35
|
+
{ path: "//sections/definitions | " \
|
36
|
+
"//sections/clause[descendant::definitions][not(descendant::terms)]" },
|
37
|
+
{ path: @klass.middle_clause(docxml), multi: true },
|
38
|
+
]
|
39
|
+
end
|
40
|
+
|
41
|
+
def clause_order_annex(_docxml)
|
42
|
+
[{ path: "//annex[not(@commentary = 'true')]", multi: true }]
|
43
|
+
end
|
44
|
+
|
45
|
+
def clause_order_back(_docxml)
|
46
|
+
[
|
47
|
+
{ path: @klass.bibliography_xpath },
|
48
|
+
{ path: "//annex[@commentary = 'true']", multi: true },
|
49
|
+
{ path: "//indexsect", multi: true },
|
50
|
+
{ path: "//colophon/*", multi: true },
|
51
|
+
]
|
52
|
+
end
|
53
|
+
|
54
|
+
def section_names(clause, num, lvl)
|
55
|
+
clause&.name == "introduction" and clause["unnumbered"] = "true"
|
56
|
+
super
|
57
|
+
end
|
58
|
+
|
59
|
+
def back_clauses_anchor_names(xml)
|
60
|
+
clause_order_back(xml).each do |a|
|
61
|
+
xml.xpath(ns(a[:path])).each do |c|
|
32
62
|
if c["commentary"] == "true"
|
33
63
|
commentary_names(c)
|
34
64
|
else
|
35
|
-
|
65
|
+
preface_names(c)
|
36
66
|
end
|
67
|
+
a[:multi] or break
|
37
68
|
end
|
38
|
-
xml.xpath(ns(@klass.bibliography_xpath)).each do |b|
|
39
|
-
preface_names(b)
|
40
|
-
end
|
41
|
-
xml.xpath(ns("//colophon/clause")).each { |b| preface_names(b) }
|
42
|
-
xml.xpath(ns("//indexsect")).each { |b| preface_names(b) }
|
43
69
|
end
|
44
|
-
references(xml) if @parse_settings.empty? || @parse_settings[:refs]
|
45
70
|
end
|
46
71
|
|
47
72
|
def commentary_names(clause)
|
data/lib/metanorma/jis/front.rb
CHANGED
@@ -7,42 +7,130 @@ module Metanorma
|
|
7
7
|
super.merge("Japanese Industrial Standards" => "JIS")
|
8
8
|
end
|
9
9
|
|
10
|
+
def home_agency
|
11
|
+
"JIS"
|
12
|
+
end
|
13
|
+
|
14
|
+
# Like the ISO code, but multilingual
|
10
15
|
def metadata_author(node, xml)
|
11
|
-
|
12
|
-
|
13
|
-
xml.contributor do |c|
|
14
|
-
c.role type: "author"
|
15
|
-
c.organization do |a|
|
16
|
-
organization(a, p, false, node, !node.attr("publisher"))
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
16
|
+
metadata_contrib_sdo(node, xml, JIS_HASH,
|
17
|
+
{ role: "author", sourcerole: "publisher" })
|
20
18
|
node.attr("doctype") == "expert-commentary" and
|
21
19
|
personal_author(node, xml)
|
22
20
|
end
|
23
21
|
|
24
22
|
def metadata_publisher(node, xml)
|
25
|
-
|
26
|
-
|
23
|
+
metadata_contrib_sdo(node, xml, JIS_HASH,
|
24
|
+
{ role: "publisher", sourcerole: "publisher" })
|
25
|
+
metadata_contrib_sdo(node, xml, nil,
|
26
|
+
{ role: "authorizer",
|
27
|
+
sourcerole: "investigative-organization",
|
28
|
+
desc: "Investigative organization" })
|
29
|
+
metadata_contrib_sdo(node, xml, nil,
|
30
|
+
{ role: "authorizer",
|
31
|
+
sourcerole: "investigative-committee",
|
32
|
+
desc: "Investigative committee" })
|
33
|
+
end
|
34
|
+
|
35
|
+
LANGS = %w(ja en).freeze
|
36
|
+
|
37
|
+
JIS_HASH =
|
38
|
+
{ "ja" => "日本工業規格", "en" => "Japanese Industrial Standards" }.freeze
|
39
|
+
|
40
|
+
def metadata_contrib_sdo(node, xml, default_value, opt)
|
41
|
+
pub, default = metadata_contrib_extract(node, opt[:sourcerole], default_value)
|
42
|
+
metadata_contrib_sdo_build(node, xml, pub, default, opt)
|
43
|
+
end
|
44
|
+
|
45
|
+
def metadata_contrib_sdo_build(node, xml, pub, default, opt)
|
46
|
+
pub&.each do |p|
|
27
47
|
xml.contributor do |c|
|
28
|
-
c.role type:
|
48
|
+
c.role type: opt[:role] do |r|
|
49
|
+
opt[:desc] and r.description opt[:desc]
|
50
|
+
end
|
29
51
|
c.organization do |a|
|
30
|
-
organization(a, p,
|
52
|
+
organization(a, p, opt[:role] == "publisher", node, default)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def metadata_contrib_extract(node, role, default_value)
|
59
|
+
pub, default = multiling_docattr_csv(node, role, LANGS, default_value)
|
60
|
+
a = node.attr("#{role}-abbr") and abbr = a # one abbrev for all languages
|
61
|
+
[pub&.map { |p| { name: p, abbr: abbr } }, default]
|
62
|
+
end
|
63
|
+
|
64
|
+
def multiling_docattr(node, attr, langs)
|
65
|
+
ret = node.attr(attr) and return ret
|
66
|
+
ret = langs.each_with_object({}).each do |l, m|
|
67
|
+
x = node.attr("#{attr}-#{l}") and m[l] = x
|
68
|
+
end.compact
|
69
|
+
ret.empty? and return nil
|
70
|
+
ret
|
71
|
+
end
|
72
|
+
|
73
|
+
def multiling_docattr_csv(node, attr, langs, default)
|
74
|
+
ret = multiling_docattr(node, attr, langs)
|
75
|
+
not_found = ret.nil?
|
76
|
+
ret ||= default
|
77
|
+
ret &&= if ret.is_a?(Hash) then interleave_multiling_docattr(ret)
|
78
|
+
else csv_split(ret)
|
79
|
+
end
|
80
|
+
[ret, not_found]
|
81
|
+
end
|
82
|
+
|
83
|
+
# TODO abort if CSV count different between different languages
|
84
|
+
def interleave_multiling_docattr(ret)
|
85
|
+
h = ret.transform_values { |v| csv_split(v) }
|
86
|
+
h.each_with_object([]) do |(k, v), m|
|
87
|
+
v.each_with_index do |v1, i|
|
88
|
+
m[i] ||= {}
|
89
|
+
m[i][k] = v1
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def multiling_noko_value(value, tag, xml)
|
95
|
+
if value.is_a?(Hash)
|
96
|
+
xml.send tag do |t|
|
97
|
+
value.each do |k, v|
|
98
|
+
t.variant v, language: k
|
31
99
|
end
|
32
100
|
end
|
101
|
+
elsif value.is_a?(Array)
|
102
|
+
value.each { |a| xml.send tag, a }
|
103
|
+
else xml.send tag, value
|
33
104
|
end
|
34
105
|
end
|
35
106
|
|
107
|
+
def organization(xml, org, _is_pub, node = nil, default_org = nil)
|
108
|
+
org.is_a?(Hash) or org = { name: org }
|
109
|
+
abbrevs = org_abbrev
|
110
|
+
name_str = org[:name].is_a?(Hash) ? org[:name]["en"] : org[:name]
|
111
|
+
n = abbrevs.invert[org[:name]] and org = { name: n, abbr: org[:name] }
|
112
|
+
multiling_noko_value(org[:name], "name", xml)
|
113
|
+
default_org && a = multiling_docattr(node, "subdivision", LANGS) and
|
114
|
+
multiling_noko_value(a, "subdivision", xml)
|
115
|
+
abbr = org[:abbr]
|
116
|
+
abbr ||= org_abbrev[name_str]
|
117
|
+
default_org && b = node.attr("subdivision-abbr") and abbr = b
|
118
|
+
abbr and xml.abbreviation abbr
|
119
|
+
# is_pub && node and org_address(node, org) # should refactor into struct, like abbr
|
120
|
+
end
|
121
|
+
|
36
122
|
def metadata_copyright(node, xml)
|
37
|
-
pub = node
|
38
|
-
|
123
|
+
pub, default = metadata_contrib_extract(node, "copyright-holder", nil)
|
124
|
+
if default
|
125
|
+
pub, default = metadata_contrib_extract(node, "publisher", JIS_HASH)
|
126
|
+
end
|
127
|
+
|
128
|
+
pub&.each do |p|
|
39
129
|
xml.copyright do |c|
|
40
130
|
c.from (node.attr("copyright-year") || Date.today.year)
|
41
131
|
c.owner do |owner|
|
42
132
|
owner.organization do |o|
|
43
|
-
organization(o, p, true, node,
|
44
|
-
!node.attr("copyright-holder") ||
|
45
|
-
node.attr("publisher"))
|
133
|
+
organization(o, p, true, node, default)
|
46
134
|
end
|
47
135
|
end
|
48
136
|
end
|
@@ -17,7 +17,7 @@
|
|
17
17
|
these elements; we just want one namespace for any child grammars
|
18
18
|
of this.
|
19
19
|
-->
|
20
|
-
<!-- VERSION v1.2.
|
20
|
+
<!-- VERSION v1.2.4 -->
|
21
21
|
<grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
22
22
|
<include href="reqt.rng"/>
|
23
23
|
<include href="basicdoc.rng">
|
@@ -192,9 +192,11 @@
|
|
192
192
|
</attribute>
|
193
193
|
</optional>
|
194
194
|
<attribute name="citeas"/>
|
195
|
-
<
|
196
|
-
<
|
197
|
-
|
195
|
+
<optional>
|
196
|
+
<attribute name="type">
|
197
|
+
<ref name="ReferenceFormat"/>
|
198
|
+
</attribute>
|
199
|
+
</optional>
|
198
200
|
<optional>
|
199
201
|
<attribute name="alt"/>
|
200
202
|
</optional>
|
@@ -836,6 +838,26 @@
|
|
836
838
|
<ref name="paragraph"/>
|
837
839
|
</element>
|
838
840
|
</define>
|
841
|
+
<define name="stem">
|
842
|
+
<element name="stem">
|
843
|
+
<attribute name="type">
|
844
|
+
<choice>
|
845
|
+
<value>MathML</value>
|
846
|
+
<value>AsciiMath</value>
|
847
|
+
<value>LatexMath</value>
|
848
|
+
</choice>
|
849
|
+
</attribute>
|
850
|
+
<attribute name="block">
|
851
|
+
<data type="boolean"/>
|
852
|
+
</attribute>
|
853
|
+
<oneOrMore>
|
854
|
+
<choice>
|
855
|
+
<text/>
|
856
|
+
<ref name="AnyElement"/>
|
857
|
+
</choice>
|
858
|
+
</oneOrMore>
|
859
|
+
</element>
|
860
|
+
</define>
|
839
861
|
<define name="em">
|
840
862
|
<element name="em">
|
841
863
|
<zeroOrMore>
|
@@ -2046,6 +2068,9 @@
|
|
2046
2068
|
</define>
|
2047
2069
|
<define name="termdefinition">
|
2048
2070
|
<element name="definition">
|
2071
|
+
<optional>
|
2072
|
+
<attribute name="type"/>
|
2073
|
+
</optional>
|
2049
2074
|
<choice>
|
2050
2075
|
<ref name="verbaldefinition"/>
|
2051
2076
|
<ref name="nonverbalrep"/>
|
data/metanorma-jis.gemspec
CHANGED
@@ -30,9 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.test_files = `git ls-files -- {spec}/*`.split("\n")
|
31
31
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
32
32
|
|
33
|
-
spec.add_dependency "metanorma-iso", "~> 2.
|
34
|
-
#spec.add_dependency "relaton-bipm", "~> 1.14.8"
|
35
|
-
#spec.add_dependency "relaton-iho", "~> 1.14.3"
|
33
|
+
spec.add_dependency "metanorma-iso", "~> 2.5.1"
|
36
34
|
spec.add_dependency "pubid-jis"
|
37
35
|
|
38
36
|
spec.add_development_dependency "debug"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-jis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: metanorma-iso
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.5.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.5.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pubid-jis
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|