asciidoctor-iso 0.9.0 → 0.9.1

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
  SHA256:
3
- metadata.gz: fb4b3cf95879f9dbc87df7bb4ef5ef0cdd6d8a84d5c025d875686d22fbbccf81
4
- data.tar.gz: 72922fb815c364609f29b030aea4349dcb8b1b2e62b2aa8a6cd1e553d077c672
3
+ metadata.gz: 6ed4e5fbc863973f1ba6574f497bbc29f7e7512f8f3289d508482eb2910da16c
4
+ data.tar.gz: c3c2fa81e796ca9b7a5476252e1bd8758769390ce56fb269d3aa39d2f71daf7a
5
5
  SHA512:
6
- metadata.gz: 2598a409d73c5fba6adbe2056428b2ff33c9e3d85ae5bd19a7af1caae42ec8d96716453676c98b50c237a0855108cd79ae4fdf40043f74782b551b504008f1b1
7
- data.tar.gz: 006c5953314176be6f126765fb4281ffa268e4c5a8faa46470a5ee4dcafebfc888f0f8af98e4ce03360647e1c7f830e546ab278b966a094b9ecc41fd0dcff591
6
+ metadata.gz: 2d4c27a6911320c11976fe46f2c2bd20789921534c1617324d7fcad6c804d467540fd1242a5e61ef482f71a1b882ea019838a92ca014dad03ce504c37422fae7
7
+ data.tar.gz: 44287b9e26b88050045c7b5f03d6e95c8629ad10309eeafe391c18dace5f33bfa2bff626f83e872da415030a384e91240f6c7276a28334f9719474557284db65
@@ -4,6 +4,7 @@ AllCops:
4
4
  - "**/Gemfile"
5
5
  - "**/*.gemfile"
6
6
  - "**/Rakefile"
7
+ - "**/*.rb"
7
8
  Exclude:
8
9
  - "vendor/**/*"
9
10
  - "db/**/*"
@@ -10,6 +10,6 @@ inherit_from:
10
10
  AllCops:
11
11
  DisplayCopNames: false
12
12
  StyleGuideCopsOnly: false
13
- TargetRubyVersion: 2.4
13
+ TargetRubyVersion: 2.5
14
14
  Rails:
15
15
  Enabled: true
@@ -15,9 +15,63 @@ GEM
15
15
  httpclient (~> 2.8, >= 2.8.3)
16
16
  json (>= 1.5.1)
17
17
  asciidoctor (1.5.7.1)
18
+ asciidoctor-csand (0.3.0)
19
+ asciidoctor (~> 1.5.7)
20
+ asciidoctor-iso (>= 0.9.0)
21
+ asciimath
22
+ htmlentities (~> 4.3.4)
23
+ image_size
24
+ isodoc (>= 0.8.0)
25
+ mime-types
26
+ nokogiri
27
+ ruby-jing
28
+ ruby-xslt
29
+ thread_safe
30
+ uuidtools
31
+ asciidoctor-csd (0.4.0)
32
+ asciidoctor-iso (>= 0.9.0)
33
+ isodoc (>= 0.8.0)
34
+ asciidoctor-gb (0.3.0)
35
+ asciidoctor-iso (>= 0.9.0)
36
+ isodoc (>= 0.8.0)
37
+ twitter_cldr
38
+ asciidoctor-m3d (0.3.1)
39
+ asciidoctor (~> 1.5.7)
40
+ asciidoctor-iso (>= 0.9.0)
41
+ asciimath
42
+ htmlentities (~> 4.3.4)
43
+ image_size
44
+ isodoc (>= 0.8.0)
45
+ mime-types
46
+ nokogiri
47
+ ruby-jing
48
+ ruby-xslt
49
+ thread_safe
50
+ uuidtools
51
+ asciidoctor-rfc (0.9.0)
52
+ asciidoctor (~> 1.5.7)
53
+ htmlentities (~> 4.3.4)
54
+ nokogiri
55
+ ruby-jing
56
+ thread_safe
57
+ asciidoctor-rsd (0.3.1)
58
+ asciidoctor (~> 1.5.7)
59
+ asciidoctor-iso (>= 0.8.0)
60
+ asciimath
61
+ htmlentities (~> 4.3.4)
62
+ image_size
63
+ isodoc (>= 0.7.0)
64
+ mime-types
65
+ nokogiri
66
+ ruby-jing
67
+ ruby-xslt
68
+ thread_safe
69
+ uuidtools
18
70
  asciimath (1.0.4)
