metanorma-jis 0.0.1

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.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/.hound.yml +5 -0
  3. data/.rubocop.yml +10 -0
  4. data/CODE_OF_CONDUCT.md +74 -0
  5. data/Gemfile +12 -0
  6. data/LICENSE +25 -0
  7. data/README.adoc +81 -0
  8. data/lib/html2doc/lists.rb +166 -0
  9. data/lib/isodoc/jis/base_convert.rb +41 -0
  10. data/lib/isodoc/jis/html/header.html +934 -0
  11. data/lib/isodoc/jis/html/html_jis_intro.html +8 -0
  12. data/lib/isodoc/jis/html/html_jis_titlepage.html +79 -0
  13. data/lib/isodoc/jis/html/htmlstyle.css +47 -0
  14. data/lib/isodoc/jis/html/htmlstyle.scss +45 -0
  15. data/lib/isodoc/jis/html/isodoc.css +12080 -0
  16. data/lib/isodoc/jis/html/isodoc.scss +11551 -0
  17. data/lib/isodoc/jis/html/style-human.css +1107 -0
  18. data/lib/isodoc/jis/html/style-human.scss +783 -0
  19. data/lib/isodoc/jis/html/style-iso.css +1133 -0
  20. data/lib/isodoc/jis/html/style-iso.scss +800 -0
  21. data/lib/isodoc/jis/html/word_jis_intro.html +14 -0
  22. data/lib/isodoc/jis/html/word_jis_titlepage.html +128 -0
  23. data/lib/isodoc/jis/html/wordstyle.css +3477 -0
  24. data/lib/isodoc/jis/html/wordstyle.scss +3378 -0
  25. data/lib/isodoc/jis/html_convert.rb +37 -0
  26. data/lib/isodoc/jis/i18n-ja.yaml +214 -0
  27. data/lib/isodoc/jis/i18n.rb +15 -0
  28. data/lib/isodoc/jis/init.rb +34 -0
  29. data/lib/isodoc/jis/metadata.rb +52 -0
  30. data/lib/isodoc/jis/pdf_convert.rb +17 -0
  31. data/lib/isodoc/jis/presentation_xml_convert.rb +11 -0
  32. data/lib/isodoc/jis/word_convert.rb +153 -0
  33. data/lib/isodoc/jis/xref.rb +6 -0
  34. data/lib/metanorma/jis/basicdoc.rng +1125 -0
  35. data/lib/metanorma/jis/biblio-standoc.rng +164 -0
  36. data/lib/metanorma/jis/biblio.rng +1461 -0
  37. data/lib/metanorma/jis/converter.rb +71 -0
  38. data/lib/metanorma/jis/front.rb +51 -0
  39. data/lib/metanorma/jis/isodoc.rng +2450 -0
  40. data/lib/metanorma/jis/isostandard.rng +316 -0
  41. data/lib/metanorma/jis/jis.rng +63 -0
  42. data/lib/metanorma/jis/processor.rb +53 -0
  43. data/lib/metanorma/jis/relaton-jis.rng +231 -0
  44. data/lib/metanorma/jis/reqt.rng +226 -0
  45. data/lib/metanorma/jis/version.rb +6 -0
  46. data/lib/metanorma/jis.rb +6 -0
  47. data/lib/metanorma-jis.rb +16 -0
  48. data/metanorma-jis.gemspec +49 -0
  49. metadata +303 -0
@@ -0,0 +1,71 @@
1
+ require "asciidoctor"
2
+ require "metanorma-iso"
3
+ require_relative "./front"
4
+
5
+ module Metanorma
6
+ module JIS
7
+ class Converter < ISO::Converter
8
+ XML_ROOT_TAG = "jis-standard".freeze
9
+ XML_NAMESPACE = "https://www.metanorma.org/ns/jis".freeze
10
+
11
+ register_for "jis"
12
+
13
+ def init_i18n(node)
14
+ node.attr("language") or node.set_attr("language", "ja")
15
+ super
16
+ end
17
+
18
+ def boilerplate_file(_x_orig)
19
+ File.join(@libdir, "jis_intro_jp.xml")
20
+ end
21
+
22
+ def html_converter(node)
23
+ if node.nil?
24
+ IsoDoc::JIS::HtmlConvert.new({})
25
+ else
26
+ IsoDoc::JIS::HtmlConvert.new(html_extract_attributes(node))
27
+ end
28
+ end
29
+
30
+ def doc_converter(node)
31
+ if node.nil?
32
+ IsoDoc::JIS::WordConvert.new({})
33
+ else
34
+ IsoDoc::JIS::WordConvert.new(doc_extract_attributes(node))
35
+ end
36
+ end
37
+
38
+ def pdf_converter(node)
39
+ return if node.attr("no-pdf")
40
+ return
41
+
42
+ if node.nil?
43
+ IsoDoc::JIS::PdfConvert.new({})
44
+ else
45
+ IsoDoc::JIS::PdfConvert.new(pdf_extract_attributes(node))
46
+ end
47
+ end
48
+
49
+ def presentation_xml_converter(node)
50
+ if node.nil?
51
+ IsoDoc::JIS::PresentationXMLConvert.new({})
52
+ else
53
+ IsoDoc::JIS::PresentationXMLConvert.new(doc_extract_attributes(node))
54
+ end
55
+ 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
+ end
70
+ end
71
+ end
@@ -0,0 +1,51 @@
1
+ module Metanorma
2
+ module JIS
3
+ class Converter < ISO::Converter
4
+ def org_abbrev
5
+ super.merge("Japanese Industrial Standards" => "JIS")
6
+ end
7
+
8
+ def metadata_author(node, xml)
9
+ publishers = node.attr("publisher") || "JIS"
10
+ csv_split(publishers)&.each do |p|
11
+ xml.contributor do |c|
12
+ c.role type: "author"
13
+ c.organization do |a|
14
+ organization(a, p, false, node, !node.attr("publisher"))
15
+ end
16
+ end
17
+ end
18
+ node.attr("doctype") == "expert-commentary" and
19
+ personal_author(node, xml)
20
+ end
21
+
22
+ def metadata_publisher(node, xml)
23
+ publishers = node.attr("publisher") || "JIS"
24
+ csv_split(publishers)&.each do |p|
25
+ xml.contributor do |c|
26
+ c.role type: "publisher"
27
+ c.organization do |a|
28
+ organization(a, p, true, node, !node.attr("publisher"))
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ def metadata_copyright(node, xml)
35
+ pub = node.attr("copyright-holder") || node.attr("publisher") || "JIS"
36
+ csv_split(pub)&.each do |p|
37
+ xml.copyright do |c|
38
+ c.from (node.attr("copyright-year") || Date.today.year)
39
+ c.owner do |owner|
40
+ owner.organization do |o|
41
+ organization(o, p, true, node,
42
+ !node.attr("copyright-holder") ||
43
+ node.attr("publisher"))
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end