metanorma 1.4.5 → 1.4.7.1
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/.github/workflows/rake.yml +1 -1
- data/lib/metanorma/collection.rb +2 -2
- data/lib/metanorma/collection_fileprocess.rb +2 -2
- data/lib/metanorma/collection_renderer.rb +16 -13
- data/lib/metanorma/compile.rb +3 -65
- data/lib/metanorma/compile_options.rb +83 -0
- data/lib/metanorma/input/asciidoc.rb +3 -1
- data/lib/metanorma/version.rb +1 -1
- data/metanorma.gemspec +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dddc02c01b500bb0ebed4952da4a8896110d962313d975fb601d4a84c6f25f98
|
4
|
+
data.tar.gz: e9918089f99a5ca51330dc7f97cfa693543a07986f1630d591f5c4627a0d4109
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a656de998950d44ed0b21f5a12a433c2ab2a39eac75c74be641a60358fffc8bed29cb6def6f8d078d8e39cf9e94dbb58e32225e0bd9d0da4c3570ae0fff7bed
|
7
|
+
data.tar.gz: 52ef6879ea3aca932b7e3802c9e947855b06d4e3cc752be5b0f45d99ba8ef27ea10e5126585c6b3960e1cd5b2e2164c0033be0a28d97abaf8fa82e0050cf47b4
|
data/.github/workflows/rake.yml
CHANGED
data/lib/metanorma/collection.rb
CHANGED
@@ -56,7 +56,7 @@ module Metanorma
|
|
56
56
|
# @return [String] XML
|
57
57
|
def to_xml
|
58
58
|
b = Nokogiri::XML::Builder.new do |xml|
|
59
|
-
xml.send("metanorma-collection",
|
59
|
+
xml.send(:"metanorma-collection",
|
60
60
|
"xmlns" => "http://metanorma.org") do |mc|
|
61
61
|
collection_body(mc)
|
62
62
|
end
|
@@ -183,7 +183,7 @@ module Metanorma
|
|
183
183
|
|
184
184
|
def doccontainer1(builder, doc, idx)
|
185
185
|
id = format("doc%<index>09d", index: idx)
|
186
|
-
builder.send("doc-container", id: id) do |b|
|
186
|
+
builder.send(:"doc-container", id: id) do |b|
|
187
187
|
if doc.attachment
|
188
188
|
doc.bibitem and b << doc.bibitem.root.to_xml
|
189
189
|
b.attachment Metanorma::Utils::datauri(doc.file)
|
@@ -69,8 +69,8 @@ module Metanorma
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def add_section_split_instance(file, manifest, key, idx, files)
|
72
|
-
|
73
|
-
|
72
|
+
presfile = File.join(File.dirname(files[key][:ref]),
|
73
|
+
File.basename(file[:url]))
|
74
74
|
manifest["#{key} #{file[:title]}"] =
|
75
75
|
{ parentid: key, presentationxml: true, type: "fileref",
|
76
76
|
rel_path: file[:url], out_path: File.basename(file[:url]),
|
@@ -85,22 +85,25 @@ module Metanorma
|
|
85
85
|
next unless %i(presentation xml).include?(e)
|
86
86
|
|
87
87
|
ext = e == :presentation ? "presentation.xml" : e.to_s
|
88
|
-
out = col.clone
|
89
|
-
out.directives << "documents-inline"
|
90
|
-
out.documents.each_key do |id|
|
91
|
-
next if @files[id][:attachment] || @files[id][:outputs].nil?
|
92
|
-
|
93
|
-
filename = @files[id][:outputs][e]
|
94
|
-
out.documents[id] = Metanorma::Document.raw_file(filename)
|
95
|
-
end
|
96
88
|
File.open(File.join(@outdir, "collection.#{ext}"), "w:UTF-8") do |f|
|
97
|
-
f.write(
|
89
|
+
f.write(concatenate1(col.clone, e).to_xml)
|
98
90
|
end
|
99
91
|
end
|
100
92
|
options[:format].include?(:pdf) and
|
101
93
|
pdfconv.convert(File.join(@outdir, "collection.presentation.xml"))
|
102
94
|
end
|
103
95
|
|
96
|
+
def concatenate1(out, ext)
|
97
|
+
out.directives << "documents-inline"
|
98
|
+
out.documents.each_key do |id|
|
99
|
+
next if @files[id][:attachment] || @files[id][:outputs].nil?
|
100
|
+
|
101
|
+
out.documents[id] =
|
102
|
+
Metanorma::Document.raw_file(@files[id][:outputs][ext])
|
103
|
+
end
|
104
|
+
out
|
105
|
+
end
|
106
|
+
|
104
107
|
def pdfconv
|
105
108
|
doctype = @doctype.to_sym
|
106
109
|
x = Asciidoctor.load nil, backend: doctype
|
@@ -152,9 +155,9 @@ module Metanorma
|
|
152
155
|
|
153
156
|
# infer the flavour from the first document identifier; relaton does that
|
154
157
|
def doctype
|
155
|
-
if (docid = @xml
|
158
|
+
if (docid = @xml.at(ns("//bibdata/docidentifier/@type"))&.text)
|
156
159
|
dt = docid.downcase
|
157
|
-
elsif (docid = @xml
|
160
|
+
elsif (docid = @xml.at(ns("//bibdata/docidentifier"))&.text)
|
158
161
|
dt = docid.sub(/\s.*$/, "").lowercase
|
159
162
|
else return "standoc"
|
160
163
|
end
|
@@ -179,8 +182,8 @@ module Metanorma
|
|
179
182
|
# @param elm [Nokogiri::XML::Element]
|
180
183
|
# @return [String]
|
181
184
|
def indexfile_title(elm)
|
182
|
-
lvl = elm
|
183
|
-
lbl = elm
|
185
|
+
lvl = elm.at(ns("./level"))&.text&.capitalize
|
186
|
+
lbl = elm.at(ns("./title"))&.text
|
184
187
|
"#{lvl}#{lvl && lbl ? ': ' : ''}#{lbl}"
|
185
188
|
end
|
186
189
|
|
data/lib/metanorma/compile.rb
CHANGED
@@ -5,6 +5,7 @@ require "yaml"
|
|
5
5
|
require "fontist"
|
6
6
|
require "fontist/manifest/install"
|
7
7
|
require_relative "compile_validate"
|
8
|
+
require_relative "compile_options"
|
8
9
|
require_relative "fontist_utils"
|
9
10
|
require_relative "util"
|
10
11
|
require_relative "sectionsplit"
|
@@ -32,61 +33,10 @@ module Metanorma
|
|
32
33
|
(file, isodoc = process_input(filename, options)) or return nil
|
33
34
|
relaton_export(isodoc, options)
|
34
35
|
extract(isodoc, options[:extract], options[:extract_type])
|
35
|
-
|
36
|
-
@fontist_installed = true
|
36
|
+
font_install(options)
|
37
37
|
process_exts(filename, extensions, file, isodoc, options)
|
38
38
|
end
|
39
39
|
|
40
|
-
def require_libraries(options)
|
41
|
-
options&.dig(:require)&.each { |r| require r }
|
42
|
-
end
|
43
|
-
|
44
|
-
def xml_options_extract(file)
|
45
|
-
xml = Nokogiri::XML(file) { |config| config.huge }
|
46
|
-
if xml.root
|
47
|
-
@registry.root_tags.each do |k, v|
|
48
|
-
return { type: k } if v == xml.root.name
|
49
|
-
end
|
50
|
-
end
|
51
|
-
{}
|
52
|
-
end
|
53
|
-
|
54
|
-
def options_extract(filename, options)
|
55
|
-
content = read_file(filename)
|
56
|
-
o = Metanorma::Input::Asciidoc.new.extract_metanorma_options(content)
|
57
|
-
.merge(xml_options_extract(content))
|
58
|
-
options[:type] ||= o[:type]&.to_sym
|
59
|
-
t = @registry.alias(options[:type]) and options[:type] = t
|
60
|
-
dir = filename.sub(%r(/[^/]+$), "/")
|
61
|
-
options[:relaton] ||= "#{dir}/#{o[:relaton]}" if o[:relaton]
|
62
|
-
options[:sourcecode] ||= "#{dir}/#{o[:sourcecode]}" if o[:sourcecode]
|
63
|
-
options[:extension_keys] ||= o[:extensions]&.split(/, */)&.map(&:to_sym)
|
64
|
-
options[:extension_keys] = nil if options[:extension_keys] == [:all]
|
65
|
-
options[:format] ||= :asciidoc
|
66
|
-
options[:filename] = filename
|
67
|
-
options
|
68
|
-
end
|
69
|
-
|
70
|
-
def get_extensions(options)
|
71
|
-
options[:extension_keys] ||=
|
72
|
-
@processor.output_formats.reduce([]) { |memo, (k, _)| memo << k }
|
73
|
-
extensions = options[:extension_keys].reduce([]) do |memo, e|
|
74
|
-
if @processor.output_formats[e] then memo << e
|
75
|
-
else
|
76
|
-
message = "[metanorma] Error: #{e} format is not supported for this standard."
|
77
|
-
@errors << message
|
78
|
-
Util.log(message, :error)
|
79
|
-
memo
|
80
|
-
end
|
81
|
-
end
|
82
|
-
if !extensions.include?(:presentation) && extensions.any? do |e|
|
83
|
-
@processor.use_presentation_xml(e)
|
84
|
-
end
|
85
|
-
extensions << :presentation
|
86
|
-
end
|
87
|
-
extensions
|
88
|
-
end
|
89
|
-
|
90
40
|
def process_input(filename, options)
|
91
41
|
case extname = File.extname(filename)
|
92
42
|
when ".adoc" then process_input_adoc(filename, options)
|
@@ -174,7 +124,7 @@ module Metanorma
|
|
174
124
|
if ext == :rxl
|
175
125
|
relaton_export(isodoc, options.merge(relaton: fnames[:out]))
|
176
126
|
elsif options[:passthrough_presentation_xml] && ext == :presentation
|
177
|
-
f = File.
|
127
|
+
f = File.exist?(fnames[:f]) ? fnames[:f] : fnames[:orig_filename]
|
178
128
|
FileUtils.cp f, fnames[:presentationxml]
|
179
129
|
elsif ext == :html && options[:sectionsplit]
|
180
130
|
sectionsplit_convert(fnames[:xml], isodoc, fnames[:out],
|
@@ -222,18 +172,6 @@ module Metanorma
|
|
222
172
|
end
|
223
173
|
end
|
224
174
|
|
225
|
-
def get_isodoc_options(file, options, ext)
|
226
|
-
ret = @processor.extract_options(file)
|
227
|
-
ret[:datauriimage] = true if options[:datauriimage]
|
228
|
-
ret[:sourcefilename] = options[:filename]
|
229
|
-
%i(bare sectionsplit no_install_fonts baseassetpath aligncrosselements)
|
230
|
-
.each { |x| ret[x] ||= options[x] }
|
231
|
-
ext == :pdf && FontistUtils.has_fonts_manifest?(@processor, options) and
|
232
|
-
ret[:mn2pdf] =
|
233
|
-
{ font_manifest: FontistUtils.location_manifest(@processor) }
|
234
|
-
ret
|
235
|
-
end
|
236
|
-
|
237
175
|
# @param options [Hash]
|
238
176
|
# @return [String]
|
239
177
|
def change_output_dir(options)
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require "csv"
|
2
|
+
|
3
|
+
module Metanorma
|
4
|
+
class Compile
|
5
|
+
def require_libraries(options)
|
6
|
+
options&.dig(:require)&.each { |r| require r }
|
7
|
+
end
|
8
|
+
|
9
|
+
def xml_options_extract(file)
|
10
|
+
xml = Nokogiri::XML(file) { |config| config.huge }
|
11
|
+
if xml.root
|
12
|
+
@registry.root_tags.each do |k, v|
|
13
|
+
return { type: k } if v == xml.root.name
|
14
|
+
end
|
15
|
+
end
|
16
|
+
{}
|
17
|
+
end
|
18
|
+
|
19
|
+
def options_extract(filename, options)
|
20
|
+
content = read_file(filename)
|
21
|
+
o = Metanorma::Input::Asciidoc.new.extract_metanorma_options(content)
|
22
|
+
.merge(xml_options_extract(content))
|
23
|
+
options[:type] ||= o[:type]&.to_sym
|
24
|
+
t = @registry.alias(options[:type]) and options[:type] = t
|
25
|
+
dir = filename.sub(%r(/[^/]+$), "/")
|
26
|
+
options[:relaton] ||= File.join(dir, o[:relaton]) if o[:relaton]
|
27
|
+
options[:sourcecode] ||= File.join(dir, o[:sourcecode]) if o[:sourcecode]
|
28
|
+
options[:extension_keys] ||= o[:extensions]&.split(/, */)&.map(&:to_sym)
|
29
|
+
options[:extension_keys] = nil if options[:extension_keys] == [:all]
|
30
|
+
options[:format] ||= :asciidoc
|
31
|
+
options[:filename] = filename
|
32
|
+
options[:fontlicenseagreement] ||= "no-install-fonts"
|
33
|
+
options
|
34
|
+
end
|
35
|
+
|
36
|
+
def get_extensions(options)
|
37
|
+
options[:extension_keys] ||=
|
38
|
+
@processor.output_formats.reduce([]) { |memo, (k, _)| memo << k }
|
39
|
+
extensions = options[:extension_keys].reduce([]) do |memo, e|
|
40
|
+
if @processor.output_formats[e] then memo << e
|
41
|
+
else
|
42
|
+
message = "[metanorma] Error: #{e} format is not supported for this standard."
|
43
|
+
@errors << message
|
44
|
+
Util.log(message, :error)
|
45
|
+
memo
|
46
|
+
end
|
47
|
+
end
|
48
|
+
if !extensions.include?(:presentation) && extensions.any? do |e|
|
49
|
+
@processor.use_presentation_xml(e)
|
50
|
+
end
|
51
|
+
extensions << :presentation
|
52
|
+
end
|
53
|
+
extensions
|
54
|
+
end
|
55
|
+
|
56
|
+
def font_install(opt)
|
57
|
+
FontistUtils.install_fonts(@processor, opt) unless @fontist_installed
|
58
|
+
@fontist_installed = true
|
59
|
+
return if !opt[:fonts] ||
|
60
|
+
opt[:fontlicenseagreement] == "continue-without-fonts"
|
61
|
+
|
62
|
+
confirm = opt[:fontlicenseagreement] == "no-install-fonts" ? "no" : "yes"
|
63
|
+
CSV.parse_line(opt[:fonts], col_sep: ";").map(&:strip).each do |f|
|
64
|
+
Fontist::Font.install(f, confirmation: confirm)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def get_isodoc_options(file, options, ext)
|
71
|
+
ret = @processor.extract_options(file)
|
72
|
+
ret[:datauriimage] = true if options[:datauriimage]
|
73
|
+
ret[:sourcefilename] = options[:filename]
|
74
|
+
%i(bare sectionsplit no_install_fonts baseassetpath aligncrosselements
|
75
|
+
tocfigures toctables tocrecommendations)
|
76
|
+
.each { |x| ret[x] ||= options[x] }
|
77
|
+
ext == :pdf && FontistUtils.has_fonts_manifest?(@processor, options) and
|
78
|
+
ret[:mn2pdf] =
|
79
|
+
{ font_manifest: FontistUtils.location_manifest(@processor) }
|
80
|
+
ret
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -68,7 +68,9 @@ module Metanorma
|
|
68
68
|
pdf-owner-password pdf-allow-copy-content pdf-allow-edit-content
|
69
69
|
pdf-allow-assemble-document pdf-allow-edit-annotations
|
70
70
|
pdf-allow-print pdf-allow-print-hq pdf-allow-fill-in-forms
|
71
|
-
|
71
|
+
toc-figures toc-tables toc-recommendations fonts
|
72
|
+
font-license-agreement pdf-allow-access-content
|
73
|
+
pdf-encrypt-metadata).freeze
|
72
74
|
|
73
75
|
def extract_options(file)
|
74
76
|
header = file.sub(/\n\n.*$/m, "\n")
|
data/lib/metanorma/version.rb
CHANGED
data/metanorma.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.required_ruby_version = ">= 2.5.0"
|
24
24
|
|
25
25
|
spec.add_runtime_dependency "asciidoctor"
|
26
|
-
spec.add_runtime_dependency "fontist", "
|
26
|
+
spec.add_runtime_dependency "fontist", ">= 1.14"
|
27
27
|
spec.add_runtime_dependency "htmlentities"
|
28
28
|
spec.add_runtime_dependency "metanorma-utils", "~> 1.2.0"
|
29
29
|
spec.add_runtime_dependency "mn2pdf", "~> 1"
|
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.4.
|
4
|
+
version: 1.4.7.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: 2022-
|
11
|
+
date: 2022-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: fontist
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.14'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.14'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: htmlentities
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -271,6 +271,7 @@ files:
|
|
271
271
|
- lib/metanorma/collection_manifest.rb
|
272
272
|
- lib/metanorma/collection_renderer.rb
|
273
273
|
- lib/metanorma/compile.rb
|
274
|
+
- lib/metanorma/compile_options.rb
|
274
275
|
- lib/metanorma/compile_validate.rb
|
275
276
|
- lib/metanorma/config.rb
|
276
277
|
- lib/metanorma/document.rb
|
@@ -305,7 +306,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
305
306
|
- !ruby/object:Gem::Version
|
306
307
|
version: '0'
|
307
308
|
requirements: []
|
308
|
-
rubygems_version: 3.
|
309
|
+
rubygems_version: 3.3.9
|
309
310
|
signing_key:
|
310
311
|
specification_version: 4
|
311
312
|
summary: Metanorma is the standard of standards; the metanorma gem allows you to create
|