metanorma 1.3.9.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cebdc5e3a04db33d1bf3c0042d914f03a1e7c36ae67d625138fb1499679abdcf
|
4
|
+
data.tar.gz: 82f7a4b816cea046181cfd05da94ca21a52f1c12ac02d9f6f2e89ae1b07e6f60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfa8565f3b0a55f12f0d0e8971d82c8bf619390cfc76860514dda7b1801267d7e04719161048ff7d9b16a71e238df2e24e145198229b5b5930233ae9110933ec
|
7
|
+
data.tar.gz: 81764ee18d5c1b36f3aacf19c0a4cf4b02cd4fb0a8979fe9d0a6733a93f4f05ddc845be35b25ec38be31d595fd04a019ae6aaf6ca33a97664519550e1abe280b
|
@@ -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
|
@@ -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
@@ -214,6 +214,12 @@ module Metanorma
|
|
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")
|
@@ -75,6 +75,7 @@ module Metanorma
|
|
75
75
|
/\n:(?<hier_assets>hierarchical-assets:[^\n]*)\n/ =~ header
|
76
76
|
/\n:(?<use_xinclude>use-xinclude:[^\n]*)\n/ =~ header
|
77
77
|
/\n:(?<break_up>break-up-urls-in-tables:[^\n]*)\n/ =~ header
|
78
|
+
/\n:suppress-asciimath-dup: (?<suppress_asciimath_dup>[^\n]+)\n/ =~ header
|
78
79
|
|
79
80
|
defined?(hier_assets) and
|
80
81
|
hier_assets = empty_attr(hier_assets, "hierarchical-assets")
|
@@ -83,11 +84,12 @@ module Metanorma
|
|
83
84
|
defined?(break_up) and
|
84
85
|
break_up = empty_attr(break_up, "break-up-urls-in-tables")
|
85
86
|
ret.merge(
|
86
|
-
datauriimage: defined?(datauriimage) ? datauriimage != "false" :
|
87
|
+
datauriimage: defined?(datauriimage) ? datauriimage != "false" : true,
|
88
|
+
suppressasciimathdup: defined?(suppress_asciimath_dup) ? suppress_asciimath_dup != "false" : nil,
|
87
89
|
hierarchical_assets: defined?(hier_assets) ? hier_assets : nil,
|
88
90
|
use_xinclude: defined?(use_xinclude) ? use_xinclude : nil,
|
89
91
|
break_up_urls_in_tables: defined?(break_up) ? break_up : nil,
|
90
|
-
).
|
92
|
+
).compact
|
91
93
|
end
|
92
94
|
end
|
93
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.0
|
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-10-25 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
|