metanorma 1.3.10 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/metanorma/collection_fileparse.rb +17 -4
- data/lib/metanorma/collection_fileprocess.rb +19 -25
- data/lib/metanorma/collection_renderer.rb +6 -4
- data/lib/metanorma/compile.rb +11 -8
- data/lib/metanorma/fontist_utils.rb +34 -42
- data/lib/metanorma/input/asciidoc.rb +5 -5
- data/lib/metanorma/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12776f5bd9badbb53a16aadbc821249bb629660d3a5de20a08903bbf246e29b1
|
4
|
+
data.tar.gz: 9800801b680cb5d6097f58b22875c4c9e436914837a47ec56dc0765e14508493
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ed067f52701b80fb2c246fb09b0227dd763a8e3d333bf3a13109bd44536c77f585e46386c52dd61ce206982525843b27f05b13b21585de679b42343a0bfc2d4
|
7
|
+
data.tar.gz: d5adad943950f178745b0288a0f11baf730b3fc84a281f30b3bba082a9d9e58135dc7f29d4ea2d31d912df100b261e8cabea33a0d8732b6dca7f747de5c88e53
|
@@ -44,7 +44,7 @@ module Metanorma
|
|
44
44
|
newbib = dup_bibitem(docid, bib)
|
45
45
|
bib.replace(newbib)
|
46
46
|
_file, url = targetfile(@files[docid], relative: true, read: false,
|
47
|
-
|
47
|
+
doc: !@files[docid][:attachment])
|
48
48
|
uri_node = Nokogiri::XML::Node.new "uri", newbib
|
49
49
|
uri_node[:type] = "citation"
|
50
50
|
uri_node.content = url
|
@@ -53,7 +53,7 @@ module Metanorma
|
|
53
53
|
|
54
54
|
def fail_update_bibitem(docid, identifier)
|
55
55
|
error = "[metanorma] Cannot find crossreference to document #{docid} "\
|
56
|
-
|
56
|
+
"in document #{identifier}."
|
57
57
|
@log.add("Cross-References", nil, error)
|
58
58
|
Util.log(error, :warning)
|
59
59
|
end
|
@@ -78,6 +78,7 @@ module Metanorma
|
|
78
78
|
# @return [String] XML content
|
79
79
|
def update_xrefs(file, identifier, internal_refs)
|
80
80
|
docxml = Nokogiri::XML(file) { |config| config.huge }
|
81
|
+
supply_repo_ids(docxml)
|
81
82
|
update_indirect_refs_to_docs(docxml, internal_refs)
|
82
83
|
add_document_suffix(identifier, docxml)
|
83
84
|
update_direct_refs_to_docs(docxml, identifier)
|
@@ -89,6 +90,18 @@ module Metanorma
|
|
89
90
|
docxml.to_xml
|
90
91
|
end
|
91
92
|
|
93
|
+
def supply_repo_ids(docxml)
|
94
|
+
docxml.xpath(ns("//bibitem[not(ancestor::bibitem)]")).each do |b|
|
95
|
+
next if b&.at(ns("./docidentifier[@type = 'repository']"))
|
96
|
+
|
97
|
+
b.xpath(ns("./docidentifier")).each do |d|
|
98
|
+
next unless @files[d.text]
|
99
|
+
|
100
|
+
d.next = "<docidentifier type='repository'>current-metanorma-collection/#{d.text}"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
92
105
|
def datauri_encode(docxml)
|
93
106
|
docxml.xpath(ns("//image")).each do |i|
|
94
107
|
i["src"] = Metanorma::Utils::datauri(i["src"])
|
@@ -161,7 +174,7 @@ module Metanorma
|
|
161
174
|
if @files[docid] then update_anchor_loc(bib, e, docid)
|
162
175
|
else
|
163
176
|
e << "<strong>** Unresolved reference to document #{docid} "\
|
164
|
-
|
177
|
+
"from eref</strong>"
|
165
178
|
end
|
166
179
|
end
|
167
180
|
end
|
@@ -188,7 +201,7 @@ module Metanorma
|
|
188
201
|
ref = ins&.at(ns("./locality/referenceFrom"))&.text
|
189
202
|
anchor = @files[docid][:anchors].dig(type, ref) or return
|
190
203
|
ins << "<locality type='anchor'><referenceFrom>#{anchor.sub(/^_/, '')}"\
|
191
|
-
|
204
|
+
"</referenceFrom></locality>"
|
192
205
|
end
|
193
206
|
|
194
207
|
# gather internal bibitem references
|
@@ -164,10 +164,15 @@ module Metanorma
|
|
164
164
|
def file_compile(file, filename, identifier)
|
165
165
|
return if @files[identifier][:sectionsplit] == "true"
|
166
166
|
|
167
|
-
|
168
|
-
|
167
|
+
opts = {
|
168
|
+
format: :asciidoc,
|
169
|
+
extension_keys: @format,
|
170
|
+
output_dir: @outdir,
|
171
|
+
}.merge(compile_options(identifier))
|
172
|
+
|
173
|
+
@compile.compile file, opts
|
169
174
|
@files[identifier][:outputs] = {}
|
170
|
-
file_compile_formats(
|
175
|
+
file_compile_formats(filename, identifier)
|
171
176
|
end
|
172
177
|
|
173
178
|
def compile_options(identifier)
|
@@ -182,29 +187,17 @@ module Metanorma
|
|
182
187
|
ret
|
183
188
|
end
|
184
189
|
|
185
|
-
def file_compile_formats(
|
190
|
+
def file_compile_formats(filename, identifier)
|
191
|
+
file_id = @files[identifier]
|
186
192
|
@format.each do |e|
|
187
193
|
ext = @compile.processor.output_formats[e]
|
188
194
|
fn = File.basename(filename).sub(/(?<=\.)[^.]+$/, ext.to_s)
|
189
|
-
|
190
|
-
|
191
|
-
else
|
192
|
-
FileUtils.cp file.path.sub(/\.xml$/, ".#{ext}"),
|
193
|
-
File.join(@outdir, fn)
|
194
|
-
@files[identifier][:outputs][e] = File.join(@outdir, fn)
|
195
|
+
unless /html$/.match?(ext) && file_id[:sectionsplit]
|
196
|
+
file_id[:outputs][e] = File.join(@outdir, fn)
|
195
197
|
end
|
196
198
|
end
|
197
199
|
end
|
198
200
|
|
199
|
-
def file_sectionsplit_copy(file, base, identifier, ext, format)
|
200
|
-
dir = file.path.sub(/\.xml$/, ".#{ext}_collection")
|
201
|
-
files = Dir.glob("#{dir}/*.#{ext}")
|
202
|
-
FileUtils.cp files, @outdir
|
203
|
-
cover = File.join(@outdir, base.sub(/\.html$/, ".index.html"))
|
204
|
-
FileUtils.cp File.join(dir, "index.html"), cover
|
205
|
-
@files[identifier][:outputs][format] = cover
|
206
|
-
end
|
207
|
-
|
208
201
|
def copy_file_to_dest(fileref)
|
209
202
|
dest = File.join(@outdir, fileref[:out_path])
|
210
203
|
FileUtils.mkdir_p(File.dirname(dest))
|
@@ -223,12 +216,13 @@ module Metanorma
|
|
223
216
|
else
|
224
217
|
file, filename = targetfile(x, read: true)
|
225
218
|
warn "\n\n\n\n\nProcess #{filename}: #{DateTime.now.strftime('%H:%M:%S')}"
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
219
|
+
collection_xml = update_xrefs(file, identifier, internal_refs)
|
220
|
+
collection_filename = File.basename(filename, File.extname(filename))
|
221
|
+
collection_xml_path = File.join(Dir.tmpdir,
|
222
|
+
"#{collection_filename}.xml")
|
223
|
+
File.write collection_xml_path, collection_xml, encoding: "UTF-8"
|
224
|
+
file_compile(collection_xml_path, filename, identifier)
|
225
|
+
FileUtils.rm(collection_xml_path)
|
232
226
|
end
|
233
227
|
end
|
234
228
|
end
|
@@ -104,13 +104,15 @@ module Metanorma
|
|
104
104
|
|
105
105
|
class PdfOptionsNode
|
106
106
|
def initialize(doctype, options)
|
107
|
-
|
108
|
-
|
107
|
+
docproc = Metanorma::Registry.instance.find_processor(doctype)
|
108
|
+
if FontistUtils.has_fonts_manifest?(docproc, options)
|
109
|
+
@fonts_manifest = FontistUtils.location_manifest(docproc)
|
110
|
+
end
|
109
111
|
end
|
110
112
|
|
111
113
|
def attr(key)
|
112
|
-
if key == "
|
113
|
-
@
|
114
|
+
if key == "fonts-manifest" && @font_locations
|
115
|
+
@fonts_manifest
|
114
116
|
end
|
115
117
|
end
|
116
118
|
end
|
data/lib/metanorma/compile.rb
CHANGED
@@ -32,7 +32,7 @@ module Metanorma
|
|
32
32
|
extract(isodoc, options[:extract], options[:extract_type])
|
33
33
|
FontistUtils.install_fonts(@processor, options) unless @fontist_installed
|
34
34
|
@fontist_installed = true
|
35
|
-
process_extensions(extensions, file, isodoc, options)
|
35
|
+
process_extensions(filename, extensions, file, isodoc, options)
|
36
36
|
end
|
37
37
|
|
38
38
|
def require_libraries(options)
|
@@ -199,7 +199,7 @@ module Metanorma
|
|
199
199
|
end
|
200
200
|
|
201
201
|
# isodoc is Raw Metanorma XML
|
202
|
-
def process_extensions(extensions, file, isodoc, options)
|
202
|
+
def process_extensions(filename, extensions, file, isodoc, options)
|
203
203
|
f = change_output_dir options
|
204
204
|
xml_name = f.sub(/\.[^.]+$/, ".xml")
|
205
205
|
presentationxml_name = f.sub(/\.[^.]+$/, ".presentation.xml")
|
@@ -210,10 +210,16 @@ module Metanorma
|
|
210
210
|
if ext == :rxl
|
211
211
|
relaton_export(isodoc, options.merge(relaton: outfilename))
|
212
212
|
elsif options[:passthrough_presentation_xml] && ext == :presentation
|
213
|
-
FileUtils.cp
|
213
|
+
FileUtils.cp filename, presentationxml_name
|
214
214
|
elsif ext == :html && options[:sectionsplit]
|
215
215
|
sectionsplit_convert(xml_name, isodoc, outfilename, isodoc_options)
|
216
216
|
else
|
217
|
+
if ext == :pdf && FontistUtils.has_fonts_manifest?(@processor,
|
218
|
+
options)
|
219
|
+
isodoc_options[:mn2pdf] = {
|
220
|
+
font_manifest: FontistUtils.location_manifest(@processor),
|
221
|
+
}
|
222
|
+
end
|
217
223
|
begin
|
218
224
|
if @processor.use_presentation_xml(ext)
|
219
225
|
@processor.output(nil, presentationxml_name, outfilename, ext,
|
@@ -245,13 +251,10 @@ module Metanorma
|
|
245
251
|
isodoc_options = @processor.extract_options(file)
|
246
252
|
isodoc_options[:datauriimage] = true if options[:datauriimage]
|
247
253
|
isodoc_options[:sourcefilename] = options[:filename]
|
248
|
-
%i(bare sectionsplit no_install_fonts
|
254
|
+
%i(bare sectionsplit no_install_fonts baseassetpath aligncrosselements)
|
255
|
+
.each do |x|
|
249
256
|
isodoc_options[x] ||= options[x]
|
250
257
|
end
|
251
|
-
if ext == :pdf
|
252
|
-
floc = FontistUtils.fontist_font_locations(@processor, options) and
|
253
|
-
isodoc_options[:mn2pdf] = { font_manifest_file: floc.path }
|
254
|
-
end
|
255
258
|
isodoc_options
|
256
259
|
end
|
257
260
|
|
@@ -16,9 +16,9 @@ module Metanorma
|
|
16
16
|
Util.log("[fontist] Skip font installation because" \
|
17
17
|
" --no-install-fonts argument passed", :debug)
|
18
18
|
return false
|
19
|
-
elsif
|
19
|
+
elsif !has_fonts_manifest?(processor)
|
20
20
|
Util.log("[fontist] Skip font installation because "\
|
21
|
-
"
|
21
|
+
"fonts_manifest is missing", :debug)
|
22
22
|
return false
|
23
23
|
end
|
24
24
|
true
|
@@ -27,26 +27,42 @@ module Metanorma
|
|
27
27
|
def install_fonts_safe(manifest, agree, continue, no_progress)
|
28
28
|
fontist_install(manifest, agree, no_progress)
|
29
29
|
rescue Fontist::Errors::LicensingError
|
30
|
+
license_error_log(continue)
|
31
|
+
rescue Fontist::Errors::FontError => e
|
32
|
+
log_level = continue ? :warning : :fatal
|
33
|
+
Util.log("[fontist] '#{e.font}' font is not supported. " \
|
34
|
+
"Please report this issue at github.com/metanorma/metanorma" \
|
35
|
+
"/issues to report this issue.", log_level)
|
36
|
+
rescue Fontist::Errors::FormulaIndexNotFoundError
|
37
|
+
fintist_update_repo(manifest, agree, continue, no_progress)
|
38
|
+
end
|
39
|
+
|
40
|
+
def fontist_install(manifest, agree, no_progress)
|
41
|
+
Fontist::Manifest::Install.from_hash(
|
42
|
+
manifest,
|
43
|
+
confirmation: agree ? "yes" : "no",
|
44
|
+
no_progress: no_progress,
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
def license_error_log(continue)
|
30
49
|
if continue
|
31
50
|
Util.log(
|
32
51
|
"[fontist] Processing will continue without fonts installed",
|
33
|
-
:debug
|
52
|
+
:debug,
|
34
53
|
)
|
35
54
|
else
|
36
55
|
Util.log("[fontist] Aborting without proper fonts installed," \
|
37
56
|
" make sure that you have set option --agree-to-terms",
|
38
57
|
:fatal)
|
39
58
|
end
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
"Please report this issue at github.com/metanorma/metanorma" \
|
44
|
-
"/issues to report this issue.", log_level)
|
45
|
-
rescue Fontist::Errors::FormulaIndexNotFoundError
|
59
|
+
end
|
60
|
+
|
61
|
+
def fintist_update_repo(manifest, agree, continue, no_progress)
|
46
62
|
if @@updated_formulas_repo
|
47
63
|
Util.log(
|
48
64
|
"[fontist] Bug: formula index not found after 'fontist update'",
|
49
|
-
:fatal
|
65
|
+
:fatal,
|
50
66
|
)
|
51
67
|
end
|
52
68
|
Util.log("[fontist] Missing formula index. Fetching it...", :debug)
|
@@ -54,28 +70,6 @@ module Metanorma
|
|
54
70
|
@@updated_formulas_repo = true
|
55
71
|
install_fonts_safe(manifest, agree, continue, no_progress)
|
56
72
|
end
|
57
|
-
|
58
|
-
def fontist_install(manifest, agree, no_progress)
|
59
|
-
Fontist::Manifest::Install.from_hash(
|
60
|
-
manifest,
|
61
|
-
confirmation: agree ? "yes" : "no",
|
62
|
-
no_progress: no_progress
|
63
|
-
)
|
64
|
-
end
|
65
|
-
|
66
|
-
def dump_fontist_manifest_locations(manifest)
|
67
|
-
location_manifest = Fontist::Manifest::Locations.from_hash(
|
68
|
-
manifest
|
69
|
-
)
|
70
|
-
location_manifest_file = Tempfile.new(["fontist_locations", ".yml"])
|
71
|
-
location_manifest_file.write location_manifest.to_yaml
|
72
|
-
location_manifest_file.flush
|
73
|
-
location_manifest_file
|
74
|
-
end
|
75
|
-
|
76
|
-
def missing_fontist_manifest?(processor)
|
77
|
-
!processor.respond_to?(:fonts_manifest) || processor.fonts_manifest.nil?
|
78
|
-
end
|
79
73
|
end
|
80
74
|
|
81
75
|
def self.install_fonts(processor, options)
|
@@ -89,20 +83,18 @@ module Metanorma
|
|
89
83
|
manifest,
|
90
84
|
agree_to_terms,
|
91
85
|
can_without_fonts,
|
92
|
-
no_progress
|
86
|
+
no_progress,
|
93
87
|
)
|
94
88
|
end
|
95
89
|
|
96
|
-
def self.
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
dump_fontist_manifest_locations(processor.fonts_manifest)
|
102
|
-
rescue Fontist::Errors::FormulaIndexNotFoundError
|
103
|
-
raise unless options[:continue_without_fonts]
|
90
|
+
def self.has_fonts_manifest?(processor, options = {})
|
91
|
+
!options[:no_install_fonts] \
|
92
|
+
&& processor.respond_to?(:fonts_manifest) \
|
93
|
+
&& !processor.fonts_manifest.nil?
|
94
|
+
end
|
104
95
|
|
105
|
-
|
96
|
+
def self.location_manifest(processor)
|
97
|
+
Fontist::Manifest::Locations.from_hash(processor.fonts_manifest)
|
106
98
|
end
|
107
99
|
end
|
108
100
|
end
|
@@ -49,7 +49,7 @@ module Metanorma
|
|
49
49
|
extensions: defined?(extensions) ? extensions : nil,
|
50
50
|
relaton: defined?(relaton) ? relaton : nil,
|
51
51
|
asciimath: asciimath,
|
52
|
-
}.
|
52
|
+
}.compact
|
53
53
|
end
|
54
54
|
|
55
55
|
def empty_attr(attr, name)
|
@@ -60,9 +60,9 @@ module Metanorma
|
|
60
60
|
scripts-override scripts-pdf wordstylesheet i18nyaml
|
61
61
|
standardstylesheet header wordcoverpage wordintropage
|
62
62
|
ulstyle olstyle htmlstylesheet-override bare
|
63
|
-
htmltoclevels doctoclevels sectionsplit
|
63
|
+
htmltoclevels doctoclevels sectionsplit base-asset-path
|
64
64
|
body-font header-font monospace-font title-font
|
65
|
-
wordstylesheet-override).freeze
|
65
|
+
align-cross-elements wordstylesheet-override).freeze
|
66
66
|
|
67
67
|
def extract_options(file)
|
68
68
|
header = file.sub(/\n\n.*$/m, "\n")
|
@@ -84,12 +84,12 @@ module Metanorma
|
|
84
84
|
defined?(break_up) and
|
85
85
|
break_up = empty_attr(break_up, "break-up-urls-in-tables")
|
86
86
|
ret.merge(
|
87
|
-
datauriimage: defined?(datauriimage) ? datauriimage != "false" :
|
87
|
+
datauriimage: defined?(datauriimage) ? datauriimage != "false" : true,
|
88
88
|
suppressasciimathdup: defined?(suppress_asciimath_dup) ? suppress_asciimath_dup != "false" : nil,
|
89
89
|
hierarchical_assets: defined?(hier_assets) ? hier_assets : nil,
|
90
90
|
use_xinclude: defined?(use_xinclude) ? use_xinclude : nil,
|
91
91
|
break_up_urls_in_tables: defined?(break_up) ? break_up : nil,
|
92
|
-
).
|
92
|
+
).compact
|
93
93
|
end
|
94
94
|
end
|
95
95
|
end
|
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.
|
4
|
+
version: 1.4.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: 2021-
|
11
|
+
date: 2021-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -303,7 +303,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
303
303
|
- !ruby/object:Gem::Version
|
304
304
|
version: '0'
|
305
305
|
requirements: []
|
306
|
-
rubygems_version: 3.
|
306
|
+
rubygems_version: 3.2.22
|
307
307
|
signing_key:
|
308
308
|
specification_version: 4
|
309
309
|
summary: Metanorma is the standard of standards; the metanorma gem allows you to create
|