metanorma 2.1.4 → 2.2.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/.rubocop.yml +4 -1
- data/lib/metanorma/collection/collection.rb +10 -4
- data/lib/metanorma/collection/config/config.rb +21 -0
- data/lib/metanorma/collection/config/manifest.rb +4 -1
- data/lib/metanorma/collection/document/document.rb +2 -0
- data/lib/metanorma/collection/filelookup/filelookup.rb +15 -6
- data/lib/metanorma/collection/filelookup/filelookup_sectionsplit.rb +4 -3
- data/lib/metanorma/collection/manifest/manifest.rb +7 -11
- data/lib/metanorma/collection/renderer/fileparse.rb +12 -39
- data/lib/metanorma/collection/renderer/fileprocess.rb +26 -10
- data/lib/metanorma/collection/renderer/navigation.rb +1 -1
- data/lib/metanorma/collection/renderer/renderer.rb +14 -1
- data/lib/metanorma/collection/renderer/utils.rb +8 -10
- data/lib/metanorma/collection/sectionsplit/collection.rb +1 -0
- data/lib/metanorma/collection/sectionsplit/sectionsplit.rb +84 -49
- data/lib/metanorma/collection/util/util.rb +24 -11
- data/lib/metanorma/collection/xrefprocess/xrefprocess.rb +2 -3
- data/lib/metanorma/compile/assets/icc-boilerplate.adoc +41 -0
- data/lib/metanorma/compile/compile.rb +148 -172
- data/lib/metanorma/compile/compile_options.rb +108 -82
- data/lib/metanorma/compile/extract.rb +76 -56
- data/lib/metanorma/compile/flavor.rb +54 -0
- data/lib/metanorma/compile/output_filename.rb +75 -0
- data/lib/metanorma/compile/output_filename_config.rb +27 -0
- data/lib/metanorma/compile/relaton_drop.rb +56 -0
- data/lib/metanorma/compile/render.rb +178 -0
- data/lib/metanorma/compile/validator.rb +26 -0
- data/lib/metanorma/compile/writeable.rb +12 -0
- data/lib/metanorma/input/asciidoc.rb +13 -6
- data/lib/metanorma/registry/registry.rb +11 -8
- data/lib/metanorma/version.rb +1 -1
- data/metanorma.gemspec +2 -1
- metadata +24 -3
- data/lib/metanorma/compile/compile_validate.rb +0 -68
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: af06733dd8691111633e6309c85ebfa069baa2edf16cbd7e8458a17ad34d4b2a
|
|
4
|
+
data.tar.gz: e924bb9b298cc37c2cebef6f8d9251ae3979e9cd9b537539057a5ade07e11c88
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 29499feb91dd56f4fe6f281f885263c897fb555a9905ce3a32b56d175199b520e9066041ff96489d5221302c259a08bf0d3c07bde19a232b3893d79a0bde747b
|
|
7
|
+
data.tar.gz: 717f1409b88dfc565393c71cddb0fda604e062d38e80b45c470dc06957ac5e7cf2f5adfd7ef7083666aeb4f7f7b6356fcbc95014bb2e9091c9c927232d7c225f
|
data/.rubocop.yml
CHANGED
|
@@ -92,15 +92,22 @@ module Metanorma
|
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
def render(opts)
|
|
95
|
-
|
|
95
|
+
opts[:format].nil? || opts[:format].empty? and
|
|
96
96
|
opts[:format] = @format || [:html]
|
|
97
|
-
end
|
|
98
97
|
opts[:log] = @log
|
|
99
98
|
opts[:flavor] = @flavor
|
|
99
|
+
output_folder(opts)
|
|
100
100
|
::Metanorma::Collection::Renderer.render self, opts
|
|
101
101
|
clean_exit
|
|
102
102
|
end
|
|
103
103
|
|
|
104
|
+
def output_folder(opts)
|
|
105
|
+
opts[:output_folder] ||= config.output_folder
|
|
106
|
+
opts[:output_folder] && !Pathname.new(opts[:output_folder]).absolute? and
|
|
107
|
+
opts[:output_folder] = File.join(@dirname, opts[:output_folder])
|
|
108
|
+
warn opts[:output_folder]
|
|
109
|
+
end
|
|
110
|
+
|
|
104
111
|
# @return [String, nil]
|
|
105
112
|
attr_reader :prefatory, :final
|
|
106
113
|
|
|
@@ -165,7 +172,7 @@ module Metanorma
|
|
|
165
172
|
def fetch_flavor
|
|
166
173
|
docid = @bibdata.docidentifier.first or return
|
|
167
174
|
f = docid.type.downcase || docid.id.sub(/\s.*$/, "").downcase or return
|
|
168
|
-
require ::Metanorma::Compile.new.
|
|
175
|
+
require ::Metanorma::Compile.new.stdtype2flavor_gem(f)
|
|
169
176
|
f
|
|
170
177
|
rescue LoadError
|
|
171
178
|
nil
|
|
@@ -216,7 +223,6 @@ module Metanorma
|
|
|
216
223
|
def resolve_fileref(ref_folder, fileref)
|
|
217
224
|
warn ref_folder
|
|
218
225
|
warn fileref
|
|
219
|
-
#require "debug"; binding.b
|
|
220
226
|
unless @fileref_resolver
|
|
221
227
|
(Pathname.new fileref).absolute? or
|
|
222
228
|
fileref = File.join(ref_folder, fileref)
|
|
@@ -124,6 +124,27 @@ module Metanorma
|
|
|
124
124
|
end
|
|
125
125
|
end
|
|
126
126
|
|
|
127
|
+
def self.flavor_from_yaml(yaml)
|
|
128
|
+
yaml["directives"]&.detect do |x|
|
|
129
|
+
x.is_a?(Hash) && x.has_key?("flavor")
|
|
130
|
+
end&.dig("flavor")&.upcase
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def self.flavor_to_bibdata(file)
|
|
134
|
+
# propagate flavor from directives to bibdata
|
|
135
|
+
yaml = YAML.safe_load(file)
|
|
136
|
+
flavor = flavor_from_yaml(yaml) or return file
|
|
137
|
+
yaml["bibdata"] or return file
|
|
138
|
+
yaml["bibdata"]["ext"] ||= {}
|
|
139
|
+
yaml["bibdata"]["ext"]["flavor"] ||= flavor
|
|
140
|
+
yaml.to_yaml
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def self.from_yaml(file)
|
|
144
|
+
file = flavor_to_bibdata(file)
|
|
145
|
+
super
|
|
146
|
+
end
|
|
147
|
+
|
|
127
148
|
include Converters
|
|
128
149
|
end
|
|
129
150
|
end
|
|
@@ -13,7 +13,7 @@ module Metanorma
|
|
|
13
13
|
|
|
14
14
|
class Manifest < ::Lutaml::Model::Serializable
|
|
15
15
|
attribute :identifier, :string,
|
|
16
|
-
|
|
16
|
+
default: -> { UUIDTools::UUID.random_create.to_s }
|
|
17
17
|
attribute :id, :string
|
|
18
18
|
attribute :bibdata, Bibdata
|
|
19
19
|
attribute :type, :string
|
|
@@ -25,6 +25,7 @@ module Metanorma
|
|
|
25
25
|
attribute :index, :boolean, default: -> { true }
|
|
26
26
|
attribute :entry, Manifest, collection: true
|
|
27
27
|
attribute :file, :string
|
|
28
|
+
attribute :format, :string, collection: true
|
|
28
29
|
|
|
29
30
|
yaml do
|
|
30
31
|
map "identifier", to: :identifier
|
|
@@ -46,6 +47,7 @@ module Metanorma
|
|
|
46
47
|
with: { from: :docref_from_yaml, to: :nop_to_yaml }
|
|
47
48
|
map "bibdata", to: :bibdata, with: { from: :bibdata_from_yaml,
|
|
48
49
|
to: :bibdata_to_yaml }
|
|
50
|
+
map "format", to: :format, render_default: true
|
|
49
51
|
end
|
|
50
52
|
|
|
51
53
|
xml do
|
|
@@ -59,6 +61,7 @@ module Metanorma
|
|
|
59
61
|
map_element "identifier", to: :identifier, render_default: true
|
|
60
62
|
map_element "type", to: :type
|
|
61
63
|
map_element "title", to: :title
|
|
64
|
+
map_element "format", to: :format
|
|
62
65
|
map_element "bibdata", to: :bibdata, with: { from: :bibdata_from_xml,
|
|
63
66
|
to: :bibdata_to_xml }
|
|
64
67
|
map_element "entry", to: :entry
|
|
@@ -18,22 +18,31 @@ module Metanorma
|
|
|
18
18
|
@parent = parent
|
|
19
19
|
@xml = parent.xml
|
|
20
20
|
@isodoc = parent.isodoc
|
|
21
|
+
@isodoc_presxml = parent.isodoc_presxml
|
|
21
22
|
@path = path
|
|
22
23
|
@compile = parent.compile
|
|
23
24
|
@documents = parent.documents
|
|
24
25
|
@files_to_delete = []
|
|
25
26
|
@disambig = Util::DisambigFiles.new
|
|
26
27
|
@manifest = parent.manifest
|
|
27
|
-
read_files(@manifest.entry)
|
|
28
|
+
read_files(@manifest.entry, parent.manifest)
|
|
29
|
+
#warn pp @files
|
|
28
30
|
end
|
|
29
31
|
|
|
30
|
-
def read_files(entries)
|
|
32
|
+
def read_files(entries, parent)
|
|
31
33
|
Array(entries).each do |e|
|
|
34
|
+
derive_format(e, parent)
|
|
32
35
|
e.file and read_file(e)
|
|
33
|
-
read_files(e.entry)
|
|
36
|
+
read_files(e.entry, e)
|
|
34
37
|
end
|
|
35
38
|
end
|
|
36
39
|
|
|
40
|
+
def derive_format(entry, parent)
|
|
41
|
+
entry.attachment and return
|
|
42
|
+
entry.format ||= parent.format || %w(xml presentation html)
|
|
43
|
+
entry.format |= ["xml", "presentation"]
|
|
44
|
+
end
|
|
45
|
+
|
|
37
46
|
def read_file(manifest)
|
|
38
47
|
i, k = read_file_idents(manifest)
|
|
39
48
|
entry = file_entry(manifest, k) or return
|
|
@@ -97,7 +106,8 @@ module Metanorma
|
|
|
97
106
|
abs = @documents[Util::key identifier].file
|
|
98
107
|
ret = if ref.file
|
|
99
108
|
{ type: "fileref", ref: abs, rel_path: ref.file, url: ref.url,
|
|
100
|
-
out_path: output_file_path(ref)
|
|
109
|
+
out_path: output_file_path(ref),
|
|
110
|
+
format: ref.format&.map(&:to_sym) }.compact
|
|
101
111
|
else { type: "id", ref: ref.id }
|
|
102
112
|
end
|
|
103
113
|
file_entry_copy(ref, ret)
|
|
@@ -122,7 +132,7 @@ module Metanorma
|
|
|
122
132
|
|
|
123
133
|
def add_document_suffix(identifier, doc)
|
|
124
134
|
document_suffix = Metanorma::Utils::to_ncname(identifier)
|
|
125
|
-
|
|
135
|
+
Util::anchor_id_attributes.each do |(tag_name, attr_name)|
|
|
126
136
|
Util::add_suffix_to_attrs(doc, document_suffix, tag_name, attr_name,
|
|
127
137
|
@isodoc)
|
|
128
138
|
end
|
|
@@ -221,7 +231,6 @@ module Metanorma
|
|
|
221
231
|
ret = {}
|
|
222
232
|
xml.traverse do |x|
|
|
223
233
|
x.text? and next
|
|
224
|
-
/^semantic__/.match?(x.name) and next
|
|
225
234
|
x["id"] and ret[x["id"]] = true
|
|
226
235
|
end
|
|
227
236
|
ret
|
|
@@ -89,7 +89,7 @@ module Metanorma
|
|
|
89
89
|
m = { parentid: key, presentationxml: true, type: "fileref",
|
|
90
90
|
rel_path: file[:url], out_path: File.basename(file[:url]),
|
|
91
91
|
anchors: anchors, anchors_lookup: anchors_lookup(anchors),
|
|
92
|
-
ids: read_ids(xml),
|
|
92
|
+
ids: read_ids(xml), format: @files[key][:format],
|
|
93
93
|
sectionsplit_output: true, indirect_key: @sectionsplit.key,
|
|
94
94
|
bibdata: @files[key][:bibdata], ref: presfile }
|
|
95
95
|
m[:bare] = true unless idx.zero?
|
|
@@ -110,8 +110,9 @@ module Metanorma
|
|
|
110
110
|
@sectionsplit = ::Metanorma::Collection::Sectionsplit
|
|
111
111
|
.new(input: file, base: @files[ident][:out_path],
|
|
112
112
|
dir: File.dirname(file), output: @files[ident][:out_path],
|
|
113
|
-
compile_opts: @parent.compile_options,
|
|
114
|
-
fileslookup: self,
|
|
113
|
+
compile_opts: @parent.compile_options, ident: ident,
|
|
114
|
+
fileslookup: self, isodoc: @isodoc,
|
|
115
|
+
isodoc_presxml: @isodoc_presxml,
|
|
115
116
|
document_suffix: @files[ident][:document_suffix])
|
|
116
117
|
coll = @sectionsplit.sectionsplit.sort_by { |f| f[:order] }
|
|
117
118
|
xml = Nokogiri::XML(File.read(file, encoding: "UTF-8"), &:huge)
|
|
@@ -96,7 +96,6 @@ module Metanorma
|
|
|
96
96
|
|
|
97
97
|
def manifest_filexist(config)
|
|
98
98
|
if config.file
|
|
99
|
-
#require "debug"; binding.b
|
|
100
99
|
file = @collection.class.resolve_fileref(@dir, config.file)
|
|
101
100
|
@collection.class.check_file_existence(file)
|
|
102
101
|
config.file = Pathname.new(file).relative_path_from(Pathname.new(@dir))
|
|
@@ -111,7 +110,6 @@ module Metanorma
|
|
|
111
110
|
currdir = dir
|
|
112
111
|
/\.ya?ml$/.match?(e.file) and
|
|
113
112
|
currdir = manifest_expand_yaml_entry(e, dir)
|
|
114
|
-
#require "debug"; binding.b
|
|
115
113
|
manifest_expand_yaml(e, currdir)
|
|
116
114
|
end
|
|
117
115
|
config
|
|
@@ -122,10 +120,8 @@ module Metanorma
|
|
|
122
120
|
currdir = File.dirname(f)
|
|
123
121
|
@collection.class.check_file_existence(f)
|
|
124
122
|
entry.file = nil
|
|
125
|
-
#require 'debug'; binding.b
|
|
126
123
|
entry.entry = ::Metanorma::Collection::Config::Config.from_yaml(File.read(f)).manifest
|
|
127
124
|
if currdir != dir
|
|
128
|
-
#require "debug"; binding.b
|
|
129
125
|
prefix = Pathname.new(currdir).relative_path_from(Pathname.new(dir))
|
|
130
126
|
update_filepaths(entry.entry, prefix.to_s)
|
|
131
127
|
end
|
|
@@ -133,10 +129,9 @@ module Metanorma
|
|
|
133
129
|
end
|
|
134
130
|
|
|
135
131
|
def update_filepaths(entry, prefix)
|
|
136
|
-
#require "debug"; binding.b
|
|
137
132
|
entry.file && !(Pathname.new entry.file).absolute? and
|
|
138
133
|
entry.file = File.join(prefix, entry.file)
|
|
139
|
-
entry
|
|
134
|
+
entry&.entry&.each do |f|
|
|
140
135
|
update_filepaths(f, prefix)
|
|
141
136
|
end
|
|
142
137
|
end
|
|
@@ -170,18 +165,19 @@ module Metanorma
|
|
|
170
165
|
f = (Pathname.new file).absolute? ? file : File.join(@dir, file)
|
|
171
166
|
File.exist?(f) or raise AdocFileNotFoundException.new "#{f} not found!"
|
|
172
167
|
compile_adoc_file?(file) or return
|
|
173
|
-
::Metanorma::Util.log("[metanorma] Info: Compiling #{f}...", :
|
|
168
|
+
::Metanorma::Util.log("[metanorma] Info: Compiling #{f}...", :warning)
|
|
174
169
|
::Metanorma::Compile.new
|
|
175
170
|
.compile(f, agree_to_terms: true, install_fonts: false,
|
|
176
171
|
extension_keys: [:xml])
|
|
177
|
-
::Metanorma::Util.log("[metanorma] Info: Compiling #{f}...done!", :
|
|
172
|
+
::Metanorma::Util.log("[metanorma] Info: Compiling #{f}...done!", :warning)
|
|
178
173
|
end
|
|
179
174
|
|
|
180
175
|
def compile_adoc_file?(file)
|
|
176
|
+
!File.exist?(file.sub(/\.adoc$/, ".xml")) and return true
|
|
181
177
|
@collection.directives.detect do |d|
|
|
182
|
-
d.key == "recompile-xml"
|
|
183
|
-
end and return
|
|
184
|
-
|
|
178
|
+
d.key == "recompile-xml" && d.value == "false"
|
|
179
|
+
end and return false
|
|
180
|
+
true
|
|
185
181
|
end
|
|
186
182
|
|
|
187
183
|
def documents(mnf = @config)
|
|
@@ -16,8 +16,6 @@ module Metanorma
|
|
|
16
16
|
# @return [String] XML content
|
|
17
17
|
def update_xrefs(file, docid, internal_refs)
|
|
18
18
|
xml, sso = update_xrefs_prep(file, docid)
|
|
19
|
-
#require "debug"; binding.b if /This document is also unrelated/.match?(xml.to_xml)
|
|
20
|
-
#warn (/fmt-title/.match?(xml.to_xml) ? "*** PRESENTATION" : "*** SEMANTIC")
|
|
21
19
|
@nested || sso or
|
|
22
20
|
Metanorma::Collection::XrefProcess::xref_process(xml, xml, nil, docid,
|
|
23
21
|
@isodoc, sso)
|
|
@@ -26,7 +24,7 @@ module Metanorma
|
|
|
26
24
|
@files.add_document_suffix(docid, xml)
|
|
27
25
|
@nested or update_sectionsplit_refs_to_docs(xml, internal_refs, sso)
|
|
28
26
|
update_direct_refs_to_docs(xml, docid, sso)
|
|
29
|
-
hide_refs(xml)
|
|
27
|
+
::Metanorma::Collection::Util::hide_refs(xml)
|
|
30
28
|
sso and eref2link(xml, sso)
|
|
31
29
|
@nested or svgmap_resolve(xml, docid, sso)
|
|
32
30
|
xml.to_xml
|
|
@@ -109,7 +107,6 @@ module Metanorma
|
|
|
109
107
|
else no_anchor[k] << e end
|
|
110
108
|
end
|
|
111
109
|
end
|
|
112
|
-
#require "debug"; binding.b
|
|
113
110
|
[erefs, no_anchor, anchors, Util::gather_bibitemids(docxml, presxml)]
|
|
114
111
|
end
|
|
115
112
|
|
|
@@ -128,8 +125,9 @@ module Metanorma
|
|
|
128
125
|
|
|
129
126
|
# Resolve erefs to a container of ids in another doc,
|
|
130
127
|
# to an anchor eref (direct link)
|
|
131
|
-
def update_indirect_refs_to_docs(docxml,
|
|
132
|
-
bib, erefs, doc_suffix, doc_type, f = update_indirect_refs_prep(docxml,
|
|
128
|
+
def update_indirect_refs_to_docs(docxml, _docid, internal_refs, presxml)
|
|
129
|
+
bib, erefs, doc_suffix, doc_type, f = update_indirect_refs_prep(docxml,
|
|
130
|
+
presxml)
|
|
133
131
|
internal_refs.each do |schema, ids|
|
|
134
132
|
add_suffix = doc_suffix && doc_type && doc_type != schema
|
|
135
133
|
ids.each do |id, file|
|
|
@@ -149,37 +147,15 @@ module Metanorma
|
|
|
149
147
|
docxml.root["document_suffix"], docxml.root["type"], {}]
|
|
150
148
|
end
|
|
151
149
|
|
|
152
|
-
# KILL
|
|
153
|
-
def indirect_ref_key(schema, id, doc_suffix, doc_type)
|
|
154
|
-
/^#{schema}_/.match?(id) and return id
|
|
155
|
-
key = [schema, id, doc_suffix, doc_type].join("::")
|
|
156
|
-
x = @indirect_keys[key] and return x
|
|
157
|
-
ret = "#{schema}_#{id}"
|
|
158
|
-
doc_suffix && doc_type && doc_type != schema and
|
|
159
|
-
ret = "#{ret}_#{doc_suffix}"
|
|
160
|
-
@indirect_keys[key] = ret
|
|
161
|
-
ret
|
|
162
|
-
end
|
|
163
|
-
|
|
164
150
|
def indirect_ref_key(schema, id, doc_suffix, add_suffix)
|
|
165
151
|
/^#{schema}_/.match?(id) and return id
|
|
166
|
-
#key = "#{schema}_#{id}"
|
|
167
152
|
x = @indirect_keys.dig(schema, id) and return x
|
|
168
153
|
@indirect_keys[schema] ||= {}
|
|
169
154
|
@indirect_keys[schema][id] = if add_suffix
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
# KILL
|
|
177
|
-
def indirect_ref_keyx(schema, id, doc_suffix, doc_type)
|
|
178
|
-
/^#{schema}_/.match?(id) and return id
|
|
179
|
-
ret = "#{schema}_#{id}"
|
|
180
|
-
doc_suffix && doc_type && doc_type != schema and
|
|
181
|
-
ret = "#{ret}_#{doc_suffix}"
|
|
182
|
-
ret
|
|
155
|
+
"#{schema}_#{id}_#{doc_suffix}"
|
|
156
|
+
else
|
|
157
|
+
"#{schema}_#{id}"
|
|
158
|
+
end
|
|
183
159
|
end
|
|
184
160
|
|
|
185
161
|
def update_indirect_refs_to_docs1(filec, key, file, bibitems, erefs)
|
|
@@ -196,13 +172,10 @@ module Metanorma
|
|
|
196
172
|
parentid and file = "#{parentid}_#{file}"
|
|
197
173
|
existing = a.text
|
|
198
174
|
anchor = if url then existing
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
@indirect_keys[existing] ||= {}
|
|
204
|
-
@indirect_keys[existing][file] ||= Metanorma::Utils::to_ncname("#{existing}_#{file}")
|
|
205
|
-
end
|
|
175
|
+
else
|
|
176
|
+
@indirect_keys[existing] ||= {}
|
|
177
|
+
@indirect_keys[existing][file] ||= Metanorma::Utils::to_ncname("#{existing}_#{file}")
|
|
178
|
+
end
|
|
206
179
|
@updated_anchors[existing] or a.children = anchor
|
|
207
180
|
@updated_anchors[anchor] = true
|
|
208
181
|
end
|
|
@@ -11,15 +11,16 @@ module Metanorma
|
|
|
11
11
|
# warn "metanorma compile -x html #{f.path}"
|
|
12
12
|
def file_compile(file, filename, identifier)
|
|
13
13
|
@files.get(identifier, :sectionsplit) and return
|
|
14
|
+
#require "debug"; binding.b
|
|
14
15
|
opts = {
|
|
15
16
|
format: :asciidoc,
|
|
16
|
-
extension_keys: @format,
|
|
17
|
+
extension_keys: @files.get(identifier, :format),
|
|
17
18
|
output_dir: @outdir,
|
|
18
19
|
type: @flavor,
|
|
19
20
|
}.merge(compile_options_update(identifier))
|
|
20
21
|
@compile.compile file, opts
|
|
21
22
|
@files.set(identifier, :outputs, {})
|
|
22
|
-
file_compile_formats(filename, identifier)
|
|
23
|
+
file_compile_formats(filename, identifier, opts)
|
|
23
24
|
end
|
|
24
25
|
|
|
25
26
|
def compile_options_update(identifier)
|
|
@@ -34,19 +35,34 @@ module Metanorma
|
|
|
34
35
|
ret
|
|
35
36
|
end
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
=begin
|
|
39
|
+
def allowed_extension_keys
|
|
40
|
+
ret = @format.dup
|
|
41
|
+
@directives.detect { |d| d.key == "individual-pdf" } or
|
|
42
|
+
ret.delete(:pdf)
|
|
43
|
+
@directives.detect { |d| d.key == "individual-doc" } or
|
|
44
|
+
ret.delete(:doc)
|
|
45
|
+
ret
|
|
46
|
+
end
|
|
47
|
+
=end
|
|
48
|
+
|
|
49
|
+
def file_compile_formats(filename, identifier, opts)
|
|
38
50
|
f = @files.get(identifier, :outputs)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
fn = File.basename(filename).sub(/(?<=\.)[^.]+$/, ext.to_s)
|
|
44
|
-
(/html$/.match?(ext) && @files.get(identifier, :sectionsplit)) or
|
|
45
|
-
f[e] = File.join(@outdir, fn)
|
|
51
|
+
format = opts[:extension_keys]
|
|
52
|
+
concatenate_presentation?({ format: format }) and format << :presentation
|
|
53
|
+
format.each do |e|
|
|
54
|
+
file_compile_format(filename, identifier, e, f)
|
|
46
55
|
end
|
|
47
56
|
@files.set(identifier, :outputs, f)
|
|
48
57
|
end
|
|
49
58
|
|
|
59
|
+
def file_compile_format(filename, identifier, format, output_formats)
|
|
60
|
+
ext = @compile.processor.output_formats[format]
|
|
61
|
+
fn = File.basename(filename).sub(/(?<=\.)[^.]+$/, ext.to_s)
|
|
62
|
+
(/html$/.match?(ext) && @files.get(identifier, :sectionsplit)) or
|
|
63
|
+
output_formats[format] = File.join(@outdir, fn)
|
|
64
|
+
end
|
|
65
|
+
|
|
50
66
|
def copy_file_to_dest(identifier)
|
|
51
67
|
out = Pathname.new(@files.get(identifier, :out_path)).cleanpath
|
|
52
68
|
out.absolute? and
|
|
@@ -15,7 +15,7 @@ module Metanorma
|
|
|
15
15
|
class Renderer
|
|
16
16
|
FORMATS = %i[html xml doc pdf].freeze
|
|
17
17
|
|
|
18
|
-
attr_accessor :isodoc, :nested
|
|
18
|
+
attr_accessor :isodoc, :isodoc_presxml, :nested
|
|
19
19
|
attr_reader :xml, :compile, :compile_options, :documents, :outdir,
|
|
20
20
|
:manifest
|
|
21
21
|
|
|
@@ -45,6 +45,8 @@ module Metanorma
|
|
|
45
45
|
|
|
46
46
|
# output processor for flavour
|
|
47
47
|
@isodoc = Util::isodoc_create(@flavor, @lang, @script, @xml)
|
|
48
|
+
@isodoc_presxml = Util::isodoc_create(@flavor, @lang, @script, @xml,
|
|
49
|
+
presxml: true)
|
|
48
50
|
@outdir = dir_name_cleanse(options[:output_folder])
|
|
49
51
|
@coverpage = options[:coverpage] || collection.coverpage
|
|
50
52
|
@format = ::Metanorma::Util.sort_extensions_execution(options[:format])
|
|
@@ -91,12 +93,22 @@ module Metanorma
|
|
|
91
93
|
warn "\n\n\n\n\nRender Init: #{DateTime.now.strftime('%H:%M:%S')}"
|
|
92
94
|
cr = new(col, File.dirname(col.file), options)
|
|
93
95
|
cr.files
|
|
96
|
+
cr.rxl(options)
|
|
94
97
|
cr.concatenate(col, options)
|
|
95
98
|
options[:format]&.include?(:html) and cr.coverpage
|
|
96
99
|
cr.flush_files
|
|
97
100
|
cr
|
|
98
101
|
end
|
|
99
102
|
|
|
103
|
+
def rxl(options)
|
|
104
|
+
@bibdata or return
|
|
105
|
+
options[:site_generate] and options[:format] << :xml
|
|
106
|
+
options[:format].include?(:rxl) or return
|
|
107
|
+
File.open(File.join(@outdir, "collection.rxl"), "w:UTF-8") do |f|
|
|
108
|
+
f.write(@bibdata.to_xml)
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
100
112
|
def concatenate(col, options)
|
|
101
113
|
warn "\n\n\n\n\nConcatenate: #{DateTime.now.strftime('%H:%M:%S')}"
|
|
102
114
|
concatenate_presentation?(options) and
|
|
@@ -112,6 +124,7 @@ module Metanorma
|
|
|
112
124
|
end
|
|
113
125
|
|
|
114
126
|
def concatenate_prep(col, options)
|
|
127
|
+
warn options[:format]
|
|
115
128
|
%i(xml presentation).each do |e|
|
|
116
129
|
options[:format].include?(e) or next
|
|
117
130
|
ext = e == :presentation ? "presentation.xml" : e.to_s
|
|
@@ -12,14 +12,19 @@ module Metanorma
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def dup_bibitem(docid, bib)
|
|
15
|
-
newbib = @files.get(docid, :bibdata)
|
|
15
|
+
newbib = deep_detached_clone(@files.get(docid, :bibdata))
|
|
16
16
|
newbib.name = "bibitem"
|
|
17
17
|
newbib["hidden"] = "true"
|
|
18
18
|
newbib&.at("./*[local-name() = 'ext']")&.remove
|
|
19
19
|
newbib["id"] = bib["id"]
|
|
20
|
+
bib["anchor"] and newbib["anchor"] = bib["anchor"]
|
|
20
21
|
newbib
|
|
21
22
|
end
|
|
22
23
|
|
|
24
|
+
def deep_detached_clone(node)
|
|
25
|
+
Nokogiri::XML(node.to_xml).root
|
|
26
|
+
end
|
|
27
|
+
|
|
23
28
|
def get_bibitem_docid(bib, identifier)
|
|
24
29
|
docid =
|
|
25
30
|
bib.at(ns("./docidentifier[@type = 'metanorma-collection']")) ||
|
|
@@ -33,17 +38,10 @@ module Metanorma
|
|
|
33
38
|
end
|
|
34
39
|
end
|
|
35
40
|
|
|
36
|
-
def hide_refs(docxml)
|
|
37
|
-
docxml.xpath(ns("//references[bibitem][not(./bibitem[not(@hidden) or " \
|
|
38
|
-
"@hidden = 'false'])]")).each do |f|
|
|
39
|
-
f["hidden"] = "true"
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
41
|
def new_hidden_ref(xmldoc)
|
|
44
42
|
ins = xmldoc.at(ns("bibliography")) or
|
|
45
43
|
xmldoc.root << "<bibliography/>" and ins = xmldoc.at(ns("bibliography"))
|
|
46
|
-
ins.at(ns("./
|
|
44
|
+
ins.at(ns("./references[@hidden = 'true']")) or
|
|
47
45
|
ins.add_child("<references hidden='true' normative='false'/>").first
|
|
48
46
|
end
|
|
49
47
|
|
|
@@ -77,7 +75,7 @@ module Metanorma
|
|
|
77
75
|
refs.each do |k, v|
|
|
78
76
|
url = @files.url(v, {})
|
|
79
77
|
ins << <<~XML
|
|
80
|
-
<bibitem id="#{k}">#{docid_xml(v)}<uri type='citation'>#{url}</uri></bibitem>
|
|
78
|
+
<bibitem id="#{k}" anchor="#{k}">#{docid_xml(v)}<uri type='citation'>#{url}</uri></bibitem>
|
|
81
79
|
XML
|
|
82
80
|
end
|
|
83
81
|
end
|