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.
@@ -0,0 +1,42 @@
1
+ module Metanorma
2
+ module JIS
3
+ class Converter < ISO::Converter
4
+ def norm_ref_preface(ref)
5
+ if ref.at("./note[@type = 'boilerplate']")
6
+ unwrap_boilerplate_clauses(ref, ".")
7
+ else
8
+ pref = if ref_empty?(ref) then @i18n.norm_empty_pref
9
+ else @i18n.get[ref_dated(ref)]
10
+ end
11
+ ref.at("./title").next = "<p>#{pref}</p>"
12
+ end
13
+ end
14
+
15
+ def ref_empty?(ref)
16
+ ref.xpath(".//bibitem").empty?
17
+ end
18
+
19
+ def ref_dated(ref)
20
+ refs = ref.xpath("./bibitem").each_with_object({}) do |e, m|
21
+ if e.at("./date") then m[:dated] = true
22
+ else m[:undated] = true
23
+ end
24
+ end
25
+ refs[:dated] && refs[:undated] and return "norm_with_refs_pref"
26
+ refs[:dated] and return "norm_with_refs_pref_all_dated"
27
+ "norm_with_refs_pref_none_dated"
28
+ end
29
+
30
+ def table_footnote_renumber(xmldoc)
31
+ xmldoc.xpath("//table | //figure").each do |t|
32
+ seen = {}
33
+ i = 0
34
+ #t.xpath(".//fn[not(ancestor::name)]").each do |fn|
35
+ t.xpath(".//fn").each do |fn|
36
+ i, seen = table_footnote_renumber1(fn, i, seen)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,6 +1,8 @@
1
1
  require "asciidoctor"
2
2
  require "metanorma-iso"
3
3
  require_relative "./front"
4
+ require_relative "./validate"
5
+ require_relative "./cleanup"
4
6
 
5
7
  module Metanorma
6
8
  module JIS
@@ -12,9 +14,17 @@ module Metanorma
12
14
 
13
15
  def init_i18n(node)
14
16
  node.attr("language") or node.set_attr("language", "ja")
17
+ node.attr("language") == "jp" and node.set_attr("language", "ja")
15
18
  super
16
19
  end
17
20
 
21
+ def doctype(node)
22
+ ret = node.attr("doctype")&.gsub(/\s+/, "-")&.downcase ||
23
+ "japanese-industrial-standard"
24
+ ret = "japanese-industrial-standard" if ret == "article"
25
+ ret
26
+ end
27
+
18
28
  def boilerplate_file(_x_orig)
19
29
  File.join(@libdir, "jis_intro_jp.xml")
20
30
  end
@@ -37,7 +47,6 @@ module Metanorma
37
47
 
38
48
  def pdf_converter(node)
39
49
  return if node.attr("no-pdf")
40
- return
41
50
 
42
51
  if node.nil?
43
52
  IsoDoc::JIS::PdfConvert.new({})
@@ -53,19 +62,6 @@ module Metanorma
53
62
  IsoDoc::JIS::PresentationXMLConvert.new(doc_extract_attributes(node))
54
63
  end
55
64
  end
56
-
57
- def script_validate(xmldoc)
58
- script = xmldoc&.at("//bibdata/script")&.text
59
- %w(Jpan Latn).include?(script) or
60
- @log.add("Document Attributes", nil,
61
- "#{script} is not a recognised script")
62
- end
63
-
64
- def validate(doc)
65
- content_validate(doc)
66
- schema_validate(formattedstr_strip(doc.dup),
67
- File.join(File.dirname(__FILE__), "jis.rng"))
68
- end
69
65
  end
70
66
  end
71
67
  end
@@ -46,6 +46,42 @@ module Metanorma
46
46
  end
47
47
  end
48
48
  end
49
+
50
+ def title(node, xml)
51
+ %w(en ja).each do |lang|
52
+ at = { language: lang, format: "text/plain" }
53
+ title_full(node, xml, lang, at)
54
+ title_intro(node, xml, lang, at)
55
+ title_main(node, xml, lang, at)
56
+ title_part(node, xml, lang, at)
57
+ title_amd(node, xml, lang, at) if @amd
58
+ end
59
+ end
60
+
61
+ def metadata_id(node, xml)
62
+ if id = node.attr("docidentifier")
63
+ xml.docidentifier id, **attr_code(type: "JIS")
64
+ else iso_id(node, xml)
65
+ end
66
+ xml.docnumber node.attr("docnumber")
67
+ end
68
+
69
+ 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"
84
+ end
49
85
  end
