asciidoctor-iso 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ff009fa5a7024c54efd53fc7e8a353559d1ab6a
4
- data.tar.gz: 7bd27462cb448bfb0ce0947ebf60a622b9215a95
3
+ metadata.gz: 7ff84c9af977a9b2adf3922bca65699f511b6d8c
4
+ data.tar.gz: b947358c67928d815d674c49b6aeed1d813b20f0
5
5
  SHA512:
6
- metadata.gz: 4f221438783ca673de960d8143f1aa196c8a5748d839cdb048f6ec3d6dd4fe8d0d927f137c8a03e9ac1e7dba47a642ebf77eb643a24a65c148b85c958e83a465
7
- data.tar.gz: cd1ae57550314578b6fe0df3d7917c793f273255e248eacb78592f98dc12fb2dc15c06f05c092323230ecf67c360d736953e06fffd9e878a325055a5f23d81df
6
+ metadata.gz: 3332e2fde234aab645e965644750bc650acfe94b590eb090358fc2ede5683ca54940f8f9bc81dedca11007fe6a6da4abeb57c4b9ed5ef021cbf185af21d60ff0
7
+ data.tar.gz: 8aba7335bf894058658fb2511812a01d65dd3a0d9a9b0ce7d65ebcaf6b4506f96636a0d22dd5a612cfede9d78117226ec6fcfeb1d1e02d7d61bb3676e20d4145
@@ -0,0 +1,46 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ ## Our Standards
8
+
9
+ Examples of behavior that contributes to creating a positive environment include:
10
+
11
+ * Using welcoming and inclusive language
12
+ * Being respectful of differing viewpoints and experiences
13
+ * Gracefully accepting constructive criticism
14
+ * Focusing on what is best for the community
15
+ * Showing empathy towards other community members
16
+
17
+ Examples of unacceptable behavior by participants include:
18
+
19
+ * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
+ * Trolling, insulting/derogatory comments, and personal or political attacks
21
+ * Public or private harassment
22
+ * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
24
+
25
+ ## Our Responsibilities
26
+
27
+ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
+
29
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ ## Scope
32
+
33
+ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
+
35
+ ## Enforcement
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at ronald.tse@ribose.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
+
39
+ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
+
41
+ ## Attribution
42
+
43
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44
+
45
+ [homepage]: http://contributor-covenant.org
46
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  GIT
2
2
  remote: https://github.com/riboseinc/html2doc.git
3
- revision: 9782088aac279f45a4420e977922ea141bc46a24
3
+ revision: 3b42789ece0ac0bb3de2c208062aca0feca4f797
4
4
  specs:
5
- html2doc (0.6.7)
5
+ html2doc (0.6.9)
6
6
  asciimath
7
7
  htmlentities (~> 4.3.4)
8
8
  image_size
@@ -14,9 +14,9 @@ GIT
14
14
 
15
15
  GIT
16
16
  remote: https://github.com/riboseinc/isodoc.git
17
- revision: b5db3572f9312f9d54ace3359d22236494584357
17
+ revision: 99f7eecc594e3763d98b60382588fae8e59fa0c0
18
18
  specs:
19
- isodoc (0.5.5)
19
+ isodoc (0.5.7)
20
20
  asciimath
21
21
  html2doc
22
22
  htmlentities (~> 4.3.4)
@@ -32,7 +32,7 @@ GIT
32
32
  PATH
33
33
  remote: .
34
34
  specs:
35
- asciidoctor-iso (0.7.1)
35
+ asciidoctor-iso (0.7.2)
36
36
  asciidoctor (~> 1.5.6)
37
37
  html2doc
38
38
  htmlentities (~> 4.3.4)
@@ -51,7 +51,7 @@ GEM
51
51
  byebug (9.1.0)
52
52
  coderay (1.1.2)
53
53
  diff-lcs (1.3)
54
- docile (1.1.5)
54
+ docile (1.3.0)
55
55
  equivalent-xml (0.6.0)
56
56
  nokogiri (>= 1.4.3)
57
57
  ffi (1.9.23)
@@ -92,7 +92,7 @@ GEM
92
92
  shellany (~> 0.0)
93
93
  optout (0.0.2)
94
94
  parallel (1.12.1)
95
- parser (2.5.0.3)
95
+ parser (2.5.0.4)
96
96
  ast (~> 2.4.0)
97
97
  powerpack (0.1.1)
98
98
  pry (0.11.3)
@@ -117,7 +117,7 @@ GEM
117
117
  diff-lcs (>= 1.2.0, < 2.0)
118
118
  rspec-support (~> 3.7.0)
119
119
  rspec-support (3.7.1)
120
- rubocop (0.52.1)
120
+ rubocop (0.53.0)
121
121
  parallel (~> 1.10)
122
122
  parser (>= 2.5)
123
123
  powerpack (~> 0.1)
