metanorma 0.1.3 → 0.1.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3afda147aa1490bff868f52c5e8f8e411028b0d0
4
- data.tar.gz: a52450e9374de20040c6565d9bc0dd5eaf5bb6b2
3
+ metadata.gz: 11a5cb8d0c0eb5830d072fa12c7a54ec1899d111
4
+ data.tar.gz: 1dd1b0095116194e7ddca1a69b487dec4ffd194a
5
5
  SHA512:
6
- metadata.gz: fd8d262d7a5bdbfe8338babf1077f3a91e4f1cd5e017fd53f4cb8c90c2603bfba954bc01d3b491f0a821df23e07cb984ad1660ee09249bf82058bf40e99f2dcb
7
- data.tar.gz: 56668430b1744adc075e49ee4a095d65b1dc27ffed175c8dc8a3818df080384a4b446cdede0a2cb812e3c6c5777203187f9f75549f7ecddedbfc0c0ece6b38f5
6
+ metadata.gz: 1a755afb86d4d93493ee3053e1d93915c6fd0d2701626842dc05ce064c89ac349ee42533968f3a2544bfcdee1b2e483c81197d0b1464994a55799c441604f3a3
7
+ data.tar.gz: af467e052c12a0c5b638ad19398819ccd028faa17b24b2b73082c3c5afd22c44bcb6f847bd561392b0507c870272ecb6841d806f2049c4a15117a6d239370270
@@ -0,0 +1,139 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ metanorma (0.1.4)
5
+ asciidoctor-csand (>= 0.2.6)
6
+ asciidoctor-csd (>= 0.2.8)
7
+ asciidoctor-gb (>= 0.2.4)
8
+ asciidoctor-iso (>= 0.7.9)
9
+ asciidoctor-rfc (>= 0.8.5)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ algoliasearch (1.22.0)
15
+ httpclient (~> 2.8, >= 2.8.3)
16
+ json (>= 1.5.1)
17
+ asciidoctor (1.5.7.1)
18
+ asciidoctor-csand (0.2.7)
19
+ asciidoctor (~> 1.5.7)
20
+ asciidoctor-iso (>= 0.7.5)
21
+ asciimath
22
+ htmlentities (~> 4.3.4)
23
+ image_size
24
+ isodoc
25
+ mime-types
26
+ nokogiri
27
+ ruby-jing
28
+ ruby-xslt
29
+ thread_safe
30
+ uuidtools
31
+ asciidoctor-csd (0.2.8)
32
+ asciidoctor-iso (>= 0.7.9)
33
+ asciidoctor-gb (0.2.4)
34
+ asciidoctor-iso (>= 0.7.9)
35
+ twitter_cldr
36
+ asciidoctor-iso (0.7.9)
37
+ asciidoctor (~> 1.5.7)
38
+ html2doc
39
+ isobib (~> 0.1.4)
40
+ isodoc (~> 0.6.2)
41
+ ruby-jing
42
+ asciidoctor-rfc (0.8.5)
43
+ asciidoctor (~> 1.5.7)
44
+ htmlentities (~> 4.3.4)
45
+ nokogiri
46
+ ruby-jing
47
+ thread_safe
48
+ asciimath (1.0.4)
49
+ camertron-eprun (1.1.1)
50
+ cldr-plurals-runtime-rb (1.0.1)
51
+ diff-lcs (1.3)
52
+ ffi (1.9.23)
53
+ html2doc (0.7.1)
54
+ asciimath
55
+ htmlentities (~> 4.3.4)
56
+ image_size
57
+ mime-types
58
+ nokogiri
59
+ ruby-xslt
60
+ thread_safe
61
+ uuidtools
62
+ htmlentities (4.3.4)
63
+ httpclient (2.8.3)
64
+ image_size (2.0.0)
65
+ iso-bib-item (0.1.3)
66
+ isoics (~> 0.1.6)
67
+ nokogiri
68
+ isobib (0.1.4)
69
+ algoliasearch
70
+ iso-bib-item (~> 0.1.2)
71
+ isodoc (0.6.2)
72
+ asciimath
73
+ html2doc
74
+ htmlentities (~> 4.3.4)
75
+ image_size
76
+ liquid
77
+ mime-types
78
+ nokogiri
79
+ roman-numerals
80
+ ruby-xslt
81
+ sass
82
+ thread_safe
83
+ uuidtools
84
+ isoics (0.1.6)
85
+ json (2.1.0)
86
+ liquid (4.0.0)
87
+ mime-types (3.1)
88
+ mime-types-data (~> 3.2015)
89
+ mime-types-data (3.2016.0521)
90
+ mini_portile2 (2.3.0)
91
+ nokogiri (1.8.2)
92
+ mini_portile2 (~> 2.3.0)
93
+ optout (0.0.2)
94
+ rake (10.5.0)
95
+ rb-fsevent (0.10.3)
96
+ rb-inotify (0.9.10)
97
+ ffi (>= 0.5.0, < 2)
98
+ roman-numerals (0.3.0)
99
+ rspec (3.7.0)
100
+ rspec-core (~> 3.7.0)
101
+ rspec-expectations (~> 3.7.0)
102
+ rspec-mocks (~> 3.7.0)
103
+ rspec-core (3.7.1)
104
+ rspec-support (~> 3.7.0)
105
+ rspec-expectations (3.7.0)
106
+ diff-lcs (>= 1.2.0, < 2.0)
107
+ rspec-support (~> 3.7.0)
108
+ rspec-mocks (3.7.0)
109
+ diff-lcs (>= 1.2.0, < 2.0)
110
+ rspec-support (~> 3.7.0)
111
+ rspec-support (3.7.1)
112
+ ruby-jing (0.0.1)
113
+ optout (>= 0.0.2)
114
+ ruby-xslt (0.9.10)
115
+ sass (3.5.6)
116
+ sass-listen (~> 4.0.0)
117
+ sass-listen (4.0.0)
118
+ rb-fsevent (~> 0.9, >= 0.9.4)
119
+ rb-inotify (~> 0.9, >= 0.9.7)
120
+ thread_safe (0.3.6)
121
+ twitter_cldr (4.4.3)
122
+ camertron-eprun
123
+ cldr-plurals-runtime-rb (~> 1.0)
124
+ tzinfo
125
+ tzinfo (1.2.5)
126
+ thread_safe (~> 0.1)
127
+ uuidtools (2.1.5)
128
+
129
+ PLATFORMS
130
+ ruby
131
+
132
+ DEPENDENCIES
133
+ bundler (~> 1.16)
134
+ metanorma!
135
+ rake (~> 10.0)
136
+ rspec (~> 3.0)
137
+
138
+ BUNDLED WITH
139
+ 1.16.2
@@ -33,6 +33,13 @@ The Metanorma workflow can be utilized via the `metanorma` Ruby gem.
33
33
  gem install metanorma
