metanorma 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -1
- data/Gemfile.lock +1 -140
- data/README.adoc +35 -2
- data/{exe → bin}/metanorma-pdf.js +0 -0
- data/lib/metanorma/output/pdf.rb +1 -1
- data/lib/metanorma/version.rb +1 -1
- data/metanorma.gemspec +4 -12
- metadata +7 -122
- data/exe/metanorma +0 -140
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65769038eade4b4613c4a2e8d3afae9937aff96be1de9c2837edf3daaf0b4864
|
4
|
+
data.tar.gz: c0f88cd2052207059fd87a27fb53ef5ef67d5f34df5f7911e43438a40c853d8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 481b22243ec66037111e6e278f5a20fcf838c83de0eb5e4cad5326fe190c8b4ea04d70e3ce2b6f68aca442f7fe36c5e6d49ebcaf537cca86dc2f14fb81498fff
|
7
|
+
data.tar.gz: b37a1957127ac6b27299d7fddacaf1ad3596834a239993bc83e9be052d8f93faa1e2b823c7251ca1bd39aa73a164851383a5839f8b700a9e5eca0e4ddd0a4710
|
data/.travis.yml
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
+
dist: trusty
|
1
2
|
sudo: false
|
2
3
|
language: ruby
|
3
4
|
rvm:
|
4
|
-
- 2.5
|
5
|
+
- 2.5
|
6
|
+
- 2.4
|
7
|
+
- ruby-head
|
5
8
|
node_js:
|
6
9
|
- "iojs"
|
7
10
|
- "8"
|
@@ -9,4 +12,7 @@ before_install:
|
|
9
12
|
- gem install bundler -v 1.16.1
|
10
13
|
- npm install -g puppeteer
|
11
14
|
- npm install
|
15
|
+
matrix:
|
16
|
+
allow_failures:
|
17
|
+
- rvm: ruby-head
|
12
18
|
|
data/Gemfile.lock
CHANGED
@@ -2,142 +2,19 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
metanorma (0.2.5)
|
5
|
-
asciidoctor-csand (>= 0.3.0)
|
6
|
-
asciidoctor-csd (>= 0.4.0)
|
7
|
-
asciidoctor-gb (>= 0.3.0)
|
8
|
-
asciidoctor-iso (>= 0.9.1)
|
9
|
-
asciidoctor-m3d (>= 0.3.1)
|
10
|
-
asciidoctor-rfc (>= 0.9.0)
|
11
|
-
asciidoctor-rsd (>= 0.3.0)
|
12
|
-
isodoc (>= 0.8.0)
|
13
5
|
|
14
6
|
GEM
|
15
7
|
remote: https://rubygems.org/
|
16
8
|
specs:
|
17
|
-
algoliasearch (1.23.2)
|
18
|
-
httpclient (~> 2.8, >= 2.8.3)
|
19
|
-
json (>= 1.5.1)
|
20
|
-
asciidoctor (1.5.7.1)
|
21
|
-
asciidoctor-csand (0.3.1)
|
22
|
-
asciidoctor (~> 1.5.7)
|
23
|
-
asciidoctor-iso (>= 0.9.0)
|
24
|
-
asciimath
|
25
|
-
htmlentities (~> 4.3.4)
|
26
|
-
image_size
|
27
|
-
isodoc (>= 0.8.0)
|
28
|
-
mime-types
|
29
|
-
nokogiri
|
30
|
-
ruby-jing
|
31
|
-
ruby-xslt
|
32
|
-
thread_safe
|
33
|
-
uuidtools
|
34
|
-
asciidoctor-csd (0.4.1)
|
35
|
-
asciidoctor-iso (>= 0.9.0)
|
36
|
-
isodoc (>= 0.8.0)
|
37
|
-
asciidoctor-gb (0.3.1)
|
38
|
-
asciidoctor-iso (>= 0.9.0)
|
39
|
-
gbbib
|
40
|
-
isodoc (>= 0.8.0)
|
41
|
-
twitter_cldr
|
42
|
-
asciidoctor-iso (0.9.3)
|
43
|
-
asciidoctor (~> 1.5.7)
|
44
|
-
iso-bib-item (~> 0.1.6)
|
45
|
-
isobib (~> 0.1.8)
|
46
|
-
isodoc (>= 0.8)
|
47
|
-
ruby-jing
|
48
|
-
asciidoctor-m3d (0.3.2)
|
49
|
-
asciidoctor (~> 1.5.7)
|
50
|
-
asciidoctor-iso (>= 0.9.0)
|
51
|
-
asciimath
|
52
|
-
htmlentities (~> 4.3.4)
|
53
|
-
image_size
|
54
|
-
isodoc (>= 0.8.0)
|
55
|
-
mime-types
|
56
|
-
nokogiri
|
57
|
-
ruby-jing
|
58
|
-
ruby-xslt
|
59
|
-
thread_safe
|
60
|
-
uuidtools
|
61
|
-
asciidoctor-rfc (0.9.0)
|
62
|
-
asciidoctor (~> 1.5.7)
|
63
|
-
htmlentities (~> 4.3.4)
|
64
|
-
nokogiri
|
65
|
-
ruby-jing
|
66
|
-
thread_safe
|
67
|
-
asciidoctor-rsd (0.3.1)
|
68
|
-
asciidoctor (~> 1.5.7)
|
69
|
-
asciidoctor-iso (>= 0.8.0)
|
70
|
-
asciimath
|
71
|
-
htmlentities (~> 4.3.4)
|
72
|
-
image_size
|
73
|
-
isodoc (>= 0.7.0)
|
74
|
-
mime-types
|
75
|
-
nokogiri
|
76
|
-
ruby-jing
|
77
|
-
ruby-xslt
|
78
|
-
thread_safe
|
79
|
-
uuidtools
|
80
|
-
asciimath (1.0.4)
|
81
9
|
byebug (10.0.2)
|
82
|
-
camertron-eprun (1.1.1)
|
83
|
-
cldr-plurals-runtime-rb (1.0.1)
|
84
|
-
cnccs (0.1.1)
|
85
10
|
diff-lcs (1.3)
|
86
|
-
duplicate (1.1.1)
|
87
11
|
equivalent-xml (0.6.0)
|
88
12
|
nokogiri (>= 1.4.3)
|
89
|
-
ffi (1.9.25)
|
90
|
-
gbbib (0.1.2)
|
91
|
-
cnccs
|
92
|
-
iso-bib-item
|
93
|
-
html2doc (0.8.0)
|
94
|
-
asciimath
|
95
|
-
htmlentities (~> 4.3.4)
|
96
|
-
image_size
|
97
|
-
mime-types
|
98
|
-
nokogiri
|
99
|
-
ruby-xslt
|
100
|
-
thread_safe
|
101
|
-
uuidtools
|
102
|
-
htmlentities (4.3.4)
|
103
|
-
httpclient (2.8.3)
|
104
|
-
image_size (2.0.0)
|
105
|
-
iso-bib-item (0.1.10)
|
106
|
-
duplicate
|
107
|
-
isoics (~> 0.1.6)
|
108
|
-
nokogiri
|
109
|
-
isobib (0.1.9)
|
110
|
-
algoliasearch
|
111
|
-
iso-bib-item (~> 0.1.10)
|
112
|
-
isodoc (0.8.1)
|
113
|
-
asciimath
|
114
|
-
html2doc (>= 0.7.1)
|
115
|
-
htmlentities (~> 4.3.4)
|
116
|
-
image_size
|
117
|
-
liquid
|
118
|
-
mime-types
|
119
|
-
nokogiri
|
120
|
-
roman-numerals
|
121
|
-
ruby-xslt
|
122
|
-
sass
|
123
|
-
thread_safe
|
124
|
-
uuidtools
|
125
|
-
isoics (0.1.6)
|
126
|
-
json (2.1.0)
|
127
|
-
liquid (4.0.0)
|
128
|
-
mime-types (3.1)
|
129
|
-
mime-types-data (~> 3.2015)
|
130
|
-
mime-types-data (3.2016.0521)
|
131
13
|
mini_portile2 (2.3.0)
|
132
14
|
mixlib-shellout (2.3.2)
|
133
|
-
nokogiri (1.8.
|
15
|
+
nokogiri (1.8.4)
|
134
16
|
mini_portile2 (~> 2.3.0)
|
135
|
-
optout (0.0.2)
|
136
17
|
rake (10.5.0)
|
137
|
-
rb-fsevent (0.10.3)
|
138
|
-
rb-inotify (0.9.10)
|
139
|
-
ffi (>= 0.5.0, < 2)
|
140
|
-
roman-numerals (0.3.0)
|
141
18
|
rspec (3.7.0)
|
142
19
|
rspec-core (~> 3.7.0)
|
143
20
|
rspec-expectations (~> 3.7.0)
|
@@ -158,22 +35,6 @@ GEM
|
|
158
35
|
diff-lcs (>= 1.2.0, < 2.0)
|
159
36
|
rspec-support (~> 3.7.0)
|
160
37
|
rspec-support (3.7.1)
|
161
|
-
ruby-jing (0.0.1)
|
162
|
-
optout (>= 0.0.2)
|
163
|
-
ruby-xslt (0.9.10)
|
164
|
-
sass (3.5.6)
|
165
|
-
sass-listen (~> 4.0.0)
|
166
|
-
sass-listen (4.0.0)
|
167
|
-
rb-fsevent (~> 0.9, >= 0.9.4)
|
168
|
-
rb-inotify (~> 0.9, >= 0.9.7)
|
169
|
-
thread_safe (0.3.6)
|
170
|
-
twitter_cldr (4.4.3)
|
171
|
-
camertron-eprun
|
172
|
-
cldr-plurals-runtime-rb (~> 1.0)
|
173
|
-
tzinfo
|
174
|
-
tzinfo (1.2.5)
|
175
|
-
thread_safe (~> 0.1)
|
176
|
-
uuidtools (2.1.5)
|
177
38
|
|
178
39
|
PLATFORMS
|
179
40
|
ruby
|
data/README.adoc
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
= Metanorma: the standard for standards
|
2
2
|
|
3
|
+
image:https://img.shields.io/gem/v/metanorma.svg["Gem Version", link="https://rubygems.org/gems/metanorma"]
|
4
|
+
image:https://img.shields.io/travis/riboseinc/metanorma/master.svg["Build Status", link="https://travis-ci.org/riboseinc/metanorma"]
|
5
|
+
image:https://codeclimate.com/github/riboseinc/metanorma/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/riboseinc/metanorma"]
|
6
|
+
|
3
7
|
Metanorma is dedicated to harmonizing standard documents
|
4
8
|
produced by different standard-setting bodies in a manner that
|
5
9
|
maintains correct semantics while allowing each standard publisher to
|
@@ -45,7 +49,7 @@ the https://github.com/riboseinc/asciidoctor-m3d/[asciidoctor-m3d implementation
|
|
45
49
|
|
46
50
|
== Installation
|
47
51
|
|
48
|
-
=== All-in-one install
|
52
|
+
=== All-in-one install, MacOS
|
49
53
|
|
50
54
|
macOS users can directly run the Metanorma setup script located here:
|
51
55
|
https://github.com/riboseinc/metanorma-macos-setup
|
@@ -53,6 +57,35 @@ https://github.com/riboseinc/metanorma-macos-setup
|
|
53
57
|
This is a one-stop installation script that setups Ruby, Node
|
54
58
|
and all necessary parts for running Metanorma.
|
55
59
|
|
60
|
+
=== Installation, https://www.ubuntu.com[Ubunto]
|
61
|
+
|
62
|
+
[source,sh]
|
63
|
+
----
|
64
|
+
# Set up prerequisites
|
65
|
+
apt-get update
|
66
|
+
apt install -y git make ruby-bundler ruby-dev libxml2-dev libxslt-dev default-jre
|
67
|
+
gem install bundler
|
68
|
+
gem install nokogiri -v '1.8.4'
|
69
|
+
gem install metanorma-cli
|
70
|
+
----
|
71
|
+
|
72
|
+
(You may need to run these as `sudo`)
|
73
|
+
|
74
|
+
If you want to run Ubuntu on MacOS, you should do the following beforehand:
|
75
|
+
|
76
|
+
[source,sh]
|
77
|
+
----
|
78
|
+
# Setup docker through dinghy on MacOS:
|
79
|
+
brew tap codekitchen/dinghy
|
80
|
+
brew install dinghy
|
81
|
+
brew install docker docker-machine
|
82
|
+
dinghy create --provider virtualbox
|
83
|
+
|
84
|
+
# Run the Ubuntu container:
|
85
|
+
dinghy up
|
86
|
+
eval $(dinghy env)
|
87
|
+
docker run -it ubuntu:18.10 bash
|
88
|
+
----
|
56
89
|
|
57
90
|
=== Installing individual components
|
58
91
|
|
@@ -60,7 +93,7 @@ The Metanorma workflow can be utilized via the `metanorma` Ruby gem.
|
|
60
93
|
|
61
94
|
[source,sh]
|
62
95
|
----
|
63
|
-
gem install metanorma
|
96
|
+
gem install metanorma-cli
|
64
97
|
----
|
65
98
|
|
66
99
|
If you are going to generate PDFs from HTML (which applies to CSD), you will also need to install
|
File without changes
|
data/lib/metanorma/output/pdf.rb
CHANGED
@@ -4,7 +4,7 @@ module Metanorma
|
|
4
4
|
|
5
5
|
def convert(url_path, output_path)
|
6
6
|
file_url = "file://#{Dir.pwd}/#{url_path}"
|
7
|
-
pdfjs = File.join(File.dirname(__FILE__), '../../../
|
7
|
+
pdfjs = File.join(File.dirname(__FILE__), '../../../bin/metanorma-pdf.js')
|
8
8
|
system "export NODE_PATH=$(npm root --quiet -g);
|
9
9
|
node #{pdfjs} #{file_url} #{output_path}"
|
10
10
|
end
|
data/lib/metanorma/version.rb
CHANGED
data/metanorma.gemspec
CHANGED
@@ -10,16 +10,16 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ['open.source@ribose.com']
|
11
11
|
|
12
12
|
spec.summary = %q{Metanorma is the standard of standards; the metanorma gem allows you to create any standard document type supported by Metanorma.}
|
13
|
-
spec.description = %q{
|
13
|
+
spec.description = %q{Library to process any Metanorma standard.}
|
14
14
|
spec.homepage = "https://github.com/riboseinc/metanorma"
|
15
|
-
spec.license = "
|
15
|
+
spec.license = "BSD-2-Clause"
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
18
|
f.match(%r{^(test|spec|features)/})
|
19
19
|
end
|
20
20
|
spec.extra_rdoc_files = %w[README.adoc CHANGELOG.adoc LICENSE.txt]
|
21
|
-
spec.bindir = "
|
22
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.bindir = "bin"
|
22
|
+
#spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
25
|
spec.required_ruby_version = '>= 2.4.0'
|
@@ -31,12 +31,4 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_development_dependency "rspec-command", "~> 1.0.3"
|
32
32
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
33
33
|
|
34
|
-
spec.add_runtime_dependency 'asciidoctor-iso', ">= 0.9.1"
|
35
|
-
spec.add_runtime_dependency 'asciidoctor-rfc', ">= 0.9.0"
|
36
|
-
spec.add_runtime_dependency 'asciidoctor-gb', ">= 0.3.0"
|
37
|
-
spec.add_runtime_dependency 'asciidoctor-csd', ">= 0.4.0"
|
38
|
-
spec.add_runtime_dependency 'asciidoctor-csand', ">= 0.3.0"
|
39
|
-
spec.add_runtime_dependency 'asciidoctor-rsd', ">= 0.3.0"
|
40
|
-
spec.add_runtime_dependency 'asciidoctor-m3d', ">= 0.3.1"
|
41
|
-
spec.add_runtime_dependency 'isodoc', ">= 0.8.0"
|
42
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,124 +94,10 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0.6'
|
97
|
-
|
98
|
-
name: asciidoctor-iso
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 0.9.1
|
104
|
-
type: :runtime
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 0.9.1
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: asciidoctor-rfc
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 0.9.0
|
118
|
-
type: :runtime
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: 0.9.0
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: asciidoctor-gb
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: 0.3.0
|
132
|
-
type: :runtime
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: 0.3.0
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: asciidoctor-csd
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - ">="
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: 0.4.0
|
146
|
-
type: :runtime
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - ">="
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: 0.4.0
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: asciidoctor-csand
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - ">="
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: 0.3.0
|
160
|
-
type: :runtime
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - ">="
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: 0.3.0
|
167
|
-
- !ruby/object:Gem::Dependency
|
168
|
-
name: asciidoctor-rsd
|
169
|
-
requirement: !ruby/object:Gem::Requirement
|
170
|
-
requirements:
|
171
|
-
- - ">="
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: 0.3.0
|
174
|
-
type: :runtime
|
175
|
-
prerelease: false
|
176
|
-
version_requirements: !ruby/object:Gem::Requirement
|
177
|
-
requirements:
|
178
|
-
- - ">="
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version: 0.3.0
|
181
|
-
- !ruby/object:Gem::Dependency
|
182
|
-
name: asciidoctor-m3d
|
183
|
-
requirement: !ruby/object:Gem::Requirement
|
184
|
-
requirements:
|
185
|
-
- - ">="
|
186
|
-
- !ruby/object:Gem::Version
|
187
|
-
version: 0.3.1
|
188
|
-
type: :runtime
|
189
|
-
prerelease: false
|
190
|
-
version_requirements: !ruby/object:Gem::Requirement
|
191
|
-
requirements:
|
192
|
-
- - ">="
|
193
|
-
- !ruby/object:Gem::Version
|
194
|
-
version: 0.3.1
|
195
|
-
- !ruby/object:Gem::Dependency
|
196
|
-
name: isodoc
|
197
|
-
requirement: !ruby/object:Gem::Requirement
|
198
|
-
requirements:
|
199
|
-
- - ">="
|
200
|
-
- !ruby/object:Gem::Version
|
201
|
-
version: 0.8.0
|
202
|
-
type: :runtime
|
203
|
-
prerelease: false
|
204
|
-
version_requirements: !ruby/object:Gem::Requirement
|
205
|
-
requirements:
|
206
|
-
- - ">="
|
207
|
-
- !ruby/object:Gem::Version
|
208
|
-
version: 0.8.0
|
209
|
-
description: Executable and library to process any Metanorma standard.
|
97
|
+
description: Library to process any Metanorma standard.
|
210
98
|
email:
|
211
99
|
- open.source@ribose.com
|
212
|
-
executables:
|
213
|
-
- metanorma
|
214
|
-
- metanorma-pdf.js
|
100
|
+
executables: []
|
215
101
|
extensions: []
|
216
102
|
extra_rdoc_files:
|
217
103
|
- README.adoc
|
@@ -229,9 +115,8 @@ files:
|
|
229
115
|
- README.adoc
|
230
116
|
- Rakefile
|
231
117
|
- bin/console
|
118
|
+
- bin/metanorma-pdf.js
|
232
119
|
- bin/setup
|
233
|
-
- exe/metanorma
|
234
|
-
- exe/metanorma-pdf.js
|
235
120
|
- lib/metanorma.rb
|
236
121
|
- lib/metanorma/document.rb
|
237
122
|
- lib/metanorma/input.rb
|
@@ -246,7 +131,7 @@ files:
|
|
246
131
|
- metanorma.gemspec
|
247
132
|
homepage: https://github.com/riboseinc/metanorma
|
248
133
|
licenses:
|
249
|
-
-
|
134
|
+
- BSD-2-Clause
|
250
135
|
metadata: {}
|
251
136
|
post_install_message:
|
252
137
|
rdoc_options: []
|
data/exe/metanorma
DELETED
@@ -1,140 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "optparse"
|
4
|
-
require "metanorma"
|
5
|
-
|
6
|
-
registry = Metanorma::Registry.instance
|
7
|
-
|
8
|
-
supported_gem_paths = [
|
9
|
-
"asciidoctor-rfc",
|
10
|
-
"asciidoctor-iso",
|
11
|
-
"asciidoctor-gb",
|
12
|
-
"asciidoctor-csd",
|
13
|
-
"asciidoctor-csand",
|
14
|
-
"asciidoctor-m3d",
|
15
|
-
"asciidoctor-rsd"
|
16
|
-
]
|
17
|
-
|
18
|
-
puts "[metanorma] detecting backends:"
|
19
|
-
supported_gem_paths.each do |backend|
|
20
|
-
begin
|
21
|
-
puts backend
|
22
|
-
require backend
|
23
|
-
rescue LoadError
|
24
|
-
puts "[metanorma] backend #{backend} not present"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
puts
|
28
|
-
|
29
|
-
options = {
|
30
|
-
format: :asciidoc
|
31
|
-
}
|
32
|
-
opt_parser = OptionParser.new do |opts|
|
33
|
-
opts.banner += " <file>"
|
34
|
-
opts.on(
|
35
|
-
'-t',
|
36
|
-
'--type TYPE',
|
37
|
-
"Type of standard to generate: #{registry.supported_backends.join(", ")}"
|
38
|
-
) { |v| options[:type] = v.to_sym }
|
39
|
-
|
40
|
-
opts.on(
|
41
|
-
'-x',
|
42
|
-
'--extensions EXT1,EXT2,...',
|
43
|
-
Array,
|
44
|
-
"Type of extension to generate per type: #{registry.output_formats}\n"
|
45
|
-
) { |v| options[:extension_keys] = v.map(&:to_sym) }
|
46
|
-
|
47
|
-
opts.on(
|
48
|
-
'-f',
|
49
|
-
'--format FORMAT',
|
50
|
-
'Format of source file: asciidoc (current default, only format supported)'
|
51
|
-
) { |v| options[:format] = v.to_sym }
|
52
|
-
|
53
|
-
opts.on(
|
54
|
-
'-r',
|
55
|
-
'--require LIBRARY',
|
56
|
-
'Require LIBRARY prior to execution'
|
57
|
-
) { |v|
|
58
|
-
options[:require] ||= []
|
59
|
-
options[:require] << v
|
60
|
-
}
|
61
|
-
|
62
|
-
opts.on(
|
63
|
-
'-v',
|
64
|
-
'--version',
|
65
|
-
"Print version of code (accompanied with -t)",
|
66
|
-
) { options[:version] = true }
|
67
|
-
|
68
|
-
opts.on_tail("-h", "--help", "Show this message") do
|
69
|
-
puts opts
|
70
|
-
exit
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
opt_parser.parse!(ARGV)
|
76
|
-
|
77
|
-
if options[:version]
|
78
|
-
case options[:format]
|
79
|
-
when :asciidoc
|
80
|
-
processor = registry.find_processor(options[:type].to_sym)
|
81
|
-
puts processor.version
|
82
|
-
exit
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
options[:filename] = ARGV.pop
|
87
|
-
|
88
|
-
unless options[:type]
|
89
|
-
puts "[metanorma] Error: Please specify a standard type."
|
90
|
-
puts opt_parser.help
|
91
|
-
exit 0
|
92
|
-
end
|
93
|
-
|
94
|
-
unless registry.supported_backends.include? options[:type]
|
95
|
-
puts "[metanorma] Error: #{options[:type]} is not a supported standard type."
|
96
|
-
exit 0
|
97
|
-
end
|
98
|
-
|
99
|
-
unless options[:format] == :asciidoc
|
100
|
-
puts "[metanorma] Error: Only source file format currently supported is 'asciidoc'."
|
101
|
-
exit 0
|
102
|
-
end
|
103
|
-
|
104
|
-
unless options[:filename]
|
105
|
-
puts "[metanorma] Error: Need to specify a file to process."
|
106
|
-
exit 0
|
107
|
-
end
|
108
|
-
|
109
|
-
if options[:require]
|
110
|
-
options[:require].each do |r|
|
111
|
-
require r
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
case options[:format]
|
116
|
-
when :asciidoc
|
117
|
-
processor = registry.find_processor(options[:type].to_sym)
|
118
|
-
options[:extension_keys] ||= processor.output_formats.inject([]) do |memo, (k, _)|
|
119
|
-
memo << k; memo
|
120
|
-
end
|
121
|
-
extensions = options[:extension_keys].inject([]) do |memo, e|
|
122
|
-
if processor.output_formats[e]
|
123
|
-
memo << e
|
124
|
-
else
|
125
|
-
warn "[metanorma] Error: #{e} format is not supported for this standard"
|
126
|
-
end
|
127
|
-
memo
|
128
|
-
end
|
129
|
-
exit 0 if extensions.empty?
|
130
|
-
|
131
|
-
file = File.read(options[:filename], encoding: "utf-8")
|
132
|
-
isodoc = processor.input_to_isodoc(file)
|
133
|
-
isodoc_options = processor.extract_options(file)
|
134
|
-
extensions.each do |ext|
|
135
|
-
file_extension = processor.output_formats[ext]
|
136
|
-
outfilename = options[:filename].sub(/\.[^.]+$/, ".#{file_extension}")
|
137
|
-
processor.output(isodoc, outfilename, ext, isodoc_options)
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|