@@ -130,8 +130,8 @@ GEM
130
130
  ruby-xslt (0.9.10)
131
131
  ruby_dep (1.5.0)
132
132
  shellany (0.0.1)
133
- simplecov (0.15.1)
134
- docile (~> 1.1.0)
133
+ simplecov (0.16.1)
134
+ docile (~> 1.1)
135
135
  json (>= 1.8, < 3)
136
136
  simplecov-html (~> 0.10.0)
137
137
  simplecov-html (0.10.2)
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.
@@ -31,15 +31,22 @@ module Asciidoctor
31
31
  File.join(File.dirname(__FILE__), File.join("html", file))
32
32
  end
33
33
 
34
- def doc_converter(node)
34
+ def html_converter(node)
35
35
  IsoDoc::Convert.new(
36
36
  htmlstylesheet: html_doc_path("htmlstyle.css"),
37
+ standardstylesheet: html_doc_path("isodoc.css"),
38
+ htmlcoverpage: html_doc_path("html_iso_titlepage.html"),
39
+ htmlintropage: html_doc_path("html_iso_intro.html"),
40
+ i18nyaml: node.attr("i18nyaml"),
41
+ )
42
+ end
43
+
44
+ def doc_converter(node)
45
+ IsoDoc::WordConvert.new(
37
46
  wordstylesheet: html_doc_path("wordstyle.css"),
38
47
  standardstylesheet: html_doc_path("isodoc.css"),
39
48
  header: html_doc_path("header.html"),
40
- htmlcoverpage: html_doc_path("html_iso_titlepage.html"),
41
49
  wordcoverpage: html_doc_path("word_iso_titlepage.html"),
42
- htmlintropage: html_doc_path("html_iso_intro.html"),
43
50
  wordintropage: html_doc_path("word_iso_intro.html"),
44
51
  i18nyaml: node.attr("i18nyaml"),
45
52
  ulstyle: "l3",
@@ -63,6 +70,7 @@ module Asciidoctor
63
70
  filename = node.attr("docfile").gsub(/\.adoc/, ".xml").
64
71
  gsub(%r{^.*/}, "")
65
72
  File.open(filename, "w") { |f| f.write(ret) }
73
+ html_converter(node).convert filename unless node.attr("nodoc")
66
74
  doc_converter(node).convert filename unless node.attr("nodoc")
67
75
  ret
68
76
  end
@@ -39,6 +39,10 @@ module Asciidoctor
39
39
  "International Organization for Standardization"].include? orgname
40
40
  org.name "International Organization for Standardization"
41
41
  org.abbreviation "ISO"
42
+ elsif ["IEC",
43
+ "International Electrotechnical Commission"].include? orgname
44
+ org.name "International Electrotechnical Commission"
45
+ org.abbreviation "IEC"
42
46
  else
43
47
  org.name orgname
44
48
  end
@@ -1,5 +1,5 @@
1
1
  require "asciidoctor/extensions"
2
- require "HTMLEntities"
2
+ require "htmlentities"
3
3
 
4
4
  module Asciidoctor
5
5
  module ISO
@@ -43,7 +43,8 @@ module Asciidoctor
43
43
  def title_subpart_validate(root)
44
44
  subpart = root.at("//bibdata/docidentifier/project-number[@subpart]")
45
45
  iec = root.at("//bibdata/contributor[role/@type = 'publisher']/"\
46
- "organization[name = 'IEC']")
46
+ "organization[abbreviation = 'IEC' or "\
47
+ "name = 'International Electrotechnical Commission']")
47
48
  warn("Subpart defined on non-IEC document!") if subpart && !iec
48
49
  end
49
50
 
@@ -67,139 +68,139 @@ module Asciidoctor
67
68
  subtitle = ss.at("./title")
68
69
  !subtitle.nil? && !subtitle&.text&.empty? ||
69
70
  warn("#{title}: each first-level subclause must have a title")
70
- end
71
- end
72
71
  end
72
+ end
73
+ end
73
74
 
74
- def title_all_siblings(xpath, label)
75
- notitle = false
76
- withtitle = false
77
- xpath.each do |s|
78
- title_all_siblings(s.xpath("./subsection | ./terms"),
79
- s&.at("./title")&.text || s["id"])
80
- subtitle = s.at("./title")
81
- notitle = notitle || (!subtitle || subtitle.text.empty?)
82
- withtitle = withtitle || !subtitle&.text&.empty?
83
- end
84
- notitle && withtitle &&
85
- warn("#{label}: all subclauses must have a title, or none")
86
- end
75
+ def title_all_siblings(xpath, label)
76
+ notitle = false
77
+ withtitle = false
78
+ xpath.each do |s|
79
+ title_all_siblings(s.xpath("./subsection | ./terms"),
80
+ s&.at("./title")&.text || s["id"])
81
+ subtitle = s.at("./title")
82
+ notitle = notitle || (!subtitle || subtitle.text.empty?)
83
+ withtitle = withtitle || !subtitle&.text&.empty?
84
+ end
85
+ notitle && withtitle &&
86
+ warn("#{label}: all subclauses must have a title, or none")
87
+ end
87
88
 
