metanorma-jis 0.2.12 → 0.3.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 +20 -0
- data/lib/isodoc/jis/i18n-en.yaml +3 -0
- data/lib/isodoc/jis/i18n-ja.yaml +3 -0
- data/lib/isodoc/jis/init.rb +5 -0
- data/lib/isodoc/jis/jis.international-standard.xsl +1069 -998
- data/lib/isodoc/jis/metadata.rb +10 -7
- data/lib/isodoc/jis/presentation_section.rb +48 -4
- data/lib/isodoc/jis/presentation_xml_convert.rb +3 -2
- data/lib/isodoc/jis/xref.rb +12 -1
- data/lib/metanorma/jis/front.rb +9 -8
- data/lib/metanorma/jis/isodoc.rng +5 -5
- data/lib/metanorma/jis/version.rb +1 -1
- data/lib/relaton/render-jis/general.rb +21 -0
- data/lib/relaton/render-jis/parse.rb +24 -0
- data/metanorma-jis.gemspec +1 -0
- metadata +18 -2
data/lib/isodoc/jis/metadata.rb
CHANGED
@@ -73,20 +73,23 @@ module IsoDoc
|
|
73
73
|
investigative_committee(xml)
|
74
74
|
end
|
75
75
|
|
76
|
+
def extract_role(role, desc)
|
77
|
+
<<~XPATH
|
78
|
+
//bibdata/contributor[xmlns:role/@type = '#{role}'][xmlns:role/description = '#{desc}' or xmlns:role/description = '#{desc.downcase}']
|
79
|
+
XPATH
|
80
|
+
end
|
81
|
+
|
76
82
|
def investigative_organisation(xml)
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
org = xml.at(ns(xpath))
|
83
|
+
p = extract_role("authorizer", "Investigative organization")
|
84
|
+
org = xml.at(ns("#{p}/organization/name[@language = '#{@lang}']"))
|
85
|
+
org ||= xml.at(ns("#{p}/organization/name"))
|
81
86
|
if org then set_encoded(:"investigative-organization", org)
|
82
87
|
else set(:"investigative-organization", get[:publisher])
|
83
88
|
end
|
84
89
|
end
|
85
90
|
|
86
91
|
def investigative_committee(xml)
|
87
|
-
xpath = "
|
88
|
-
"[xmlns:role/@type = 'authorizer'][xmlns:role/description = " \
|
89
|
-
"'investigative committee']"
|
92
|
+
xpath = extract_role("authorizer", "Investigative committee")
|
90
93
|
if o = xml.at(ns("#{xpath}/organization/name"))
|
91
94
|
set_encoded(:"investigative-committee", o)
|
92
95
|
elsif p = xml.at(ns("#{xpath}/person"))
|
@@ -22,7 +22,7 @@ module IsoDoc
|
|
22
22
|
docxml.at(ns("//annex[@commentary = 'true']")) or return
|
23
23
|
b = docxml.at(ns("//bibliography")) ||
|
24
24
|
docxml.at(ns("//annex[last()]")).after(" ").next
|
25
|
-
docxml.xpath(ns("//annex[@commentary = 'true']")).
|
25
|
+
docxml.xpath(ns("//annex[@commentary = 'true']")).reverse_each do |x|
|
26
26
|
b.next = x.remove
|
27
27
|
end
|
28
28
|
end
|
@@ -42,17 +42,22 @@ module IsoDoc
|
|
42
42
|
elem.previous = ret
|
43
43
|
end
|
44
44
|
|
45
|
-
def
|
46
|
-
|
45
|
+
def make_preface(docxml)
|
46
|
+
docxml.at(ns("//preface")) ||
|
47
47
|
docxml.at(ns("//sections | //annex | //bibliography"))
|
48
48
|
&.before("<preface> </preface>")
|
49
|
-
&.previous_element
|
49
|
+
&.previous_element
|
50
|
+
end
|
51
|
+
|
52
|
+
def toc_title_insert_pt(docxml)
|
53
|
+
ins = make_preface(docxml) or return nil
|
50
54
|
ins.children.last.after(" ").next
|
51
55
|
end
|
52
56
|
|
53
57
|
def preface_rearrange(doc)
|
54
58
|
move_introduction(doc)
|
55
59
|
super
|
60
|
+
move_participants(doc)
|
56
61
|
end
|
57
62
|
|
58
63
|
def move_introduction(doc)
|
@@ -63,6 +68,45 @@ module IsoDoc
|
|
63
68
|
dest.children.first.next = source
|
64
69
|
end
|
65
70
|
|
71
|
+
def move_participants(doc)
|
72
|
+
p = doc.at(ns("//clause[@type = 'participants']")) or return
|
73
|
+
t = participant_table(p) or return
|
74
|
+
p.remove
|
75
|
+
ins = make_preface(doc) or return nil
|
76
|
+
ins.children.first.previous = t
|
77
|
+
end
|
78
|
+
|
79
|
+
def participant_table(clause)
|
80
|
+
s = clause.at(ns("./sourcecode")) or return nil
|
81
|
+
y = YAML.safe_load(s.children.to_xml(encoding: "UTF-8")) or return nil
|
82
|
+
y.is_a?(Array) or return nil
|
83
|
+
out1 = <<~OUTPUT
|
84
|
+
<clause id='_#{UUIDTools::UUID.random_create}'><title>#{@meta.get[:"investigative-committee"]} #{@i18n.membership_table}</title>
|
85
|
+
<table unnumbered='true'>
|
86
|
+
<thead>
|
87
|
+
<tr><th/><th>#{@i18n.full_name}</th><th>#{@i18n.affiliation}</th></tr>
|
88
|
+
</thead>
|
89
|
+
<tbody>
|
90
|
+
OUTPUT
|
91
|
+
out2 = <<~OUTPUT
|
92
|
+
</tbody></table></clause>
|
93
|
+
OUTPUT
|
94
|
+
"#{out1}#{participant_rows(y)}#{out2}"
|
95
|
+
end
|
96
|
+
|
97
|
+
def participant_rows(yaml)
|
98
|
+
yaml.map do |y|
|
99
|
+
r = y["role"] ? @i18n.l10n("(#{y['role']})") : ""
|
100
|
+
n = y["name"]
|
101
|
+
if n.is_a?(Hash)
|
102
|
+
n =
|
103
|
+
if @lang == "ja" then "#{n['surname']} #{n['givenname']}"
|
104
|
+
else "#{n['givenname']} #{n['surname']}" end
|
105
|
+
end
|
106
|
+
"<tr><td>#{r}</rd><td>#{n}</td><td>#{y['affiliation']}</td></tr>"
|
107
|
+
end.join("\n")
|
108
|
+
end
|
109
|
+
|
66
110
|
def middle_title(docxml)
|
67
111
|
s = docxml.at(ns("//sections")) or return
|
68
112
|
elem = s.children.first
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require_relative "init"
|
2
2
|
require "isodoc"
|
3
3
|
require_relative "presentation_section"
|
4
|
+
require_relative "../../relaton/render-jis/general"
|
4
5
|
|
5
6
|
module IsoDoc
|
6
7
|
module JIS
|
@@ -77,8 +78,8 @@ module IsoDoc
|
|
77
78
|
end
|
78
79
|
|
79
80
|
def dl_to_para_name(node)
|
80
|
-
e = node.at(ns("./name"))
|
81
|
-
"<p class='ListTitle'>#{e
|
81
|
+
e = node.at(ns("./name")) or return ""
|
82
|
+
"<p class='ListTitle'>#{e.children.to_xml}</p>"
|
82
83
|
end
|
83
84
|
|
84
85
|
def dl_to_para_terms(node)
|
data/lib/isodoc/jis/xref.rb
CHANGED
@@ -17,11 +17,22 @@ module IsoDoc
|
|
17
17
|
end
|
18
18
|
|
19
19
|
class Xref < IsoDoc::Iso::Xref
|
20
|
+
def hierfigsep
|
21
|
+
@lang == "ja" ? "の" : super
|
22
|
+
end
|
23
|
+
|
24
|
+
def subfigure_label(subfignum)
|
25
|
+
subfignum.zero? and return ""
|
26
|
+
sep = @lang == "ja" ? "の" : " "
|
27
|
+
"#{sep}#{(subfignum + 96).chr})"
|
28
|
+
end
|
29
|
+
|
20
30
|
def annex_name_lbl(clause, num)
|
21
31
|
obl = l10n("(#{@labels['inform_annex']})")
|
22
32
|
clause["obligation"] == "normative" and
|
23
33
|
obl = l10n("(#{@labels['norm_annex']})")
|
24
|
-
title = Common::case_with_markup(@labels["annex"], "capital",
|
34
|
+
title = Common::case_with_markup(@labels["annex"], "capital",
|
35
|
+
@script)
|
25
36
|
l10n("#{title} #{num}<br/>#{obl}")
|
26
37
|
end
|
27
38
|
|
data/lib/metanorma/jis/front.rb
CHANGED
@@ -14,12 +14,12 @@ module Metanorma
|
|
14
14
|
def metadata_author(node, xml)
|
15
15
|
org_contributor(node, xml,
|
16
16
|
{ source: ["publisher", "pub"], role: "author",
|
17
|
-
default:
|
17
|
+
default: pub_hash })
|
18
18
|
personal_author(node, xml)
|
19
19
|
end
|
20
20
|
|
21
21
|
def metadata_publisher(node, xml)
|
22
|
-
[{ source: ["publisher", "pub"], role: "publisher", default:
|
22
|
+
[{ source: ["publisher", "pub"], role: "publisher", default: pub_hash },
|
23
23
|
{ role: "authorizer",
|
24
24
|
source: ["investigative-organization"],
|
25
25
|
desc: "Investigative organization" },
|
@@ -32,8 +32,9 @@ module Metanorma
|
|
32
32
|
|
33
33
|
LANGS = %w(ja en).freeze
|
34
34
|
|
35
|
-
|
36
|
-
{ "ja" => "日本工業規格", "en" => "Japanese Industrial Standards" }
|
35
|
+
def pub_hash
|
36
|
+
{ "ja" => "日本工業規格", "en" => "Japanese Industrial Standards" }
|
37
|
+
end
|
37
38
|
|
38
39
|
def org_organization(node, xml, org)
|
39
40
|
organization(xml, { name: org[:name], abbr: org[:abbr] }.compact,
|
@@ -92,9 +93,9 @@ module Metanorma
|
|
92
93
|
|
93
94
|
def multiling_noko_value(value, tag, xml)
|
94
95
|
if value.is_a?(Hash)
|
95
|
-
|
96
|
-
|
97
|
-
|
96
|
+
value.each do |k, v|
|
97
|
+
xml.send tag, language: k do |x|
|
98
|
+
x << v
|
98
99
|
end
|
99
100
|
end
|
100
101
|
elsif value.is_a?(Array)
|
@@ -119,7 +120,7 @@ module Metanorma
|
|
119
120
|
|
120
121
|
def copyright_parse(node)
|
121
122
|
opt = { source: ["copyright-holder", "publisher", "pub"],
|
122
|
-
role: "publisher", default:
|
123
|
+
role: "publisher", default: pub_hash }
|
123
124
|
ret = org_attrs_parse(node, opt)
|
124
125
|
ret.empty? and ret = [{ name: "-" }]
|
125
126
|
ret
|
@@ -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.3.
|
20
|
+
<!-- VERSION v1.3.3 -->
|
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">
|
@@ -331,9 +331,9 @@
|
|
331
331
|
<zeroOrMore>
|
332
332
|
<ref name="table-note"/>
|
333
333
|
</zeroOrMore>
|
334
|
-
<
|
334
|
+
<zeroOrMore>
|
335
335
|
<ref name="source"/>
|
336
|
-
</
|
336
|
+
</zeroOrMore>
|
337
337
|
</define>
|
338
338
|
<define name="FigureAttr">
|
339
339
|
<optional>
|
@@ -380,9 +380,9 @@
|
|
380
380
|
<zeroOrMore>
|
381
381
|
<ref name="note"/>
|
382
382
|
</zeroOrMore>
|
383
|
-
<
|
383
|
+
<zeroOrMore>
|
384
384
|
<ref name="source"/>
|
385
|
-
</
|
385
|
+
</zeroOrMore>
|
386
386
|
</define>
|
387
387
|
<define name="source">
|
388
388
|
<element name="source">
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "relaton-render"
|
2
|
+
require "metanorma-iso"
|
3
|
+
require "isodoc"
|
4
|
+
require_relative "parse"
|
5
|
+
|
6
|
+
module Relaton
|
7
|
+
module Render
|
8
|
+
module JIS
|
9
|
+
class General < ::Relaton::Render::Iso::General
|
10
|
+
#def config_loc
|
11
|
+
# YAML.load_file(File.join(File.dirname(__FILE__), "config.yml"))
|
12
|
+
#end
|
13
|
+
|
14
|
+
def klass_initialize(_options)
|
15
|
+
super
|
16
|
+
@parseklass = Relaton::Render::JIS::Parse
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "metanorma-iso"
|
2
|
+
|
3
|
+
module Relaton
|
4
|
+
module Render
|
5
|
+
module JIS
|
6
|
+
class Parse < ::Relaton::Render::Iso::Parse
|
7
|
+
def simple_or_host_xml2hash(doc, host)
|
8
|
+
ret = super
|
9
|
+
ret.merge(home_standard: home_standard(doc, ret[:publisher_raw] ||
|
10
|
+
ret[:author_raw]))
|
11
|
+
end
|
12
|
+
|
13
|
+
def home_standard(_doc, pubs)
|
14
|
+
pubs&.any? do |r|
|
15
|
+
["International Organization for Standardization", "ISO",
|
16
|
+
"International Electrotechnical Commission", "IEC",
|
17
|
+
"一般財団法人 日本規格協会", "Japanese Industrial Standards"]
|
18
|
+
.include?(r[:nonpersonal])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/metanorma-jis.gemspec
CHANGED
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.3.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: 2024-
|
11
|
+
date: 2024-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: japanese_calendar
|
@@ -234,6 +234,20 @@ dependencies:
|
|
234
234
|
- - ">="
|
235
235
|
- !ruby/object:Gem::Version
|
236
236
|
version: '0'
|
237
|
+
- !ruby/object:Gem::Dependency
|
238
|
+
name: xml-c14n
|
239
|
+
requirement: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - ">="
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: '0'
|
244
|
+
type: :development
|
245
|
+
prerelease: false
|
246
|
+
version_requirements: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - ">="
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: '0'
|
237
251
|
description: |
|
238
252
|
metanorma-jis lets you write JIS standards in AsciiDoc syntax.
|
239
253
|
|
@@ -300,6 +314,8 @@ files:
|
|
300
314
|
- lib/metanorma/jis/reqt.rng
|
301
315
|
- lib/metanorma/jis/validate.rb
|
302
316
|
- lib/metanorma/jis/version.rb
|
317
|
+
- lib/relaton/render-jis/general.rb
|
318
|
+
- lib/relaton/render-jis/parse.rb
|
303
319
|
- metanorma-jis.gemspec
|
304
320
|
homepage: https://github.com/metanorma/metanorma-jis
|
305
321
|
licenses:
|