metanorma 1.0.6 → 1.1.0
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 +4 -4
- data/.gitignore +3 -0
- data/lib/metanorma/compile.rb +51 -16
- data/lib/metanorma/processor.rb +10 -1
- data/lib/metanorma/version.rb +1 -1
- data/metanorma.gemspec +1 -1
- metadata +8 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 315077d28cfe3e052808e9890d2f3c3f571b7350788e6d6423be1746e5559ef4
|
4
|
+
data.tar.gz: f8a9c7d3055af8a687fe8df52b725b1fadbceb8920bef8ea449af5cde0aafb6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab023b366ca20c7d4fe3785e00698d2ccd868c0d119b0df74a5ba52e11f4bd69b884b18fea2b820838708c3bae5516be911c9e82de8302b6ade8cf52c99c36b4
|
7
|
+
data.tar.gz: 3f3520b67f58296be755b0e8b2b9cfb0e98611e214f73e131e1eccde7b74dfd611db1f476cee84d5071f6ef0c1b7b801ed9874e7261697b52fb7bf288282c57d
|
data/.gitignore
CHANGED
data/lib/metanorma/compile.rb
CHANGED
@@ -4,8 +4,12 @@ require "htmlentities"
|
|
4
4
|
|
5
5
|
module Metanorma
|
6
6
|
class Compile
|
7
|
+
# @return [Array<String>]
|
8
|
+
attr_reader :errors
|
9
|
+
|
7
10
|
def initialize
|
8
11
|
@registry = Metanorma::Registry.instance
|
12
|
+
@errors = []
|
9
13
|
end
|
10
14
|
|
11
15
|
def compile(filename, options = {})
|
@@ -89,14 +93,22 @@ module Metanorma
|
|
89
93
|
end
|
90
94
|
|
91
95
|
def get_extensions(options)
|
92
|
-
options[:extension_keys] ||= @processor.output_formats.
|
93
|
-
memo << k
|
96
|
+
options[:extension_keys] ||= @processor.output_formats.reduce([]) do |memo, (k, _)|
|
97
|
+
memo << k
|
94
98
|
end
|
95
|
-
extensions = options[:extension_keys].
|
96
|
-
@processor.output_formats[e]
|
97
|
-
|
98
|
-
|
99
|
+
extensions = options[:extension_keys].reduce([]) do |memo, e|
|
100
|
+
if @processor.output_formats[e]
|
101
|
+
memo << e
|
102
|
+
else
|
103
|
+
message = "[metanorma] Error: #{e} format is not supported for this standard."
|
104
|
+
@errors << message
|
105
|
+
Util.log(message, :error)
|
106
|
+
memo
|
107
|
+
end
|
99
108
|
end
|
109
|
+
if !extensions.include?(:presentation) and extensions.any? { |e| @processor.use_presentation_xml(e) }
|
110
|
+
extensions << :presentation
|
111
|
+
end
|
100
112
|
extensions
|
101
113
|
end
|
102
114
|
|
@@ -195,10 +207,35 @@ module Metanorma
|
|
195
207
|
end
|
196
208
|
end
|
197
209
|
|
210
|
+
# dependency ordering
|
211
|
+
def sort_extensions_execution(ext)
|
212
|
+
case ext
|
213
|
+
when :xml then 0
|
214
|
+
when :rxl then 1
|
215
|
+
when :presentation then 2
|
216
|
+
else
|
217
|
+
99
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
def wrap_html(options, file_extension, outfilename)
|
222
|
+
if options[:wrapper] and /html$/.match file_extension
|
223
|
+
outfilename = outfilename.sub(/\.html$/, "")
|
224
|
+
FileUtils.mkdir_p outfilename
|
225
|
+
FileUtils.mv "#{outfilename}.html", outfilename
|
226
|
+
FileUtils.mv "#{outfilename}_images", outfilename, force: true
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
# isodoc is Raw Metanorma XML
|
198
231
|
def process_extensions(extensions, file, isodoc, options)
|
199
|
-
|
200
|
-
|
201
|
-
|
232
|
+
xml_name = options[:filename].sub(/\.[^.]+$/, ".xml")
|
233
|
+
presentationxml_name = options[:filename].sub(/\.[^.]+$/, ".presentation.xml")
|
234
|
+
isodoc_options = @processor.extract_options(file)
|
235
|
+
isodoc_options[:datauriimage] = true if options[:datauriimage]
|
236
|
+
extensions.sort do |a, b|
|
237
|
+
sort_extensions_execution(a) <=> sort_extensions_execution(b)
|
238
|
+
end.each do |ext|
|
202
239
|
file_extension = @processor.output_formats[ext]
|
203
240
|
outfilename = options[:filename].sub(/\.[^.]+$/, ".#{file_extension}")
|
204
241
|
if ext == :rxl
|
@@ -206,17 +243,15 @@ module Metanorma
|
|
206
243
|
relaton_export(isodoc, options)
|
207
244
|
else
|
208
245
|
begin
|
209
|
-
|
246
|
+
#require "byebug"; byebug
|
247
|
+
@processor.use_presentation_xml(ext) ?
|
248
|
+
@processor.output(nil, presentationxml_name, outfilename, ext, isodoc_options) :
|
249
|
+
@processor.output(isodoc, xml_name, outfilename, ext, isodoc_options)
|
210
250
|
rescue StandardError => e
|
211
251
|
puts e.message
|
212
252
|
end
|
213
253
|
end
|
214
|
-
|
215
|
-
outfilename = outfilename.sub(/\.html$/, "")
|
216
|
-
FileUtils.mkdir_p outfilename
|
217
|
-
FileUtils.mv "#{outfilename}.html", outfilename
|
218
|
-
FileUtils.mv "#{outfilename}_images", outfilename, force: true
|
219
|
-
end
|
254
|
+
wrap_html(options, file_extension, outfilename)
|
220
255
|
end
|
221
256
|
end
|
222
257
|
end
|
data/lib/metanorma/processor.rb
CHANGED
@@ -15,6 +15,7 @@ module Metanorma
|
|
15
15
|
def output_formats
|
16
16
|
{
|
17
17
|
xml: "xml",
|
18
|
+
presentation: "presentation.xml",
|
18
19
|
rxl: "rxl"
|
19
20
|
}
|
20
21
|
end
|
@@ -23,7 +24,15 @@ module Metanorma
|
|
23
24
|
raise "This is an abstract class!"
|
24
25
|
end
|
25
26
|
|
26
|
-
def
|
27
|
+
def use_presentation_xml(ext)
|
28
|
+
case ext
|
29
|
+
when :html, :doc, :pdf then true
|
30
|
+
else
|
31
|
+
false
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def output(isodoc_node, inname, outname, format, options={})
|
27
36
|
File.open(outname, "w:UTF-8") { |f| f.write(isodoc_node) }
|
28
37
|
end
|
29
38
|
|
data/lib/metanorma/version.rb
CHANGED
data/metanorma.gemspec
CHANGED
@@ -33,5 +33,5 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_development_dependency "byebug", "~> 10.0"
|
34
34
|
spec.add_development_dependency "rspec-command", "~> 1.0"
|
35
35
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
36
|
-
spec.add_development_dependency "metanorma-iso", "~> 1.
|
36
|
+
spec.add_development_dependency "metanorma-iso", "~> 1.4"
|
37
37
|
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: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -142,14 +142,14 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '1.
|
145
|
+
version: '1.4'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: '1.
|
152
|
+
version: '1.4'
|
153
153
|
description: Library to process any Metanorma standard.
|
154
154
|
email:
|
155
155
|
- open.source@ribose.com
|
@@ -202,7 +202,7 @@ homepage: https://github.com/metanorma/metanorma
|
|
202
202
|
licenses:
|
203
203
|
- BSD-2-Clause
|
204
204
|
metadata: {}
|
205
|
-
post_install_message:
|
205
|
+
post_install_message:
|
206
206
|
rdoc_options: []
|
207
207
|
require_paths:
|
208
208
|
- lib
|
@@ -217,9 +217,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
217
|
- !ruby/object:Gem::Version
|
218
218
|
version: '0'
|
219
219
|
requirements: []
|
220
|
-
|
221
|
-
|
222
|
-
signing_key:
|
220
|
+
rubygems_version: 3.0.3
|
221
|
+
signing_key:
|
223
222
|
specification_version: 4
|
224
223
|
summary: Metanorma is the standard of standards; the metanorma gem allows you to create
|
225
224
|
any standard document type supported by Metanorma.
|