88
- def title_validate(root)
89
- title_intro_validate(root)
90
- title_main_validate(root)
91
- title_part_validate(root)
92
- title_subpart_validate(root)
93
- title_names_type_validate(root)
94
- title_first_level_validate(root)
95
- title_all_siblings(root.xpath(SECTIONS_XPATH), "(top level)")
96
- end
89
+ def title_validate(root)
90
+ title_intro_validate(root)
91
+ title_main_validate(root)
92
+ title_part_validate(root)
93
+ title_subpart_validate(root)
94
+ title_names_type_validate(root)
95
+ title_first_level_validate(root)
96
+ title_all_siblings(root.xpath(SECTIONS_XPATH), "(top level)")
97
+ end
97
98
 
98
- def onlychild_clause_validate(root)
99
- root.xpath("//subsection").each do |c|
100
- next unless c.xpath("../subsection").size == 1
101
- title = c.at("./title")
102
- location = c["id"] || c.text[0..60] + "..."
103
- location += ":#{title.text}" if c["id"] && !title.nil?
104
- warn "ISO style: #{location}: subsection is only child"
105
- end
106
- end
99
+ def onlychild_clause_validate(root)
100
+ root.xpath("//subsection").each do |c|
101
+ next unless c.xpath("../subsection").size == 1
102
+ title = c.at("./title")
103
+ location = c["id"] || c.text[0..60] + "..."
104
+ location += ":#{title.text}" if c["id"] && !title.nil?
105
+ warn "ISO style: #{location}: subsection is only child"
106
+ end
107
+ end
107
108
 
108
- def isosubgroup_validate(root)
109
- root.xpath("//technical-committee/@type").each do |t|
110
- unless %w{TC PC JTC JPC}.include? t.text
111
- warn "ISO: invalid technical committee type #{t}"
112
- end
113
- end
114
- root.xpath("//subcommittee/@type").each do |t|
115
- unless %w{SC JSC}.include? t.text
116
- warn "ISO: invalid subcommittee type #{t}"
117
- end
118
- end
109
+ def isosubgroup_validate(root)
110
+ root.xpath("//technical-committee/@type").each do |t|
111
+ unless %w{TC PC JTC JPC}.include? t.text
112
+ warn "ISO: invalid technical committee type #{t}"
119
113
  end
120
-
121
- def see_xrefs_validate(root)
122
- root.xpath("//xref").each do |t|
123
- # does not deal with preceding text marked up
124
- preceding = t.at("./preceding-sibling::text()[last()]")
125
- next unless !preceding.nil? && /\bsee\s*$/mi.match?(preceding)
126
- (target = root.at("//*[@id = '#{t['target']}']")) || next
127
- if target&.at("./ancestor-or-self::*[@obligation = 'normative']")
128
- warn "ISO: 'see #{t['target']}' is pointing to a normative section"
129
- end
130
- end
114
+ end
115
+ root.xpath("//subcommittee/@type").each do |t|
116
+ unless %w{SC JSC}.include? t.text
117
+ warn "ISO: invalid subcommittee type #{t}"
131
118
  end
119
+ end
120
+ end
132
121
 
133
- def see_erefs_validate(root)
134
- root.xpath("//eref").each do |t|
135
- preceding = t.at("./preceding-sibling::text()[last()]")
136
- next unless !preceding.nil? && /\bsee\s*$/mi.match?(preceding)
137
- target = root.at("//*[@id = '#{t['bibitemid']}']")
138
- if target.at("./ancestor::references"\
139
- "[title = 'Normative References']")
140
- warn "ISO: 'see #{t}' is pointing to a normative reference"
141
- end
142
- end
122
+ def see_xrefs_validate(root)
123
+ root.xpath("//xref").each do |t|
124
+ # does not deal with preceding text marked up
125
+ preceding = t.at("./preceding-sibling::text()[last()]")
126
+ next unless !preceding.nil? && /\bsee\s*$/mi.match?(preceding)
127
+ (target = root.at("//*[@id = '#{t['target']}']")) || next
128
+ if target&.at("./ancestor-or-self::*[@obligation = 'normative']")
129
+ warn "ISO: 'see #{t['target']}' is pointing to a normative section"
143
130
  end
131
+ end
132
+ end
144
133
 