34
34
  ----
35
35
 
36
+ If you are going to generate PDFs from HTML (which applies to CSD), you will also need to install
37
+ the node library https://github.com/GoogleChrome/puppeteer:
38
+
39
+ * Install Node, with at least version 7.6.0: https://nodejs.org/en/download/,
40
+ https://nodejs.org/en/download/package-manager/ . (For Mac, `brew install node`)
41
+ * Install npm: https://docs.npmjs.com/getting-started/installing-node
42
+ * Install puppeteer: `npm install -g --save --save-exact puppeteer`
36
43
 
37
44
  == Usage
38
45
 
@@ -42,7 +49,7 @@ Help command:
42
49
  ----
43
50
  $ metanorma -h
44
51
  Usage: metanorma [options] <file>
45
- -t, --type TYPE Type of standard to generate: rfc2, rfc3, iso, gb, csd
52
+ -t, --type TYPE Type of standard to generate: rfc2, rfc3, iso, gb, csd, csand, m3d
46
53
  -f, --format FORMAT Format of source file: asciidoc (current default, only format supported)
47
54
  -r, --require LIBRARY Require LIBRARY prior to execution
48
55
  -h, --help Show this message
@@ -74,9 +81,24 @@ metanorma --type iso iso-my-standard-document.adoc
74
81
 
75
82
  == Origin of name
76
83
 