50
86
  end
51
87
  end
@@ -13,7 +13,7 @@ module Metanorma
13
13
  def output_formats
14
14
  super.merge(
15
15
  html: "html",
16
- # pdf: "pdf",
16
+ pdf: "pdf",
17
17
  doc: "doc",
18
18
  )
19
19
  end
@@ -6,9 +6,6 @@
6
6
  <attribute name="schema-version"/>
7
7
  </optional>
8
8
  <ref name="doctype"/>
9
- <optional>
10
- <ref name="docsubtype"/>
11
- </optional>
12
9
  <ref name="editorialgroup"/>
13
10
  <zeroOrMore>
14
11
  <ref name="ics"/>
@@ -18,93 +15,12 @@
18
15
  <ref name="stagename"/>
19
16
  </optional>
20
17
  </define>
21
- <define name="bdate">
22
- <element name="date">
23
- <attribute name="type">
24
- <choice>
25
- <ref name="BibliographicDateType"/>
26
- <text/>
27
- </choice>
28
- </attribute>
29
- <choice>
30
- <group>
31
- <element name="from">
32
- <ref name="ISO8601Date"/>
33
- </element>
34
- <optional>
35
- <element name="to">
36
- <ref name="ISO8601Date"/>
37
- </element>
38
- </optional>
39
- </group>
40
- <element name="on">
41
- <choice>
42
- <ref name="ISO8601Date"/>
43
- <value>--</value>
44
- <value>–</value>
45
- </choice>
46
- </element>
47
- </choice>
48
- </element>
49
- </define>
50
- <define name="organization">
51
- <element name="organization">
52
- <oneOrMore>
53
- <ref name="orgname"/>
54
- </oneOrMore>
55
- <optional>
56
- <ref name="abbreviation"/>
57
- </optional>
58
- <optional>
59
- <ref name="uri"/>
60
- </optional>
61
- <zeroOrMore>
62
- <ref name="org-identifier"/>
63
- </zeroOrMore>
64
- <zeroOrMore>
65
- <ref name="contact"/>
66
- </zeroOrMore>
67
- <optional>
68
- <ref name="technical-committee"/>
69
- </optional>
70
- <optional>
71
- <ref name="subcommittee"/>
72
- </optional>
73
- <optional>
74
- <ref name="workgroup"/>
75
- </optional>
76
- <optional>
77
- <ref name="secretariat"/>
78
- </optional>
79
- </element>
80
- </define>
81
18
  <define name="DocumentType">
82
19
  <choice>
83
- <value>british-standard</value>
84
- <value>draft-for-development</value>
85
- <value>published-document</value>
86
- <value>privately-subscribed-standard</value>
87
- <value>publicly-available-specification</value>
88
- <value>flex-standard</value>
89
- <value>international-standard</value>
90
- <value>technical-specification</value>
20
+ <value>japanese-industrial-standard</value>
91
21
  <value>technical-report</value>
92
- <value>guide</value>
93
- <value>international-workshop-agreement</value>
94
- <value>industry-technical-agreement</value>
95
- <value>standard</value>
96
- <value>european-workshop-agreement</value>
97
- <value>fast-track-standard</value>
98
- <value>expert-commentary</value>
99
- </choice>
100
- </define>
101
- <define name="DocumentSubtype">
102
- <choice>
103
- <value>specification</value>
104
- <value>method-of-test</value>
105
- <value>method-of-specifying</value>
106
- <value>vocabulary</value>
107
- <value>code-of-practice</value>
22
+ <value>technical-specification</value>
23
+ <value>amendment</value>
108
24
  </choice>
109
25
  </define>
110
26
  <define name="structuredidentifier">
@@ -126,11 +42,6 @@
126
42
  </element>
127
43
  </define>
128
44
  </include>
129
- <define name="updates_document_type">
130
- <element name="updates-document-type">
131
- <ref name="DocumentType"/>
132
- </element>
133
- </define>
134
45
  <define name="ISOProjectGroup">
135
46
  <zeroOrMore>
136
47
  <ref name="agency"/>