19
71
  ast (2.4.0)
20
72
  byebug (9.1.0)
73
+ camertron-eprun (1.1.1)
74
+ cldr-plurals-runtime-rb (1.0.1)
21
75
  coderay (1.1.2)
22
76
  diff-lcs (1.3)
23
77
  docile (1.3.1)
@@ -52,11 +106,11 @@ GEM
52
106
  htmlentities (4.3.4)
53
107
  httpclient (2.8.3)
54
108
  image_size (2.0.0)
55
- iso-bib-item (0.1.6)
109
+ iso-bib-item (0.1.8)
56
110
  duplicate
57
111
  isoics (~> 0.1.6)
58
112
  nokogiri
59
- isobib (0.1.6)
113
+ isobib (0.1.7)
60
114
  algoliasearch
61
115
  iso-bib-item (~> 0.1.2)
62
116
  isodoc (0.8)
@@ -81,6 +135,15 @@ GEM
81
135
  rb-inotify (~> 0.9, >= 0.9.7)
82
136
  ruby_dep (~> 1.2)
83
137
  lumberjack (1.0.13)
138
+ metanorma (0.2.2)
139
+ asciidoctor-csand (>= 0.3.0)
140
+ asciidoctor-csd (>= 0.4.0)
141
+ asciidoctor-gb (>= 0.3.0)
142
+ asciidoctor-iso (>= 0.9.0)
143
+ asciidoctor-m3d (>= 0.3.1)
144
+ asciidoctor-rfc (>= 0.9.0)
145
+ asciidoctor-rsd (>= 0.3.0)
146
+ isodoc (>= 0.8.0)
84
147
  method_source (0.9.0)
85
148
  mime-types (3.1)
86
149
  mime-types-data (~> 3.2015)
@@ -146,6 +209,12 @@ GEM
146
209
  thor (0.20.0)
147
210
  thread_safe (0.3.6)
148
211
  timecop (0.9.1)
212
+ twitter_cldr (4.4.3)
213
+ camertron-eprun
214
+ cldr-plurals-runtime-rb (~> 1.0)
215
+ tzinfo
216
+ tzinfo (1.2.5)
217
+ thread_safe (~> 0.1)
149
218
  unicode-display_width (1.4.0)
150
219
  uuidtools (2.1.5)
151
220
 
@@ -159,6 +228,7 @@ DEPENDENCIES
159
228
  equivalent-xml (~> 0.6)
160
229
  guard (~> 2.14)
161
230
  guard-rspec (~> 4.7)
231
+ metanorma
162
232
  rake (~> 12.0)
163
233
  rspec (~> 3.6)
164
234
  rubocop (~> 0.50)
@@ -41,29 +41,51 @@ gives a summary overview.
41
41
 
42
42
  == Usage
43
43
 
44
+ The preferred way to invoke this gem is via the `metanorma` script:
45
+
44
46
  [source,console]
45
47
  ----
46
- $ asciidoctor a.adoc # HTML output of Asciidoc file
47
- $ asciidoctor -b iso -r 'asciidoctor-iso' a.adoc # ISO XML output,
48
+ $ metanorma --type iso a.adoc # output HTML and DOC
49
+ $ metanorma --type csd --extensions html a.adoc # output just HTML
50
+ $ metanorma --type csd --extensions doc a.adoc # output just DOC
51
+ $ metanorma --type csd --extensions xml a.adoc # output CSD XML
48
52
  ----
49
53
 
50
- The initial step is optional, and can be used as a preview of what the gem
51
- will do; it generates a `{filename}.html` file.
54
+ The gem translates the document into ISO XML format, and then
55
+ validates its output against the ISO XML document model; errors are
56
+ reported to console against the XML, and are intended for users to
57
+ check that they have provided all necessary components of the
58
+ document.
52
59
 
53
- When invoked within Asciidoctor, the gem translates the document into
54
- ISO XML format, and then validates its
55
- output against the ISO XML document model; errors are reported to console
56
- against the XML, and are intended for users to check that they have provided
57
- all necessary components of the document.
60
+ The gem then converts the XML into HTML and DOC.
58
61
 
59
- The gem then converts the XML to Micosoft Word (`{filename}.doc`), HTML (`{filename}.html`),
60
- and PDF (forthcoming).
62
+ The gem can also be invoked directly within asciidoctor, though this is deprecated:
61
63
 
