metanorma 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/metanorma/compile.rb +20 -11
- data/lib/metanorma/input/asciidoc.rb +5 -2
- data/lib/metanorma/processor.rb +6 -2
- data/lib/metanorma/registry.rb +11 -2
- data/lib/metanorma/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 969ed76602cb33778779c7ab04c8c4c4be5fd63e83b448c07f96e8fafa6c7afb
|
4
|
+
data.tar.gz: cf467c6615d1e5840a8c3accdd36195f269d4624307e94d2db6d56744a95cacb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64d4f4a2f7375bb804a5e0acae3a538e4306a0f0a4cfa5c4b8688a320d0fb65e1b977099a5d413bcf87f74ab084abb11496ed20842daa476c92bb08aa57623d2
|
7
|
+
data.tar.gz: eec76dfa55611c07335aa3c661b7926c0249338b9d6225fb3e58eb78d598b2cfee8fac19ebd1623721fa0fae441b451f04fd536dec7e728ae97d652626fca897
|
data/.gitignore
CHANGED
data/lib/metanorma/compile.rb
CHANGED
@@ -15,7 +15,7 @@ module Metanorma
|
|
15
15
|
def compile(filename, options = {})
|
16
16
|
require_libraries(options)
|
17
17
|
options = options_extract(filename, options)
|
18
|
-
|
18
|
+
validate_type(options) && validate_format(options) || (return nil)
|
19
19
|
@processor = @registry.find_processor(options[:type].to_sym)
|
20
20
|
extensions = get_extensions(options) or return nil
|
21
21
|
(file, isodoc = process_input(filename, options)) or return nil
|
@@ -47,6 +47,7 @@ module Metanorma
|
|
47
47
|
o = Metanorma::Input::Asciidoc.new.extract_metanorma_options(content)
|
48
48
|
o = o.merge(xml_options_extract(content))
|
49
49
|
options[:type] ||= o[:type]&.to_sym
|
50
|
+
t = @registry.alias(options[:type]) and options[:type] = t
|
50
51
|
dir = filename.sub(%r(/[^/]+$), "/")
|
51
52
|
options[:relaton] ||= "#{dir}/#{o[:relaton]}" if o[:relaton]
|
52
53
|
options[:sourcecode] ||= "#{dir}/#{o[:sourcecode]}" if o[:sourcecode]
|
@@ -57,10 +58,6 @@ module Metanorma
|
|
57
58
|
options
|
58
59
|
end
|
59
60
|
|
60
|
-
def validate(options)
|
61
|
-
validate_type(options) && validate_format(options)
|
62
|
-
end
|
63
|
-
|
64
61
|
def validate_type(options)
|
65
62
|
unless options[:type]
|
66
63
|
Util.log("[metanorma] Error: Please specify a standard type: #{@registry.supported_backends}.", :error)
|
@@ -122,7 +119,7 @@ module Metanorma
|
|
122
119
|
dir = File.dirname(filename)
|
123
120
|
dir != '.' and
|
124
121
|
file.gsub!(/^include::/, "include::#{dir}/")
|
125
|
-
[file, @processor.input_to_isodoc(file, filename)]
|
122
|
+
[file, @processor.input_to_isodoc(file, filename, options)]
|
126
123
|
when ".xml"
|
127
124
|
Util.log("[metanorma] Processing: Metanorma XML input.", :info)
|
128
125
|
# TODO NN: this is a hack -- we should provide/bridge the
|
@@ -229,15 +226,16 @@ module Metanorma
|
|
229
226
|
|
230
227
|
# isodoc is Raw Metanorma XML
|
231
228
|
def process_extensions(extensions, file, isodoc, options)
|
232
|
-
|
233
|
-
|
229
|
+
f = change_output_dir options
|
230
|
+
xml_name = f.sub(/\.[^.]+$/, ".xml")
|
231
|
+
presentationxml_name = f.sub(/\.[^.]+$/, ".presentation.xml")
|
234
232
|
extensions.sort do |a, b|
|
235
233
|
sort_extensions_execution(a) <=> sort_extensions_execution(b)
|
236
234
|
end.each do |ext|
|
237
|
-
file_extension = @processor.output_formats[ext]
|
238
|
-
outfilename = options[:filename].sub(/\.[^.]+$/, ".#{file_extension}")
|
239
235
|
isodoc_options = @processor.extract_options(file)
|
240
236
|
isodoc_options[:datauriimage] = true if options[:datauriimage]
|
237
|
+
file_extension = @processor.output_formats[ext]
|
238
|
+
outfilename = f.sub(/\.[^.]+$/, ".#{file_extension}")
|
241
239
|
if ext == :rxl
|
242
240
|
options[:relaton] = outfilename
|
243
241
|
relaton_export(isodoc, options)
|
@@ -246,12 +244,23 @@ module Metanorma
|
|
246
244
|
@processor.use_presentation_xml(ext) ?
|
247
245
|
@processor.output(nil, presentationxml_name, outfilename, ext, isodoc_options) :
|
248
246
|
@processor.output(isodoc, xml_name, outfilename, ext, isodoc_options)
|
249
|
-
rescue StandardError => e
|
247
|
+
rescue StandardError => e
|
250
248
|
puts e.message
|
251
249
|
end
|
252
250
|
end
|
253
251
|
wrap_html(options, file_extension, outfilename)
|
254
252
|
end
|
255
253
|
end
|
254
|
+
|
255
|
+
private
|
256
|
+
|
257
|
+
# @param options [Hash]
|
258
|
+
# @return [String]
|
259
|
+
def change_output_dir(options)
|
260
|
+
if options[:"output-dir"]
|
261
|
+
File.join options[:"output-dir"], File.basename(options[:filename])
|
262
|
+
else options[:filename]
|
263
|
+
end
|
264
|
+
end
|
256
265
|
end
|
257
266
|
end
|
@@ -5,7 +5,7 @@ module Metanorma
|
|
5
5
|
|
6
6
|
class Asciidoc < Base
|
7
7
|
|
8
|
-
def process(file, filename, type)
|
8
|
+
def process(file, filename, type, options = {})
|
9
9
|
require "asciidoctor"
|
10
10
|
::Asciidoctor.convert(
|
11
11
|
file,
|
@@ -13,7 +13,10 @@ module Metanorma
|
|
13
13
|
safe: :safe,
|
14
14
|
backend: type,
|
15
15
|
header_footer: true,
|
16
|
-
attributes: [
|
16
|
+
attributes: [
|
17
|
+
"nodoc", "stem", "xrefstyle=short", "docfile=#{filename}",
|
18
|
+
"output_dir=#{options[:"output-dir"]}"
|
19
|
+
],
|
17
20
|
)
|
18
21
|
end
|
19
22
|
|
data/lib/metanorma/processor.rb
CHANGED
@@ -20,10 +20,14 @@ module Metanorma
|
|
20
20
|
}
|
21
21
|
end
|
22
22
|
|
23
|
-
def input_to_isodoc(file, filename)
|
24
|
-
|
23
|
+
def input_to_isodoc(file, filename, options = {})
|
24
|
+
Metanorma::Input::Asciidoc.new.process(file, filename, @asciidoctor_backend, options)
|
25
25
|
end
|
26
26
|
|
27
|
+
# def input_to_isodoc(file, filename)
|
28
|
+
# raise "This is an abstract class!"
|
29
|
+
# end
|
30
|
+
|
27
31
|
def use_presentation_xml(ext)
|
28
32
|
case ext
|
29
33
|
when :html, :doc, :pdf then true
|
data/lib/metanorma/registry.rb
CHANGED
@@ -14,14 +14,23 @@ module Metanorma
|
|
14
14
|
|
15
15
|
def initialize
|
16
16
|
@processors = {}
|
17
|
+
@aliases = {csd: :cc, m3d: :m3aawg, mpfd: :mpfa, csand: :csa}
|
18
|
+
end
|
19
|
+
|
20
|
+
def alias(x)
|
21
|
+
@aliases[x]
|
17
22
|
end
|
18
23
|
|
19
24
|
def register processor
|
20
25
|
raise Error unless processor < ::Metanorma::Processor
|
21
26
|
p = processor.new
|
22
|
-
|
23
|
-
|
27
|
+
# p.short[-1] is the canonical name
|
28
|
+
short = Array(p.short)
|
29
|
+
@processors[short[-1]] = p
|
30
|
+
short.each do |s|
|
31
|
+
@aliases[s] = short[-1]
|
24
32
|
end
|
33
|
+
Array(p.short)
|
25
34
|
Util.log("[metanorma] processor \"#{Array(p.short)[0]}\" registered", :info)
|
26
35
|
end
|
27
36
|
|
data/lib/metanorma/version.rb
CHANGED
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.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|