@@ -148,21 +59,11 @@
148
59
  <ref name="secretariat"/>
149
60
  </optional>
150
61
  </define>
151
- <define name="approvalgroup">
152
- <element name="approvalgroup">
153
- <ref name="ISOProjectGroup"/>
154
- </element>
155
- </define>
156
62
  <define name="agency">
157
63
  <element name="agency">
158
64
  <text/>
159
65
  </element>
160
66
  </define>
161
- <define name="horizontal">
162
- <element name="horizontal">
163
- <data type="boolean"/>
164
- </element>
165
- </define>
166
67
  <define name="documentnumber">
167
68
  <element name="project-number">
168
69
  <optional>
@@ -221,11 +122,4 @@
221
122
  <text/>
222
123
  </element>
223
124
  </define>
224
- <define name="coverimages">
225
- <element name="coverimages">
226
- <oneOrMore>
227
- <ref name="image"/>
228
- </oneOrMore>
229
- </element>
230
- </define>
231
125
  </grammar>
@@ -0,0 +1,26 @@
1
+ module Metanorma
2
+ module JIS
3
+ class Converter < ISO::Converter
4
+ def doctype_validate(xmldoc)
5
+ doctype = xmldoc&.at("//bibdata/ext/doctype")&.text
6
+ %w(japanese-industrial-standard technical-report
7
+ technical-specification amendment).include? doctype or
8
+ @log.add("Document Attributes", nil,
9
+ "#{doctype} is not a recognised document type")
10
+ end
11
+
12
+ def script_validate(xmldoc)
13
+ script = xmldoc&.at("//bibdata/script")&.text
14
+ %w(Jpan Latn).include?(script) or
15
+ @log.add("Document Attributes", nil,
16
+ "#{script} is not a recognised script")
17
+ end
18
+
19
+ def validate(doc)
20
+ content_validate(doc)
21
+ schema_validate(formattedstr_strip(doc.dup),
22
+ File.join(File.dirname(__FILE__), "jis.rng"))
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,6 +1,6 @@
1
1
  module Metanorma
2
2
  module JIS
3
- VERSION = "0.0.1".freeze
3
+ VERSION = "0.0.3".freeze
4
4
  end
5
5
  end
6
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.1
4
+ version: 0.0.3
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-16 00:00:00.000000000 Z
11
+ date: 2023-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-iso
@@ -254,12 +254,15 @@ files:
254
254
  - lib/isodoc/jis/html/wordstyle.css
255
255
  - lib/isodoc/jis/html/wordstyle.scss
256
256
  - lib/isodoc/jis/html_convert.rb
257
+ - lib/isodoc/jis/i18n-en.yaml
257
258
  - lib/isodoc/jis/i18n-ja.yaml
258
259
  - lib/isodoc/jis/i18n.rb
259
260
  - lib/isodoc/jis/init.rb
261
+ - lib/isodoc/jis/jis.international-standard.xsl
260
262
  - lib/isodoc/jis/metadata.rb
261
263
  - lib/isodoc/jis/pdf_convert.rb
262
264
  - lib/isodoc/jis/presentation_xml_convert.rb
265
+ - lib/isodoc/jis/word_cleanup.rb
263
266
  - lib/isodoc/jis/word_convert.rb
264
267
  - lib/isodoc/jis/xref.rb
265
268
  - lib/metanorma-jis.rb
@@ -267,6 +270,7 @@ files:
267
270
  - lib/metanorma/jis/basicdoc.rng
268
271
  - lib/metanorma/jis/biblio-standoc.rng
269
272
  - lib/metanorma/jis/biblio.rng
273
+ - lib/metanorma/jis/cleanup.rb
270
274
  - lib/metanorma/jis/converter.rb
271
275
  - lib/metanorma/jis/front.rb
272
276
  - lib/metanorma/jis/isodoc.rng
@@ -275,6 +279,7 @@ files:
275
279
  - lib/metanorma/jis/processor.rb
276
280
  - lib/metanorma/jis/relaton-jis.rng
277
281
  - lib/metanorma/jis/reqt.rng
282
+ - lib/metanorma/jis/validate.rb
278
283
  - lib/metanorma/jis/version.rb
279
284
  - metanorma-jis.gemspec
280
285
  homepage: https://github.com/metanorma/metanorma-jis