62
- In the process of generating the Microsoft Word document, the associated
63
- https://github.com/riboseinc/isodoc[IsoDoc] gem generates temporary files:
64
- `{filename}.htm` contains the Microsoft Word-specific HTML for inclusion in that file,
65
- and the `{filename}_files` folder contains any images and headers for the Word
66
- document.
64
+ [source,console]
65
+ ----
66
+ $ asciidoctor -b iso -r 'asciidoctor-iso' a.adoc
67
+ ----
68
+
69
+ If you do not invoke the `iso` backend explicitly, the AsciiISO source will be
70
+ treated as generic Asciidoc markup, and will output an HTML preview that
71
+ ignores the ISO-specific modifications to the markup:
72
+
73
+ [source,console]
74
+ ----
75
+ $ asciidoctor a.adoc
76
+ ----
77
+
78
+ === Installation
79
+
80
+ If you are using a Mac, the https://github.com/riboseinc/metanorma-macos-setup
81
+ repository has instructions on setting up your machine to run Metanorma
82
+ scripts such as this one. You need only run the following in a Terminal console:
83
+
84
+ [source,console]
85
+ ----
86
+ $ bash <(curl -s https://raw.githubusercontent.com/riboseinc/metanorma-macos-setup/master/metanorma-setup)
87
+ $ gem install asciidoctor-iso
88
+ ----
67
89
 
68
90
 
69
91
  === Content Warnings
@@ -43,4 +43,5 @@ Gem::Specification.new do |spec|
43
43
  spec.add_development_dependency "rubocop", "~> 0.50"
44
44
  spec.add_development_dependency "simplecov", "~> 0.15"
45
45
  spec.add_development_dependency "timecop", "~> 0.9"
46
+ spec.add_development_dependency "metanorma"
46
47
  end
@@ -80,120 +80,6 @@ module Asciidoctor
80
80
  end
81
81
  end
82
82
 
83
- # --- ISOBIB
84
- def fetch_ref_err(code, year, missed_years)
85
- id = year ? "#{code}:#{year}" : code
86
- warn "WARNING: no match found on the ISO website for #{id}. "\
87
- "The code must be exactly like it is on the website."
88
- warn "(There was no match for #{year}, though there were matches "\
89
- "found for #{missed_years.join(', ')}.)" unless missed_years.empty?
90
- if /\d-\d/.match? code
91
- warn "The provided document part may not exist, or the document "\
92
- "may no longer be published in parts."
93
- else
94
- warn "If you wanted to cite all document parts for the reference, "\
95
- "use \"#{code} (all parts)\".\nIf the document is not a standard, "\
96
- "use its document type abbreviation (TS, TR, PAS, Guide)."
97
- end
98
- nil
99
- end
100
-
101
- def fetch_pages(s, n)
102
- workers = WorkersPool.new n
103
- workers.worker { |w| { i: w[:i], hit: w[:hit].fetch } }
104
- s.each_with_index { |hit, i| workers << { i: i, hit: hit } }
105
- workers.end
106
- workers.result.sort { |x, y| x[:i] <=> y[:i] }.map { |x| x[:hit] }
107
- end
108
-
109
- def isobib_search_filter(code)
110
- docidrx = %r{^(ISO|IEC)[^0-9]*\s[0-9-]+}
111
- corrigrx = %r{^(ISO|IEC)[^0-9]*\s[0-9-]+:[0-9]+/}
112
- warn "fetching #{code}..."
113
- result = Isobib::IsoBibliography.search(code)
114
- result.first.select do |i|
115
- i.hit["title"] &&
116
- i.hit["title"].match(docidrx).to_s == code &&
117
- !corrigrx.match?(i.hit["title"])
118
- end
119
- end
120
-
121
- def iev
122
- Nokogiri::XML.fragment(<<~"END")
123
- <bibitem type="international-standard" id="IEV">
124
- <title format="text/plain" language="en" script="Latn">Electropedia:
125
- The World's Online Electrotechnical Vocabulary</title>
126
- <source type="src">http://www.electropedia.org</source>
127
- <docidentifier>IEV</docidentifier>
128
- <date type="published"> <on>#{Date.today.year}</on> </date>
129
- <contributor>
130
- <role type="publisher"/>
131
- <organization>
132
- <name>International Electrotechnical Commission</name>
133
- <abbreviation>IEC</abbreviation>
134
- <uri>www.iec.ch</uri>
135
- </organization>
136
- </contributor>
137
- <language>en</language> <language>fr</language>
138
- <script>Latn</script>
139
- <copyright>
140
- <from>#{Date.today.year}</from>
141
- <owner>
142
- <organization>
143
- <name>International Electrotechnical Commission</name>
144
- <abbreviation>IEC</abbreviation>
145
- <uri>www.iec.ch</uri>
146
- </organization>
147
- </owner>
148
- </copyright>
149
- <relation type="updates">
150
- <bibitem>
151
- <formattedref>IEC 60050</formattedref>
152
- </bibitem>
153
- </relation>
154
- </bibitem>
155
- END
156
- end
157
-
158
- # Sort through the results from Isobib, fetching them three at a time,
159
- # and return the first result that matches the code,
160
- # matches the year (if provided), and which # has a title (amendments do not).
161
- # Only expects the first page of results to be populated.
162
- # Does not match corrigenda etc (e.g. ISO 3166-1:2006/Cor 1:2007)
163
- # If no match, returns any years which caused mismatch, for error reporting
164
- def isobib_results_filter(result, year)
165
- missed_years = []
166
- result.each_slice(3) do |s| # ISO website only allows 3 connections
167
- fetch_pages(s, 3).each_with_index do |r, i|
168
- return { ret: r } if !year
169
- r.dates.select { |d| d.type == "published" }.each do |d|
170
- return { ret: r } if year.to_i == d.on.year
171
- missed_years << d.on.year
172
- end
173
- end
174
- end
175
- { years: missed_years }
176
- end
177
-
178
- def isobib_get1(code, year, opts)
179
- return iev if code.casecmp? "IEV"
180
- result = isobib_search_filter(code) or return nil
181
- ret = isobib_results_filter(result, year)
182
- return ret[:ret] if ret[:ret]
183
- fetch_ref_err(code, year, ret[:years])
184
- end
185
-
186
- def isobib_get(code, year, opts)
187
- code += "-1" if opts[:all_parts]
188
- ret = isobib_get1(code, year, opts)
189
- return nil if ret.nil?
190
- ret.to_most_recent_reference if !year
191
- ret.to_all_parts if opts[:all_parts]
192
- ret.to_xml
193
- end
194
-
195
- # --- ISOBIB
196
-
197
83
  def iso_id(code, year, all_parts)
198
84
  ret = code
199
85
  ret += ":#{year}" if year
@@ -204,7 +90,7 @@ module Asciidoctor
204
90
  def fetch_ref1(code, year, opts)
205
91
  id = iso_id(code, year, opts[:all_parts])
206
92
  return nil if @bibliodb.nil? # signals we will not be using isobib
207
- @bibliodb[id] = isobib_get(code, year, opts) unless @bibliodb[id]
93
+ @bibliodb[id] = Isobib::IsoBibliography.isobib_get(code, year, opts) unless @bibliodb[id]
208
94
  @local_bibliodb[id] = @bibliodb[id] if !@local_bibliodb.nil? &&
209
95
  !@local_bibliodb[id]
210
96
  return @local_bibliodb[id] unless @local_bibliodb.nil?
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module ISO
3
- VERSION = "0.9.0".freeze
3
+ VERSION = "0.9.1".freeze
4
4
  end
5
5
  end
@@ -18,6 +18,10 @@ module Metanorma
18
18
  }
