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.
@@ -1,3 +1,5 @@
1
+ require "pubid-jis"
2
+
1
3
  module Metanorma
2
4
  module JIS
3
5
  class Converter < ISO::Converter
@@ -59,28 +61,68 @@ module Metanorma
59
61
  end
60
62
 
61
63
  def metadata_id(node, xml)
64
+ node.attr("docidentifier") || node.attr("docnumber") or
65
+ @fatalerror << "No docnumber attribute supplied"
62
66
  if id = node.attr("docidentifier")
63
- xml.docidentifier id, **attr_code(type: "JIS")
67
+ xml.docidentifier id.sub(/^JIS /, ""), **attr_code(type: "JIS")
64
68
  else iso_id(node, xml)
65
69
  end
66
70
  xml.docnumber node.attr("docnumber")
67
71
  end
68
72
 
73
+ def get_typeabbr(node, amd: false)
74
+ amd || node.attr("amendment-number") and return :amd
75
+ case doctype(node)
76
+ when "technical-report" then :tr
77
+ when "technical-specification" then :ts
78
+ when "amendment" then :amd
79
+ end
80
+ end
81
+
69
82
  def iso_id(node, xml)
70
- id = case doctype(node)
71
- when "japanese-industrial-standard", "amendment" then "JIS"
72
- when "technical-report" then "TR"
73
- when "technical-specification" then "TS"
74
- else "JIS"
75
- end
76
- a = node.attr("docseries") and id += " #{a}"
77
- a = node.attr("docnumber") and id += " #{a}"
78
- yr = iso_id_year(node)
79
- origyr = node.attr("created-date") || yr
80
- a = node.attr("amendment-number") and
81
- id += ":#{origyr}/AMD #{a}"
82
- id += ":#{yr}"
83
- xml.docidentifier id, type: "JIS"
83
+ (!@amd && node.attr("docnumber")) || (@amd && node.attr("updates")) or
84
+ return
85
+ params = iso_id_params(node)
86
+ iso_id_out(xml, params, true)
87
+ end
88
+
89
+ def iso_id_params(node)
90
+ params = iso_id_params_core(node)
91
+ params2 = iso_id_params_add(node)
92
+ if node.attr("updates")
93
+ orig_id = Pubid::Jis::Identifier::Base.parse(node.attr("updates"))
94
+ orig_id.edition ||= 1
95
+ end
96
+ iso_id_params_resolve(params, params2, node, orig_id)
97
+ end
98
+
99
+ def iso_id_params_core(node)
100
+ pub = (node.attr("publisher") || "JIS").split(/[;,]/)
101
+ ret = { number: node.attr("docnumber") || "0",
102
+ part: node.attr("partnumber"),
103
+ series: node.attr("docseries"),
104
+ language: node.attr("language") == "en" ? "E" : nil,
105
+ type: get_typeabbr(node),
106
+ publisher: pub[0],
107
+ copublisher: pub[1..-1] }.compact
108
+ ret[:copublisher].empty? and ret.delete(:copublisher)
109
+ ret
110
+ end
111
+
112
+ def iso_id_params_add(node)
113
+ { number: node.attr("amendment-number"),
114
+ year: iso_id_year(node) }.compact
115
+ end
116
+
117
+ def iso_id_out(xml, params, _with_prf)
118
+ id = iso_id_default(params).to_s(with_publisher: false)
119
+ xml.docidentifier id.strip, type: "JIS"
120
+ end
121
+
122
+ def iso_id_default(params)
123
+ Pubid::Jis::Identifier.create(**params)
124
+ rescue StandardError => e
125
+ clean_abort("Document identifier: #{e}", xml)
84
126
  end
85
127
  end
86
128
  end
@@ -17,6 +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.1 -->
20
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">
21
22
  <include href="reqt.rng"/>
22
23
  <include href="basicdoc.rng">
@@ -382,6 +383,9 @@
382
383
  <optional>
383
384
  <ref name="dl"/>
384
385
  </optional>