145
- def termdef_warn(text, re, term, msg)
146
- re.match?(text) && warn("ISO style: #{term}: #{msg}")
134
+ def see_erefs_validate(root)
135
+ root.xpath("//eref").each do |t|
136
+ preceding = t.at("./preceding-sibling::text()[last()]")
137
+ next unless !preceding.nil? && /\bsee\s*$/mi.match?(preceding)
138
+ target = root.at("//*[@id = '#{t['bibitemid']}']")
139
+ if target.at("./ancestor::references"\
140
+ "[title = 'Normative References']")
141
+ warn "ISO: 'see #{t}' is pointing to a normative reference"
147
142
  end
143
+ end
144
+ end
148
145
 
149
- def termdef_style(xmldoc)
150
- xmldoc.xpath("//term").each do |t|
151
- para = t.at("./definition") || return
152
- term = t.at("./preferred").text
153
- termdef_warn(para.text, /^(the|a)\b/i, term,
154
- "term definition starts with article")
155
- termdef_warn(para.text, /\.$/i, term,
156
- "term definition ends with period")
157
- end
158
- end
146
+ def termdef_warn(text, re, term, msg)
147
+ re.match?(text) && warn("ISO style: #{term}: #{msg}")
148
+ end
159
149
 
160
- def content_validate(doc)
161
- title_validate(doc.root)
162
- isosubgroup_validate(doc.root)
163
- section_validate(doc)
164
- onlychild_clause_validate(doc.root)
165
- termdef_style(doc.root)
166
- see_xrefs_validate(doc.root)
167
- see_erefs_validate(doc.root)
168
- end
150
+ def termdef_style(xmldoc)
151
+ xmldoc.xpath("//term").each do |t|
152
+ para = t.at("./definition") || return
153
+ term = t.at("./preferred").text
154
+ termdef_warn(para.text, /^(the|a)\b/i, term,
155
+ "term definition starts with article")
156
+ termdef_warn(para.text, /\.$/i, term,
157
+ "term definition ends with period")
158
+ end
159
+ end
169
160
 
170
- def schema_validate(doc, filename)
171
- File.open(".tmp.xml", "w") { |f| f.write(doc.to_xml) }
172
- begin
173
- errors = Jing.new(filename).validate(".tmp.xml")
174
- rescue Jing::Error => e
175
- abort "what what what #{e}"
176
- end
177
- warn "Valid!" if errors.none?
178
- errors.each do |error|
179
- warn "#{error[:message]} @ #{error[:line]}:#{error[:column]}"
180
- end
181
- end
161
+ def content_validate(doc)
162
+ title_validate(doc.root)
163
+ isosubgroup_validate(doc.root)
164
+ section_validate(doc)
165
+ onlychild_clause_validate(doc.root)
166
+ termdef_style(doc.root)
167
+ see_xrefs_validate(doc.root)
168
+ see_erefs_validate(doc.root)
169
+ end
182
170
 
183
- # RelaxNG cannot cope well with wildcard attributes. So we strip
184
- # any attributes from FormattedString instances (which can contain
185
- # xs:any markup, and are signalled with @format) before validation.
186
- def formattedstr_strip(doc)
187
- doc.xpath("//*[@format]").each do |n|
188
- n.elements.each do |e|
189
- e.traverse do |e1|
190
- next unless e1.element?
191
- e1.each { |k, _v| e.delete(k) }
192
- end
193
- end
194
- end
195
- doc
196
- end
171
+ def schema_validate(doc, filename)
172
+ File.open(".tmp.xml", "w") { |f| f.write(doc.to_xml) }
173
+ begin
174
+ errors = Jing.new(filename).validate(".tmp.xml")
175
+ rescue Jing::Error => e
176
+ abort "what what what #{e}"
177
+ end
178
+ warn "Valid!" if errors.none?
179
+ errors.each do |error|
180
+ warn "#{error[:message]} @ #{error[:line]}:#{error[:column]}"
181
+ end
182
+ end
197
183
 
198
- def validate(doc)
199
- content_validate(doc)
200
- schema_validate(formattedstr_strip(doc.dup),
201
- File.join(File.dirname(__FILE__), "isostandard.rng"))
184
+ # RelaxNG cannot cope well with wildcard attributes. So we strip
185
+ # any attributes from FormattedString instances (which can contain
186
+ # xs:any markup, and are signalled with @format) before validation.
187
+ def formattedstr_strip(doc)
188
+ doc.xpath("//*[@format]").each do |n|
189
+ n.elements.each do |e|
190
+ e.traverse do |e1|
191
+ next unless e1.element?
192
+ e1.each { |k, _v| e.delete(k) }
193
+ end
202
194
  end
203
195
  end
196
+ doc
197
+ end
198
+
199
+ def validate(doc)
200
+ content_validate(doc)
201
+ schema_validate(formattedstr_strip(doc.dup),
202
+ File.join(File.dirname(__FILE__), "isostandard.rng"))
203
+ end
204
+ end
204
205
  end
205
206
  end