19
19
  end
20
20
 
21
+ def version
22
+ "Asciidoctor::ISO #{Asciidoctor::ISO::VERSION}/IsoDoc #{IsoDoc::VERSION}"
23
+ end
24
+
21
25
  def input_to_isodoc(file)
22
26
  Metanorma::Input::Asciidoc.new.process(file, @asciidoctor_backend)
23
27
  end
@@ -35,4 +39,4 @@ module Metanorma
35
39
 
36
40
  end
37
41
  end
38
- end
42
+ end
@@ -123,7 +123,7 @@ RSpec.describe Asciidoctor::ISO do
123
123
  <text>Latex and raw rubber</text>
124
124
  </ics>
125
125
  <relation type="instance">
126
- <bibitem type="international-standard" id="ISO123">
126
+ <bibitem type="international-standard">
127
127
  <title format="text/plain" language="en" script="Latn">Rubber latex -- Sampling</title>
128
128
  <title format="text/plain" language="fr" script="Latn">Latex de caoutchouc -- Échantillonnage</title>
129
129
  <source type="src">https://www.iso.org/standard/23281.html</source>
@@ -0,0 +1,70 @@
1
+ require "spec_helper"
2
+ require "metanorma"
3
+
4
+ #RSpec.describe Asciidoctor::Gb do
5
+ RSpec.describe Metanorma::Iso::Processor do
6
+
7
+ registry = Metanorma::Registry.instance
8
+ registry.register(Metanorma::Iso::Processor)
9
+ processor = registry.find_processor(:iso)
10
+
11
+ it "registers against metanorma" do
12
+ expect(processor).not_to be nil
13
+ end
14
+
15
+ it "registers output formats against metanorma" do
16
+ expect(processor.output_formats.sort.to_s).to be_equivalent_to <<~"OUTPUT"
17
+ [[:doc, "doc"], [:html, "html"], [:html_alt, "alt.html"]]
18
+ OUTPUT
19
+ end
20
+
21
+ it "registers version against metanorma" do
22
+ expect(processor.version.to_s).to match(%r{^Asciidoctor::ISO })
23
+ expect(processor.version.to_s).to match(%r{/IsoDoc })
24
+ end
25
+
26
+ it "generates IsoDoc XML from a blank document" do
27
+ expect(processor.input_to_isodoc(<<~"INPUT")).to be_equivalent_to <<~"OUTPUT"
28
+ #{ASCIIDOC_BLANK_HDR}
29
+ INPUT
30
+ #{BLANK_HDR}
31
+ <sections/>
32
+ </iso-standard>
33
+ OUTPUT
34
+ end
35
+
36
+ it "generates HTML from IsoDoc XML" do
37
+ system "rm -f test.xml"
38
+ processor.output(<<~"INPUT", "test.html", :html)
39
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
40
+ <sections>
41
+ <terms id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title>
42
+ <term id="J">
43
+ <preferred>Term2</preferred>
44
+ </term>
45
+ </terms>
46
+ </sections>
47
+ </iso-standard>
48
+ INPUT
49
+ expect(File.read("test.html", encoding: "utf-8").gsub(%r{^.*<main}m, "<main").gsub(%r{</main>.*}m, "</main>")).to be_equivalent_to <<~"OUTPUT"
50
+ <main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
51
+ <p class="zzSTDTitle1"></p>
52
+ <div id="H"><h1>1.&#xA0; Terms and definitions</h1><p>For the purposes of this document,
53
+ the following terms and definitions apply.</p>
54
+ <p>ISO and IEC maintain terminological databases for use in
55
+ standardization at the following addresses:</p>
56
+
57
+ <ul>
58
+ <li> <p>ISO Online browsing platform: available at
59
+ <a href="http://www.iso.org/obp">http://www.iso.org/obp</a></p> </li>
60
+ <li> <p>IEC Electropedia: available at
61
+ <a href="http://www.electropedia.org">http://www.electropedia.org</a>
62
+ </p> </li> </ul>
63
+ <h2 class="TermNum" id="J">1.1</h2>
64
+ <p class="Terms" style="text-align:left;">Term2</p>
65
+ </div>
66
+ </main>
67
+ OUTPUT
68
+ end
69
+
70
+ end
@@ -8,6 +8,8 @@ require "asciidoctor"
8
8
  require "asciidoctor-iso"