386
+ <optional>
387
+ <ref name="source"/>
388
+ </optional>
385
389
  </element>
386
390
  </define>
387
391
  <define name="figure">
@@ -404,9 +408,6 @@
404
408
  <attribute name="class"/>
405
409
  </optional>
406
410
  <ref name="BlockAttributes"/>
407
- <optional>
408
- <ref name="source"/>
409
- </optional>
410
411
  <optional>
411
412
  <ref name="tname"/>
412
413
  </optional>
@@ -431,6 +432,20 @@
431
432
  <zeroOrMore>
432
433
  <ref name="note"/>
433
434
  </zeroOrMore>
435
+ <optional>
436
+ <ref name="source"/>
437
+ </optional>
438
+ </element>
439
+ </define>
440
+ <define name="source">
441
+ <element name="source">
442
+ <attribute name="status">
443
+ <ref name="SourceStatusType"/>
444
+ </attribute>
445
+ <ref name="origin"/>
446
+ <optional>
447
+ <ref name="modification"/>
448
+ </optional>
434
449
  </element>
435
450
  </define>
436
451
  <define name="sourcecode">
@@ -1335,15 +1350,19 @@
1335
1350
  </choice>
1336
1351
  </element>
1337
1352
  </define>
1353
+ <define name="Root-Attributes">
1354
+ <attribute name="version"/>
1355
+ <attribute name="schema-version"/>
1356
+ <attribute name="type">
1357
+ <choice>
1358
+ <value>semantic</value>
1359
+ <value>presentation</value>
1360
+ </choice>
1361
+ </attribute>
1362
+ </define>
1338
1363
  <define name="standard-document">
1339
1364
  <element name="standard-document">
1340
- <attribute name="version"/>
1341
- <attribute name="type">
1342
- <choice>
1343
- <value>semantic</value>
1344
- <value>presentation</value>
1345
- </choice>
1346
- </attribute>
1365
+ <ref name="Root-Attributes"/>
1347
1366
  <ref name="bibdata"/>
1348
1367
  <optional>
1349
1368
  <ref name="misccontainer"/>
@@ -2099,10 +2118,7 @@
2099
2118
  <define name="termsource">
2100
2119
  <element name="termsource">
2101
2120
  <attribute name="status">
2102
- <choice>
2103
- <value>identical</value>
2104
- <value>modified</value>
2105
- </choice>
2121
+ <ref name="SourceStatusType"/>
2106
2122
  </attribute>
2107
2123
  <attribute name="type">
2108
2124
  <choice>
@@ -2116,6 +2132,17 @@
2116
2132
  </optional>
2117
2133
  </element>
2118
2134
  </define>
2135
+ <define name="SourceStatusType">
2136
+ <choice>
2137
+ <value>identical</value>
2138
+ <value>modified</value>
2139
+ <value>restyled</value>
2140
+ <value>context-added</value>
2141
+ <value>generalisation</value>
2142
+ <value>specialisation</value>
2143
+ <value>unspecified</value>
2144
+ </choice>
2145
+ </define>
2119
2146
  <define name="origin">
2120
2147
  <element name="origin">
2121
2148
  <choice>
@@ -1,6 +1,9 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
- <!-- default namespace isostandard = "https://www.metanorma.com/ns/iso" -->
3
+ <!--
4
+ VERSION v1.2.1
5
+ default namespace isostandard = "https://www.metanorma.com/ns/iso"
6
+ -->
4
7
  <include href="isodoc.rng">
5
8
  <start>
6
9
  <ref name="iso-standard"/>
@@ -240,13 +243,7 @@
240
243
  -->
241
244
  <define name="iso-standard">
242
245
  <element name="iso-standard">
243
- <attribute name="version"/>
244
- <attribute name="type">
245
- <choice>
246
- <value>semantic</value>
247
- <value>presentation</value>
248
- </choice>
249
- </attribute>
246
+ <ref name="Root-Attributes"/>
250
247
  <ref name="bibdata"/>