77
- *Meta-* is a prefix of Greek origin ("μετα") for "`with`" or simply
78
- "`of`", and *norma* is Latin for "`rule`" and "`standard`". The
79
- Metanorma project is for setting a standard for standard documents
80
- created by standards-setting organizations, and therefore is given this
81
- rather fitting name.
84
+ *Meta-* is a prefix of Greek origin ("μετα") for "`with`" "`after`".
85
+ In English, it has ended up meaning "about (its own category)"; e.g.
86
+ _meta-discussion_ (a discussion about discussion). (For the roundabout way
87
+ it ended up with that meaning, see https://en.wikipedia.org/wiki/Meta#Etymology.)
88
+
89
+ *Norma* is Latin for "`rule`" and "`standard`"; hence English _norm_,
90
+ but also German _Norm_ "standard".
91
+
92
+ The Metanorma project is for setting a standard for standard documents
93
+ created by standards-setting organizations (which is a meta thing to do);
94
+ hence this name.
95
+
96
+ Metanorma seeks to embrace all standards documents standards, but not possess any:
97
+ it can give rise to many "standard" standards, but not limit the extension of any of those standards.
98
+
99
+ The motto of the project is https://en.wikipedia.org/wiki/Aequitas[_Aequitate_] _verum_,
100
+ "Truth through equity". Dealing with all standards fairly (_aequitate_), we seek not an abstract
101
+ virtue (_veritas_), but a practical reality on the ground (_verum_), that can be used by
102
+ stakeholders of multiple standards.
103
+
82
104
 
@@ -1,7 +1,32 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "optparse"
4
- require "asciidoctor/cli"
4
+
5
+ def asciidoc_extract_options(file)
6
+ header = file.sub(/\n\n.*$/m, "")
7
+ /\nscript: (?<script>[^\n]+)\n/ =~ header
8
+ /\nbody-font: (?<bodyfont>[^\n]+)\n/ =~ header
9
+ /\nheader-font: (?<headerfont>[^\n]+)\n/ =~ header
10
+ /\nmonospace-font: (?<monospacefont>[^\n]+)\n/ =~ header
11
+ /\ntitle-font: (?<titlefont>[^\n]+)\n/ =~ header
12
+ /\ni18nyaml: (?<ni18nyaml>[^\n]+)\n/ =~ header
13
+ {
14
+ script: defined?(script) ? script : nil,
15
+ bodyfont: defined?(bodyfont) ? bodyfont : nil,
16
+ headerfont: defined?(headerfont) ? headerfont : nil,
17
+ monospacefont: defined?(monospacefont) ? monospacefont : nil,
18
+ titlefont: defined?(titlefont) ? titlefont : nil,
19
+ i18nyaml: defined?(i18nyaml) ? i18nyaml : nil,
20
+ }.reject { |_, val| val.nil? }.map
21
+ end
22
+
23
+ def pdf_convert(filename)
24
+ url = "#{Dir.pwd}/#{filename}.html"
25
+ pdfjs = File.join(File.dirname(__FILE__), 'pdf.js')
26
+ system "export NODE_PATH=$(npm root --quiet -g);
27
+ node #{pdfjs} file://#{url} #{filename}.pdf"
28
+ end
29
+
5
30
 
6
31
  supported_backends = [
7
32
  {
@@ -40,6 +65,12 @@ supported_backends = [
40
65
  asciidoctor_backend: "csand"
41
66
  },
42
67
 
68
+ {
69
+ short: :m3d,
70
+ load_path: "asciidoctor/m3d/converter",
71
+ asciidoctor_backend: "m3d"
72
+ },
73
+
43
74
  # {
44
75
  # short: :rsd,
45
76
  # load_path: "asciidoctor/rsd/converter",
@@ -126,16 +157,34 @@ if options[:require]
126
157
  end
127
158
  end
128
159
 
129
- asciidoc_options = Asciidoctor::Cli::Options.new(
130
- backend: options[:type],
131
- header_footer: true
132
- )
133
- if asciidoc_options.parse!([options[:filename]]) == 0
134
- puts "[metanorma] Error: Backend process error."
135
- exit 0
160
+ case options[:format]
161
+ when "asciidoc"
162
+ if %w{rfc2 rfc3}.include? options[:type]
163
+ Asciidoctor.convert_file options[:filename], to_file: true, safe: :safe, backend: options[:type], header_footer: true
164
+ else
165
+ file = File.read(options[:filename], encoding: "utf-8")
166
+ #file = file.sub(%r{^([^\n]*\n)}, "\\1:nodoc: \n") # no isodoc output; ignored in rfc2, rfc3
167
+ xml = Asciidoctor.convert file, to_file: false, safe: :safe, backend: options[:type], header_footer: true,
168
+ attributes: %w(nodoc stem xrefstyle=short)
169
+ isodoc_options = asciidoc_extract_options(file)
170
+ filename = options[:filename].sub(/\.[^.]+$/, "")
171
+ case options[:type]
172
+ when "iso"
173
+ IsoDoc::Iso::Convert.new(options).convert(filename, xml)
174
+ IsoDoc::Iso::Convert.new(options.merge(alt: true)).convert(filename + "_alt", xml)
175
+ IsoDoc::Iso::WordConvert.new(options).convert(filename, xml)
176
+ when "gb"
177
+ IsoDoc::Gb::Convert.new(options).convert(filename, xml)
178
+ IsoDoc::Gb::WordConvert.new(options).convert(filename, xml)
179
+ when "csd"
180
+ IsoDoc::Csd::Convert.new(options).convert(filename, xml)
181
+ pdf_convert(filename)
182
+ when "csand"
183
+ IsoDoc::Csand::Convert.new(options).convert(filename, xml)
184
+ when "m3d"
185
+ IsoDoc::M3d::Convert.new(options).convert(filename, xml)
186
+ IsoDoc::M3d::WordConvert.new(options).convert(filename, xml)
187
+ end
188
+ end
136
189
  end
137
190
 
138
- invoker = Asciidoctor::Cli::Invoker.new asciidoc_options
139
- GC.start
140
- invoker.invoke!
141
- exit invoker.code
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ const puppeteer = require('puppeteer');
4
+
5
+ const createPdf = async() => {
6
+ let browser;
7
+ try {
8
+ browser = await puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']});
9
+ const page = await browser.newPage();
10
+ await page.goto(process.argv[2], {waitUntil: 'networkidle2'});
11
+ await page.pdf({
12
+ path: process.argv[3],
13
+ format: 'A4'
14
+ });
15
+ } catch (err) {
16
+ console.log(err.message);
17
+ } finally {
18
+ if (browser) {
19
+ browser.close();
20
+ }
21
+ process.exit();
22
+ }
23
+ };
24
+ createPdf();
@@ -1,3 +1,3 @@
1
1
  module Metanorma
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -27,10 +27,10 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency "rake", "~> 10.0"
28
28
  spec.add_development_dependency "rspec", "~> 3.0"
29
29
 
30
- spec.add_runtime_dependency 'asciidoctor-iso'
31
- spec.add_runtime_dependency 'asciidoctor-rfc'
32
- spec.add_runtime_dependency 'asciidoctor-gb'
33
- spec.add_runtime_dependency 'asciidoctor-csd'
34
- spec.add_runtime_dependency 'asciidoctor-csand'
30
+ spec.add_runtime_dependency 'asciidoctor-iso', ">= 0.7.9"
31
+ spec.add_runtime_dependency 'asciidoctor-rfc', ">= 0.8.5"
32
+ spec.add_runtime_dependency 'asciidoctor-gb', ">= 0.2.4"
33
+ spec.add_runtime_dependency 'asciidoctor-csd', ">= 0.2.8"
34
+ spec.add_runtime_dependency 'asciidoctor-csand', ">= 0.2.6"
35
35
  # spec.add_runtime_dependency 'asciidoctor-rsd'
36
36
  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.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-21 00:00:00.000000000 Z
11
+ date: 2018-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,76 +58,77 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 0.7.9
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 0.7.9
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: asciidoctor-rfc
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: 0.8.5
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: 0.8.5
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: asciidoctor-gb
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 0.2.4
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 0.2.4
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: asciidoctor-csd
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: 0.2.8
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: 0.2.8
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: asciidoctor-csand
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: 0.2.6
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: 0.2.6
125
125
  description: Metanorma is the standard of standards; the metanorma gem allows you
126
126
  to create any standard document type supported by Metanorma.
127
127
  email:
128
128
  - open.source@ribose.com
129
129
  executables:
130
130
  - metanorma
131
+ - pdf.js
131
132
  extensions: []
132
133
  extra_rdoc_files:
133
134
  - README.adoc
@@ -140,12 +141,14 @@ files:
140
141
  - CHANGELOG.adoc
141
142
  - CODE_OF_CONDUCT.md
142
143
  - Gemfile
144
+ - Gemfile.lock
143
145
  - LICENSE.txt
144
146
  - README.adoc
145
147
  - Rakefile
146
148
  - bin/console
147
149
  - bin/setup
148
150
  - exe/metanorma
151
+ - exe/pdf.js
149
152
  - lib/metanorma.rb
150
153
  - lib/metanorma/version.rb
151
154
  - metanorma.gemspec