9
9
  require "rspec/matchers"
10
10
  require "equivalent-xml"
11
+ require "metanorma"
12
+ require "metanorma/iso"
11
13
 
12
14
  RSpec.configure do |config|
13
15
  # Enable flags like --only-failures and --next-failure
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-iso
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-20 00:00:00.000000000 Z
11
+ date: 2018-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -220,6 +220,20 @@ dependencies:
220
220
  - - "~>"
221
221
  - !ruby/object:Gem::Version
222
222
  version: '0.9'
223
+ - !ruby/object:Gem::Dependency
224
+ name: metanorma
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ">="
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
223
237
  description: |
224
238
  asciidoctor-iso lets you write ISO standards in AsciiDoc syntax.
225
239
 
@@ -301,6 +315,7 @@ files:
301
315
  - spec/examples/rice_images/rice_image3_1.png
302
316
  - spec/examples/rice_images/rice_image3_2.png
303
317
  - spec/examples/rice_images/rice_image3_3.png
318
+ - spec/metanorma/processor_spec.rb
304
319
  - spec/spec_helper.rb
305
320
  homepage: https://github.com/riboseinc/asciidoctor-iso
306
321
  licenses:
@@ -322,7 +337,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
322
337
  version: '0'
323
338
  requirements: []
324
339
  rubyforge_project:
325
- rubygems_version: 2.7.7
340
+ rubygems_version: 2.7.6
326
341
  signing_key:
327
342
  specification_version: 4
328
343
  summary: asciidoctor-iso lets you write ISO standards in AsciiDoc.