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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 389469990940f3daa6877a9bfd6f3903ef3705e4a3bc0446de19e2d2c1a52930
4
+ data.tar.gz: b0cbac18b0e1cf0223d52ebe4cce6d2c7956a7a79a70e974369cf8d556c8bf9a
5
+ SHA512:
6
+ metadata.gz: c14b13c90635a211a98d25a65850166c7d515aa49857ba99394664a571cee113f3c91db7e32c5ad523a51676b6a83536aec9fe8ccd0908c277bc1f748768e906
7
+ data.tar.gz: 5b6e900e60f71d0f4f4fb363269ef974fbdfa99690bc1a4292b8d05c20f195b7afe8878433368adbc95c5177a7b6f929f3d29cfb42c9da0a49f0bd690e5d189f
data/.hound.yml ADDED
@@ -0,0 +1,5 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ ruby:
4
+ enabled: true
5
+ config_file: .rubocop.yml
data/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ inherit_from:
4
+ - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
5
+
6
+ # local repo-specific modifications
7
+ # ...
8
+
9
+ AllCops:
10
+ TargetRubyVersion: 2.5
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at ronald.tse@ribose.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ Encoding.default_external = Encoding::UTF_8
2
+ Encoding.default_internal = Encoding::UTF_8
3
+
4
+ source "https://rubygems.org"
5
+
6
+ # Specify your gem's dependencies in gemspec
7
+ gemspec
8
+
9
+ if File.exist? "Gemfile.devel"
10
+ eval File.read("Gemfile.devel"), nil, "Gemfile.devel" # rubocop:disable Security/Eval
11
+ end
12
+
data/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ BSD 2-Clause License
2
+
3
+ Copyright (c) 2018, Ribose
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.adoc ADDED
@@ -0,0 +1,81 @@
1
+ = metanorma-JIS: Metanorma processor for Japanese Industrial Standards
2
+
3
+ image:https://img.shields.io/gem/v/metanorma-jis.svg["Gem Version", link="https://rubygems.org/gems/metanorma-jis"]
4
+ image:https://github.com/metanorma/metanorma-jis/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/metanorma-jis/actions?workflow=rake"]
5
+ image:https://codeclimate.com/github/metanorma/metanorma-jis/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/metanorma-jis"]
6
+ image:https://img.shields.io/github/issues-pr-raw/metanorma/metanorma-jis.svg["Pull Requests", link="https://github.com/metanorma/metanorma-jis/pulls"]
7
+ image:https://img.shields.io/github/commits-since/metanorma/metanorma-jis/latest.svg["Commits since latest",link="https://github.com/metanorma/metanorma-jis/releases"]
8
+
9
+ == Functionality
10
+
11
+ This gem processes https://www.metanorma.com[Metanorma documents] following
12
+ the Metanorma model for generating JIS standards.
13
+
14
+ The gem is basically the https://github.com/metanorma/metanorma-iso gem, with some tweaking of rendering to meet the particular requirements of the JIS.
15
+
16
+ It provides the following functions:
17
+
18
+ . Compiles Metanorma input into the Metanorma-JIS XML format (which is identical to Metanorma-ISO, since the two standards share the same document model)
19
+ . Validates XML output against the Metanorma-JIS document model
20
+ ** Errors are reported to console against the XML, and are intended for users to
21
+ check that they have provided all necessary components of the
22
+ document.
23
+ . Metanorma-JIS XML is then converted into desired output formats.
24
+
25
+ The following outputs are supported:
26
+
27
+ * Primary: the canonical Metanorma-JIS XML representation (`.xml`).
28
+ * Secondary: the Metanorma-JIS XML representation is processed to generate the following outputs
29
+ as end deliverable JIS documents.
30
+ ** HTML (`.html`)
31
+ ** Word (`.doc`)
32
+ ** PDF (`.pdf`)
33
+
34
+ == Structure
35
+
36
+ This gem inherits from the https://github.com/metanorma/metanorma-iso
37
+ gem, and aligns closely to it.
38
+
39
+
40
+ === Quickstart
41
+
42
+ Please see https://www.metanorma.com for instructions to get started.
43
+
44
+ You will need to setup your Git credentials for bundler or for HTTPS in order
45
+ to fetch the software. Please refer to the following articles for details:
46
+
47
+ * https://depfu.com/blog/2017/08/02/bundler-and-private-dependencies[Setting up bundler for private dependencies]
48
+ * https://bundler.io/v1.16/bundle_config.html#CREDENTIALS-FOR-GEM-SOURCES[Bundler credentials for gem sources]
49
+ * https://help.github.com/articles/caching-your-github-password-in-git[GitHub - Caching your GitHub credentials in Git]
50
+
51
+
52
+ == Usage
53
+
54
+ Using the `metanorma` CLI:
55
+
56
+ [source,console]
57
+ ----
58
+ $ metanorma --type jis a.adoc # output HTML
59
+ $ metanorma --type jis --extensions html a.adoc # output just HTML
60
+ $ metanorma --type jis --extensions xml a.adoc # output Metanorma XML
61
+ ----
62
+
63
+
64
+ == Authoring
65
+
66
+ Please refer to the Metanorma-ISO documentation for general documentation.
67
+
68
+ * Metanorma-ISO general documentation: https://www.metanorma.com/software/metanorma-iso/
69
+
70
+ * Metanorma-ISO guidance: https://www.metanorma.com/software/metanorma-iso/docs/guidance/
71
+
72
+
73
+ == Documentation
74
+
75
+ See https://www.metanorma.com/author/iso/[Write ISO documents with Metanorma]
76
+
77
+ == Examples
78
+
79
+ * Example documents are avalable at the https://github.com/metanorma/mn-samples-jis[mn-samples-jis] repository.
80
+ * Document templates are available at the https://github.com/metanorma/mn-templates-jis[mn-templates-jis] repository.
81
+
@@ -0,0 +1,166 @@
1
+ class Html2Doc
2
+ class JIS < ::Html2Doc
3
+ def list2para(list)
4
+ return if list.xpath("./li").empty?
5
+
6
+ list.xpath("./li").each do |l|
7
+ list2para_level(l, list)
8
+ end
9
+ end
10
+
11
+ def style_list(elem, level, liststyle, listnumber)
12
+ return unless liststyle
13
+ elem["level"] = level
14
+ super
15
+ end
16
+
17
+ def list2para_level(item, list)
18
+ level = item["level"]
19
+ item.delete("level")
20
+ item.name = "p"
21
+ list2para_nest(item, level, list) if level
22
+ end
23
+
24
+ def list2para_nest(item, level, list)
25
+ item["class"] = list2para_style(list.name, level)
26
+ item.xpath("./p").each do |p|
27
+ p["class"] = list2para_style(list.name, level)
28
+ p["style"] = item["style"]
29
+ p["id"] = item["id"]
30
+ end
31
+ item.at("./p") or return
32
+ item.replace(item.children)
33
+ =begin
34
+ prev = p1.xpath("./preceding-sibling::* | ./preceding-sibling::text()")
35
+ if prev[-1].name == "span" && prev[-1]["style"] == "mso-tab-count:1" &&
36
+ prev.size == 2
37
+ p1.children.first.previous = prev[1]
38
+ p1.children.first.previous = prev[0]
39
+ end
40
+ =end
41
+ end
42
+
43
+ def list2para_unnest_para(para, first_p, last_p)
44
+ return if last_p.xpath("./following-sibling::* | ./following-sibling::text()")
45
+ .any? do |x|
46
+ !x.text.strip.empty?
47
+ end
48
+
49
+ prev = first_p.xpath("./preceding-sibling::* | " \
50
+ "./preceding-sibling::text()[normalize-space()]")
51
+ # bullet, tab, paragraph: ignore bullet, tab
52
+ if prev.empty? then para.replace(para.children)
53
+ elsif prev.size == 2 && prev[-1].name == "span" &&
54
+ prev[-1]["style"] == "mso-tab-count:1"
55
+ first_p.replace(first_p.children)
56
+ end
57
+ end
58
+
59
+ def list2para_style(listtype, depth)
60
+ case listtype
61
+ when "ul", "ol"
62
+ case depth
63
+ when "1" then "MsoList"
64
+ when "2", "3", "4", "5" then "MsoList#{depth}"
65
+ else "MsoList6"
66
+ end
67
+ end
68
+ end
69
+
70
+ def lists(docxml, liststyles)
71
+ super
72
+ docxml.xpath("//p[ol | ul]").each do |p|
73
+ list2para_unnest_para(p, p.at("./ol | ./ul"),
74
+ p.at("./*[name() = 'ul' or name() = 'ol'][last()]"))
75
+ end
76
+ docxml.xpath("//ol | //ul").each do |u|
77
+ u.replace(u.children)
78
+ end
79
+ unnest_list_paras(docxml)
80
+ indent_lists(docxml)
81
+ end
82
+
83
+ def unnest_list_paras(docxml)
84
+ docxml.xpath("//p[@class = 'ListContinue1' or @class = 'ListNumber1']" \
85
+ "[.//p]").each do |p|
86
+ p.at("./p") and
87
+ list2para_unnest_para(p, p.at("./p"),
88
+ p.at("./p[last()]"))
89
+ p.xpath(".//p[p]").each do |p1|
90
+ list2para_unnest_para(p1, p1.at("./p"),
91
+ p1.at("./p[last()]"))
92
+ end
93
+ end
94
+ end
95
+
96
+ def indent_lists(docxml)
97
+ docxml.xpath("//div[@class = 'Note' or @class = 'Example' or " \
98
+ "@class = 'Quote']").each do |d|
99
+ d.xpath(".//p").each do |p|
100
+ indent_lists1(p)
101
+ end
102
+ end
103
+ end
104
+
105
+ def indent_lists1(para)
106
+ m = /^(ListContinue|ListNumber|MsoListContinue|MsoListNumber)(\d)$/
107
+ .match(para["class"]) or return
108
+ base = m[1].sub(/^Mso/, "")
109
+ level = m[2].to_i + 1
110
+ level = 5 if level > 5
111
+ para["class"] = "#{base}#{level}-"
112
+ end
113
+
114
+ def list_add(xpath, liststyles, listtype, level)
115
+ xpath.each do |l|
116
+ level == 1 and l["seen"] = true and @listnumber += 1
117
+ l["seen"] = true if level == 1
118
+ l["id"] ||= UUIDTools::UUID.random_create
119
+ list_add_number(l, liststyles, listtype, level)
120
+ list_add_tail(l, liststyles, listtype, level)
121
+ end
122
+ end
123
+
124
+ def list_add_number(list, liststyles, listtype, level)
125
+ i = list["start"] and @listnumber = list["start"].to_i - 1
126
+ (list.xpath(".//li") - list.xpath(".//ol//li | .//ul//li")).each do |li|
127
+ style_list(li, level, liststyles[listtype], @listnumber)
128
+ list_add1(li, liststyles, listtype, level)
129
+ end
130
+ end
131
+
132
+ def list_add_tail(list, liststyles, listtype, level)
133
+ list.xpath(".//ul[not(ancestor::li/ancestor::*/@id = '#{list['id']}')] | " \
134
+ ".//ol[not(ancestor::li/ancestor::*/@id = '#{list['id']}')]")
135
+ .each do |li|
136
+ list_add1(li.parent, liststyles, listtype, level - 1)
137
+ end
138
+ end
139
+
140
+ def listlabel(listtype, idx, level)
141
+ case listtype
142
+ when :ul then "&#x2014;"
143
+ when :ol then "#{listidx(idx, level)})"
144
+ end
145
+ end
146
+
147
+ def listidx(idx, level)
148
+ case level
149
+ when "a" then (96 + idx).chr.to_s
150
+ when "1" then idx.to_s
151
+ when "i" then RomanNumerals.to_roman(idx).downcase
152
+ when "A" then (64 + idx).chr.to_s
153
+ when "I" then RomanNumerals.to_roman(idx).upcase
154
+ end
155
+ end
156
+
157
+ def cleanup(docxml)
158
+ super
159
+ docxml.xpath("//div[@class = 'Quote' or @class = 'Example' or " \
160
+ "@class = 'Note']").each do |d|
161
+ d.delete("class")
162
+ end
163
+ docxml
164
+ end
165
+ end
166
+ end
@@ -0,0 +1,41 @@
1
+ require "isodoc"
2
+ require "metanorma-iso"
3
+
4
+ module IsoDoc
5
+ module JIS
6
+ module BaseConvert
7
+ def middle_title(_isoxml, out)
8
+ middle_title_main(out)
9
+ middle_subtitle_main(out)
10
+ # middle_title_amd(out)
11
+ end
12
+
13
+ def middle_title_main(out)
14
+ out.p(class: "zzSTDTitle1") do |p|
15
+ p << @meta.get[:doctitleintro]
16
+ p << " &#x2014; " if @meta.get[:doctitleintro] && @meta.get[:doctitlemain]
17
+ p << @meta.get[:doctitlemain]
18
+ p << " &#x2014; " if @meta.get[:doctitlemain] && @meta.get[:doctitlepart]
19
+ end
20
+ a = @meta.get[:doctitlepart] and out.p(class: "zzSTDTitle1") do |p|
21
+ b = @meta.get[:doctitlepartlabel] and p << "#{b}: "
22
+ p << "<br/><b>#{a}</b>"
23
+ end
24
+ end
25
+
26
+ def middle_subtitle_main(out)
27
+ @meta.get[:docsubtitlemain] or return
28
+ out.p(class: "zzSTDTitle2") do |p|
29
+ p << @meta.get[:docsubtitleintro]
30
+ p << " &#x2014; " if @meta.get[:docsubtitleintro] && @meta.get[:docsubtitlemain]
31
+ p << @meta.get[:doctitlemain]
32
+ p << " &#x2014; " if @meta.get[:docsubtitlemain] && @meta.get[:docsubtitlepart]
33
+ end
34
+ a = @meta.get[:docsubtitlepart] and out.p(class: "zzSTDTitle2") do |p|
35
+ b = @meta.get[:docsubtitlepartlabel] and p << "#{b}: "
36
+ p << "<br/><b>#{a}</b>"
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end