251
248
  <zeroOrMore>
252
249
  <ref name="termdocsource"/>
@@ -1,11 +1,24 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <grammar ns="https://www.metanorma.org/ns/jis" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
- <!-- default namespace = "https://www.metanorma.com/ns/jis" -->
2
+ <grammar ns='https://www.metanorma.org/ns/jis' xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
+ <!--
4
+ VERSION v1.2.1
5
+ default namespace = "https://www.metanorma.com/ns/jis"
6
+ -->
4
7
  <include href="relaton-jis.rng"/>
5
8
  <include href="isostandard.rng">
6
9
  <start>
7
10
  <ref name="jis-standard"/>
8
11
  </start>
12
+ <define name="annex">
13
+ <element name="annex">
14
+ <optional>
15
+ <attribute name="commentary">
16
+ <data type="boolean"/>
17
+ </attribute>
18
+ </optional>
19
+ <ref name="Annex-Section"/>
20
+ </element>
21
+ </define>
9
22
  </include>
10
23
  <!-- end overrides -->
11
24
  <define name="floating-section-title">
@@ -27,13 +40,7 @@
27
40
  -->
28
41
  <define name="jis-standard">
29
42
  <element name="jis-standard">
30
- <attribute name="version"/>
31
- <attribute name="type">
32
- <choice>
33
- <value>semantic</value>
34
- <value>presentation</value>
35
- </choice>
36
- </attribute>
43
+ <ref name="Root-Attributes"/>
37
44
  <ref name="bibdata"/>
38
45
  <zeroOrMore>
39
46
  <ref name="termdocsource"/>
@@ -21,8 +21,8 @@ module Metanorma
21
21
  def fonts_manifest
22
22
  {
23
23
  "STIX Two Math" => nil,
24
- "MS Gothic" => nil,
25
- "MS Mincho" => nil,
24
+ "IPAexGothic" => nil,
25
+ "IPAexMincho" => nil,
26
26
  "Courier New" => nil,
27
27
  "Cambria Math" => nil,
28
28
  "Times New Roman" => nil,
@@ -1,6 +1,6 @@
1
1
  module Metanorma
2
2
  module JIS
3
- VERSION = "0.0.3".freeze
3
+ VERSION = "0.0.5".freeze
4
4
  end
5
5
  end
6
6
 
@@ -30,8 +30,8 @@ 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.4.0"
34
- spec.add_dependency "ruby-jing"
33
+ spec.add_dependency "metanorma-iso", "~> 2.4.2"
34
+ spec.add_dependency "pubid-jis"
35
35
 
36
36
  spec.add_development_dependency "debug"
37
37
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
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.0.3
4
+ version: 0.0.5
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-03-27 00:00:00.000000000 Z
11
+ date: 2023-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-iso
@@ -16,16 +16,16 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.4.0
19
+ version: 2.4.2
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.4.0
26
+ version: 2.4.2
27
27
  - !ruby/object:Gem::Dependency
28
- name: ruby-jing
28
+ name: pubid-jis
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -238,6 +238,7 @@ files:
238
238
  - README.adoc
239
239
  - lib/html2doc/lists.rb
240
240
  - lib/isodoc/jis/base_convert.rb
241
+ - lib/isodoc/jis/figure.rb
241
242
  - lib/isodoc/jis/html/header.html
242
243
  - lib/isodoc/jis/html/html_jis_intro.html
243
244
  - lib/isodoc/jis/html/html_jis_titlepage.html
@@ -262,6 +263,7 @@ files:
262
263
  - lib/isodoc/jis/metadata.rb
263
264
  - lib/isodoc/jis/pdf_convert.rb
264
265
  - lib/isodoc/jis/presentation_xml_convert.rb
266
+ - lib/isodoc/jis/table.rb
265
267
  - lib/isodoc/jis/word_cleanup.rb
266
268
  - lib/isodoc/jis/word_convert.rb
267
269
  - lib/isodoc/jis/xref.rb