metanorma 1.3.4 → 1.3.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c92210eec85835a4e8be4a85a1c1dbe84cc1b88163e0f3c9c9be136f0019cb6e
4
- data.tar.gz: 066d89b3df0a8865f52e3e70b257a1a4ce3c71eb9f8b6840a87b9046743536d1
3
+ metadata.gz: d8b82f79d4ce3a18564bd84c137faeca4daf763e2284464f390476fb881a0996
4
+ data.tar.gz: f6a33995af907243fd0ae9ebff3676467455f21cd502089da6599783b4ba4e86
5
5
  SHA512:
6
- metadata.gz: d23d488ab60995b4745184cc5a22aaaf1c9b24694186b8cfb0d7359ecaea1a999fef99dcc71c15944d5e9fbdd377f0739b35f79528f46071a7a701b512fd3108
7
- data.tar.gz: 70dd774b5b69a08661cacf0d2601b0a92cb45624848f23f6f3a397df02ef9c496ff44a64f1c1fc083d07bbfa8754921dafe6168d0472ab776cb1453b064313ce
6
+ metadata.gz: 484b71a094f6e23f5e512ffcbc8eac5bed0cd6d5b3fc6e952a28ce05e0e9eef3b64bff995692fd43f36b0c7888814b20318559aeeb0d9dee7900baf0847d95b8
7
+ data.tar.gz: 508757811e5a63b30b91d4353fdc2a983bfe269da85f39b9be50d0c6a904113965ae53c40052cd43fb38ee740c350b9922d114bfd21833383a525782d278f95c
@@ -16,7 +16,7 @@ jobs:
16
16
  strategy:
17
17
  fail-fast: false
18
18
  matrix:
19
- ruby: [ '3.0', '2.7', '2.6', '2.5', '2.4' ]
19
+ ruby: [ '3.0', '2.7', '2.6', '2.5' ]
20
20
  os: [ ubuntu-latest, windows-latest, macos-latest ]
21
21
  experimental: [ false ]
22
22
  steps:
data/.rubocop.yml CHANGED
@@ -7,4 +7,4 @@ inherit_from:
7
7
  # ...
8
8
 
9
9
  AllCops:
10
- TargetRubyVersion: 2.4
10
+ TargetRubyVersion: 2.5
data/Gemfile CHANGED
@@ -6,6 +6,6 @@ git_source(:github) { |repo| "https://github.com/#{repo}" }
6
6
 
7
7
  gemspec
8
8
 
9
- if File.exist? 'Gemfile.devel'
10
- eval File.read('Gemfile.devel'), nil, 'Gemfile.devel' # rubocop:disable Security/Eval
9
+ if File.exist? "Gemfile.devel"
10
+ eval File.read("Gemfile.devel"), nil, "Gemfile.devel" # rubocop:disable Security/Eval
11
11
  end
data/lib/metanorma.rb CHANGED
@@ -5,7 +5,6 @@ require "asciidoctor"
5
5
  require "metanorma/util"
6
6
  require "metanorma/config"
7
7
  require "metanorma/input"
8
- require "metanorma/output"
9
8
  require "metanorma/registry"
10
9
  require "metanorma/processor"
11
10
  require "metanorma/asciidoctor_extensions"
@@ -4,6 +4,7 @@ require "relaton"
4
4
  require "relaton/cli"
5
5
  require "metanorma/collection_manifest"
6
6
  require "metanorma-utils"
7
+ require_relative "util"
7
8
 
8
9
  module Metanorma
9
10
  # Metanorma collection of documents
@@ -18,6 +19,8 @@ module Metanorma
18
19
  # @return [Hash<String, Metanorma::Document>]
19
20
  attr_accessor :documents
20
21
 
22
+ attr_accessor :disambig
23
+
21
24
  # @param file [String] path to source file
22
25
  # @param directives [Array<String>] documents-inline to inject the XML into
23
26
  # the collection manifest; documents-external to keeps them outside
@@ -41,6 +44,7 @@ module Metanorma
41
44
  @prefatory = args[:prefatory]
42
45
  @final = args[:final]
43
46
  @log = Metanorma::Utils::Log.new
47
+ @disambig = Util::DisambigFiles.new
44
48
  end
45
49
 
46
50
  # rubocop:enable Metrics/AbcSize,Metrics/MethodLength
@@ -87,7 +91,9 @@ module Metanorma
87
91
  private
88
92
 
89
93
  def parse_xml(file)
90
- xml = Nokogiri::XML File.read(file, encoding: "UTF-8")
94
+ xml = Nokogiri::XML File.read(file, encoding: "UTF-8") do |config|
95
+ config.huge
96
+ end
91
97
  if (b = xml.at("/xmlns:metanorma-collection/xmlns:bibdata"))
92
98
  bd = Relaton::Cli.parse_xml b
93
99
  end
@@ -11,15 +11,21 @@ module Metanorma
11
11
  xrefs = @isodoc.xref_init(@lang, @script, @isodoc, @isodoc.i18n, {})
12
12
  xrefs.parse xml
13
13
  xrefs.get.each_with_object({}) do |(k, v), ret|
14
- ret[v[:type]] ||= {}
15
- index = if v[:container] || v[:label].nil? || v[:label].empty?
16
- UUIDTools::UUID.random_create.to_s
17
- else v[:label]
18
- end
19
- ret[v[:type]][index] = k
14
+ read_anchors1(k, v, ret)
20
15
  end
21
16
  end
22
17
 
18
+ def read_anchors1(key, val, ret)
19
+ val[:type] ||= "clause"
20
+ ret[val[:type]] ||= {}
21
+ index = if val[:container] || val[:label].nil? || val[:label].empty?
22
+ UUIDTools::UUID.random_create.to_s
23
+ else val[:label]
24
+ end
25
+ ret[val[:type]][index] = key
26
+ ret[val[:type]][val[:value]] = key if val[:value]
27
+ end
28
+
23
29
  # @param id [String]
24
30
  # @param read [Boolean]
25
31
  # @return [Array<String, nil>]
@@ -31,29 +37,36 @@ module Metanorma
31
37
 
32
38
  # @param bib [Nokogiri::XML::Element]
33
39
  # @param identifier [String]
34
- def update_bibitem(bib, identifier) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
35
- docid = bib&.at(ns("./docidentifier"))&.text
36
- unless @files[docid]
37
- error = "[metanorma] Cannot find crossreference to document #{docid} "\
38
- "in document #{identifier}."
39
- @log.add("Cross-References", nil, error)
40
- Util.log(error, :warning)
41
- return
42
- end
43
- id = bib["id"]
44
- newbib = bib.replace(@files[docid][:bibdata])
45
- newbib.name = "bibitem"
46
- newbib["id"] = id
47
- newbib["hidden"] = "true"
48
- newbib&.at(ns("./ext"))&.remove
40
+ def update_bibitem(bib, identifier) # rubocop:disable Metrics/AbcSize
41
+ docid = bib&.at(ns("./docidentifier"))&.children&.to_xml
42
+ return fail_update_bibitem(docid, identifier) unless @files[docid]
43
+
44
+ newbib = dup_bibitem(docid, bib)
45
+ bib.replace(newbib)
49
46
  _file, url = targetfile(@files[docid], relative: true, read: false,
50
- doc: !@files[docid][:attachment])
47
+ doc: !@files[docid][:attachment])
51
48
  uri_node = Nokogiri::XML::Node.new "uri", newbib
52
49
  uri_node[:type] = "citation"
53
50
  uri_node.content = url
54
51
  newbib.at(ns("./docidentifier")).previous = uri_node
55
52
  end
56
53
 
54
+ def fail_update_bibitem(docid, identifier)
55
+ error = "[metanorma] Cannot find crossreference to document #{docid} "\
56
+ "in document #{identifier}."
57
+ @log.add("Cross-References", nil, error)
58
+ Util.log(error, :warning)
59
+ end
60
+
61
+ def dup_bibitem(docid, bib)
62
+ newbib = @files[docid][:bibdata].dup
63
+ newbib.name = "bibitem"
64
+ newbib["hidden"] = "true"
65
+ newbib&.at("./*[local-name() = 'ext']")&.remove
66
+ newbib["id"] = bib["id"]
67
+ newbib
68
+ end
69
+
57
70
  # Resolves direct links to other files in collection
58
71
  # (repo(current-metanorma-collection/x),
59
72
  # and indirect links to other files in collection
@@ -64,12 +77,12 @@ module Metanorma
64
77
  # @param internal_refs [Hash{String=>Hash{String=>String}] schema name to anchor to filename
65
78
  # @return [String] XML content
66
79
  def update_xrefs(file, identifier, internal_refs)
67
- docxml = Nokogiri::XML(file)
80
+ docxml = Nokogiri::XML(file) { |config| config.huge }
68
81
  update_indirect_refs_to_docs(docxml, internal_refs)
69
82
  add_document_suffix(identifier, docxml)
70
83
  update_direct_refs_to_docs(docxml, identifier)
71
84
  svgmap_resolve(datauri_encode(docxml))
72
- docxml.xpath(ns("//references[not(./bibitem[not(@hidden) or "\
85
+ docxml.xpath(ns("//references[bibitem][not(./bibitem[not(@hidden) or "\
73
86
  "@hidden = 'false'])]")).each do |f|
74
87
  f["hidden"] = "true"
75
88
  end
@@ -103,12 +116,18 @@ module Metanorma
103
116
  # Preferably with anchor, and is a job to realise dynamic lookup
104
117
  # of localities.
105
118
  def update_direct_refs_to_docs(docxml, identifier)
119
+ erefs = docxml.xpath(ns("//eref"))
120
+ .each_with_object({ citeas: {}, bibitemid: {} }) do |i, m|
121
+ m[:citeas][i["citeas"]] = true
122
+ m[:bibitemid][i["bibitemid"]] = true
123
+ end
106
124
  docxml.xpath(ns("//bibitem[not(ancestor::bibitem)]")).each do |b|
107
125
  docid = b&.at(ns("./docidentifier[@type = 'repository']"))&.text
108
126
  next unless docid && %r{^current-metanorma-collection/}.match(docid)
109
127
 
110
128
  update_bibitem(b, identifier)
111
- update_anchors(b, docxml, docid)
129
+ docid = b&.at(ns("./docidentifier"))&.children&.to_xml or next
130
+ erefs[:citeas][docid] and update_anchors(b, docxml, docid)
112
131
  end
113
132
  end
114
133
 
@@ -125,6 +144,9 @@ module Metanorma
125
144
  def update_indirect_refs_to_docs1(docxml, schema, id, file)
126
145
  docxml.xpath(ns("//eref[@bibitemid = '#{schema}_#{id}']")).each do |e|
127
146
  e["citeas"] = file
147
+ if a = e.at(ns(".//locality[@type = 'anchor']/referenceFrom"))
148
+ a.children = "#{a.text}_#{Metanorma::Utils::to_ncname(file)}"
149
+ end
128
150
  end
129
151
  docid = docxml.at(ns("//bibitem[@id = '#{schema}_#{id}']/"\
130
152
  "docidentifier[@type = 'repository']")) or return
@@ -134,21 +156,19 @@ module Metanorma
134
156
 
135
157
  # update crossrefences to other documents, to include
136
158
  # disambiguating document suffix on id
137
- def update_anchors(bib, docxml, _id) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
138
- docid = bib&.at(ns("./docidentifier"))&.text
159
+ def update_anchors(bib, docxml, docid) # rubocop:disable Metrics/AbcSize
139
160
  docxml.xpath("//xmlns:eref[@citeas = '#{docid}']").each do |e|
140
- if @files[docid]
141
- update_anchor_loc(bib, e, docid)
161
+ if @files[docid] then update_anchor_loc(bib, e, docid)
142
162
  else
143
- e << "<strong>** Unresolved reference to document #{docid}, "\
144
- "id #{e['bibitemid']}</strong>"
163
+ e << "<strong>** Unresolved reference to document #{docid} "\
164
+ "from eref</strong>"
145
165
  end
146
166
  end
147
167
  end
148
168
 
149
- def update_anchor_loc(bib, e, docid)
150
- loc = e.at(ns(".//locality[@type = 'anchor']")) or
151
- return update_anchor_create_loc(bib, e, docid)
169
+ def update_anchor_loc(bib, eref, docid)
170
+ loc = eref.at(ns(".//locality[@type = 'anchor']")) or
171
+ return update_anchor_create_loc(bib, eref, docid)
152
172
  document_suffix = Metanorma::Utils::to_ncname(docid)
153
173
  ref = loc.at(ns("./referenceFrom")) || return
154
174
  anchor = "#{ref.text}_#{document_suffix}"
@@ -161,17 +181,14 @@ module Metanorma
161
181
 
162
182
  # if there is a crossref to another document, with no anchor, retrieve the
163
183
  # anchor given the locality, and insert it into the crossref
164
- def update_anchor_create_loc(bib, e, docid)
165
- ins = e.at(ns("./localityStack")) || return
184
+ def update_anchor_create_loc(_bib, eref, docid)
185
+ ins = eref.at(ns("./localityStack")) or return
166
186
  type = ins&.at(ns("./locality/@type"))&.text
187
+ type = "clause" if type == "annex"
167
188
  ref = ins&.at(ns("./locality/referenceFrom"))&.text
168
- (anchor = @files[docid][:anchors][type][ref]) || return
169
- ref_from = Nokogiri::XML::Node.new "referenceFrom", bib
170
- ref_from.content = anchor.sub(/^_/, "")
171
- locality = Nokogiri::XML::Node.new "locality", bib
172
- locality[:type] = "anchor"
173
- locality.add_child ref_from
174
- ins << locality
189
+ anchor = @files[docid][:anchors].dig(type, ref) or return
190
+ ins << "<locality type='anchor'><referenceFrom>#{anchor.sub(/^_/, '')}"\
191
+ "</referenceFrom></locality>"
175
192
  end
176
193
 
177
194
  # gather internal bibitem references
@@ -182,7 +199,7 @@ module Metanorma
182
199
  file, = targetfile(x, read: true)
183
200
  Nokogiri::XML(file)
184
201
  .xpath(ns("//bibitem[@type = 'internal']/"\
185
- "docidentifier[@type = 'repository']")).each do |d|
202
+ "docidentifier[@type = 'repository']")).each do |d|
186
203
  a = d.text.split(%r{/}, 2)
187
204
  a.size > 1 or next
188
205
  refs[a[0]] ||= {}
@@ -207,10 +224,11 @@ module Metanorma
207
224
 
208
225
  def locate_internal_refs1(refs, identifier, filedesc)
209
226
  file, _filename = targetfile(filedesc, read: true)
210
- docxml = Nokogiri::XML(file)
227
+ xml = Nokogiri::XML(file) { |config| config.huge }
228
+ t = xml.xpath("//*/@id").each_with_object({}) { |i, x| x[i.text] = true }
211
229
  refs.each do |schema, ids|
212
- ids.each_key do |id|
213
- n = docxml.at("//*[@id = '#{id}']") and
230
+ ids.keys.select { |id| t[id] }.each do |id|
231
+ n = xml.at("//*[@id = '#{id}']") and
214
232
  n.at("./ancestor-or-self::*[@type = '#{schema}']") and
215
233
  refs[schema][id] = identifier
216
234
  end
@@ -15,7 +15,7 @@ module Metanorma
15
15
  def read_files(path) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
16
16
  files = {}
17
17
  @xml.xpath(ns("//docref")).each do |d|
18
- identifier = d.at(ns("./identifier")).text
18
+ identifier = d.at(ns("./identifier")).children.to_xml
19
19
  files[identifier] = file_entry(d, identifier, path)
20
20
  if files[identifier][:attachment]
21
21
  files[identifier][:bibdata] = Metanorma::Document
@@ -27,22 +27,88 @@ module Metanorma
27
27
  files[identifier][:anchors] = read_anchors(xml)
28
28
  files[identifier][:bibdata] = xml.at(ns("//bibdata"))
29
29
  end
30
+ files[identifier][:bibitem] = files[identifier][:bibdata].dup
31
+ files[identifier][:bibitem].name = "bibitem"
32
+ files[identifier][:bibitem]["hidden"] = "true"
33
+ files[identifier][:bibitem]&.at("./*[local-name() = 'ext']")&.remove
30
34
  end
31
- files
35
+ add_section_split(files)
36
+ end
37
+
38
+ def add_section_split(files)
39
+ files.keys.each_with_object({}) do |k, m|
40
+ if files[k][:sectionsplit] == "true" && !files[k]["attachment"]
41
+ s, manifest = sectionsplit(files[k][:ref])
42
+ s.each_with_index do |f1, i|
43
+ add_section_split_instance(f1, m, k, i, files)
44
+ end
45
+ m["#{k}:index.html"] = add_section_split_cover(files, manifest, k)
46
+ end
47
+ m[k] = files[k]
48
+ end
49
+ end
50
+
51
+ def add_section_split_cover(files, manifest, ident)
52
+ cover = section_split_cover(manifest, ident)
53
+ files[ident][:out_path] = cover
54
+ { attachment: true, index: false, out_path: cover,
55
+ ref: File.join(File.dirname(manifest.file), cover) }
56
+ end
57
+
58
+ def section_split_cover(col, ident)
59
+ dir = File.dirname(col.file)
60
+ @compile.collection_setup(nil, dir)
61
+ CollectionRenderer.new(col, dir,
62
+ output_folder: "#{ident}_collection",
63
+ format: %i(html),
64
+ coverpage: File.join(dir, "cover.html")).coverpage
65
+ FileUtils.mv "#{ident}_collection/index.html",
66
+ File.join(dir, "#{ident}_index.html")
67
+ FileUtils.rm_rf "#{ident}_collection"
68
+ "#{ident}_index.html"
69
+ end
70
+
71
+ def add_section_split_instance(file, manifest, key, idx, files)
72
+ dir = File.dirname(files[key][:ref])
73
+ presfile = File.join(dir, File.basename(file[:url]))
74
+ manifest["#{key} #{file[:title]}"] =
75
+ { parentid: key, presentationxml: true, type: "fileref",
76
+ rel_path: file[:url], out_path: File.basename(file[:url]),
77
+ anchors: read_anchors(Nokogiri::XML(File.read(presfile))),
78
+ bibdata: files[key][:bibdata], ref: presfile }
79
+ manifest["#{key} #{file[:title]}"][:bare] = true unless idx.zero?
80
+ end
81
+
82
+ def sectionsplit(file)
83
+ @compile.compile(
84
+ file, { format: :asciidoc, extension_keys: [:presentation] }
85
+ .merge(@compile_options)
86
+ )
87
+ r = file.sub(/\.xml$/, ".presentation.xml")
88
+ xml = Nokogiri::XML(File.read(r))
89
+ s = @compile.sectionsplit(xml, File.basename(r), File.dirname(r))
90
+ .sort_by { |f| f[:order] }
91
+ [s, @compile.collection_manifest(File.basename(r), s, xml, nil,
92
+ File.dirname(r))]
32
93
  end
33
94
 
34
95
  # rel_path is the source file address, determined relative to the YAML.
35
96
  # out_path is the destination file address, with any references outside
36
97
  # the working directory (../../...) truncated
37
- def file_entry(docref, identifier, _path)
38
- ret = if docref["fileref"]
98
+ def file_entry(ref, identifier, _path)
99
+ out = ref["attachment"] ? ref["fileref"] : File.basename(ref["fileref"])
100
+ ret = if ref["fileref"]
39
101
  { type: "fileref", ref: @documents[identifier].file,
40
- rel_path: docref["fileref"],
41
- out_path: Util::source2dest_filename(docref["fileref"]) }
102
+ rel_path: ref["fileref"],
103
+ out_path: out }
42
104
  else
43
- { type: "id", ref: docref["id"] }
105
+ { type: "id", ref: ref["id"] }
44
106
  end
45
- ret[:attachment] = docref["attachment"] if docref["attachment"]
107
+ %i(attachment sectionsplit index).each do |s|
108
+ ret[s] = ref[s.to_s] if ref[s.to_s]
109
+ end
110
+ ret[:presentationxml] = ref["presentation-xml"] if ref["presentation-xml"]
111
+ ret[:bareafterfirst] = ref["bare-after-first"] if ref["bare-after-first"]
46
112
  ret
47
113
  end
48
114
 
@@ -74,9 +140,9 @@ module Metanorma
74
140
  # @return [Array<String, nil>]
75
141
  def targetfile(data, options)
76
142
  options = { read: false, doc: true, relative: false }.merge(options)
77
- path = options[:relative] ? data[:out_path] : data[:ref]
143
+ path = options[:relative] ? data[:rel_path] : data[:ref]
78
144
  if data[:type] == "fileref"
79
- ref_file path, options[:read], options[:doc]
145
+ ref_file path, data[:out_path], options[:read], options[:doc]
80
146
  else
81
147
  xml_file data[:id], options[:read]
82
148
  end
@@ -86,43 +152,77 @@ module Metanorma
86
152
  # @param read [Boolean]
87
153
  # @param doc [Boolean]
88
154
  # @return [Array<String, nil>]
89
- def ref_file(ref, read, doc)
155
+ def ref_file(ref, out, read, doc)
90
156
  file = File.read(ref, encoding: "utf-8") if read
91
- filename = ref.dup
157
+ filename = out.dup
92
158
  filename.sub!(/\.xml$/, ".html") if doc
93
159
  [file, filename]
94
160
  end
95
161
 
96
162
  # compile and output individual file in collection
163
+ # warn "metanorma compile -x html #{f.path}"
97
164
  def file_compile(file, filename, identifier)
98
- # warn "metanorma compile -x html #{f.path}"
99
- c = Compile.new
100
- c.compile file.path, { format: :asciidoc,
101
- extension_keys: @format }.merge(@compile_options)
165
+ return if @files[identifier][:sectionsplit] == "true"
166
+
167
+ @compile.compile file.path, { format: :asciidoc, extension_keys: @format }
168
+ .merge(compile_options(identifier))
102
169
  @files[identifier][:outputs] = {}
170
+ file_compile_formats(file, filename, identifier)
171
+ end
172
+
173
+ def compile_options(identifier)
174
+ ret = @compile_options.dup
175
+ Array(@directives).include?("presentation-xml") ||
176
+ @files[identifier][:presentationxml] and
177
+ ret.merge!(passthrough_presentation_xml: true)
178
+ @files[identifier][:sectionsplit] == "true" and
179
+ ret.merge!(sectionsplit: "true")
180
+ @files[identifier][:bare] == true and
181
+ ret.merge!(bare: true)
182
+ ret
183
+ end
184
+
185
+ def file_compile_formats(file, filename, identifier)
103
186
  @format.each do |e|
104
- ext = c.processor.output_formats[e]
105
- fn = File.basename(filename).sub(/(?<=\.)[^\.]+$/, ext.to_s)
106
- FileUtils.mv file.path.sub(/\.xml$/, ".#{ext}"), File.join(@outdir, fn)
107
- @files[identifier][:outputs][e] = File.join(@outdir, fn)
187
+ ext = @compile.processor.output_formats[e]
188
+ fn = File.basename(filename).sub(/(?<=\.)[^.]+$/, ext.to_s)
189
+ if /html$/.match?(ext) && @files[identifier][:sectionsplit]
190
+ # file_sectionsplit_copy(file, fn, identifier, ext, e)
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
+ end
108
196
  end
109
197
  end
110
198
 
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
+
111
208
  def copy_file_to_dest(fileref)
112
- _file, filename = targetfile(fileref, read: true, doc: false)
113
209
  dest = File.join(@outdir, fileref[:out_path])
114
210
  FileUtils.mkdir_p(File.dirname(dest))
115
- FileUtils.cp filename, dest
211
+ FileUtils.cp fileref[:ref], dest
116
212
  end
117
213
 
118
214
  # process each file in the collection
119
215
  # files are held in memory, and altered as postprocessing
120
216
  def files # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
217
+ warn "\n\n\n\n\nInternal Refs: #{DateTime.now.strftime('%H:%M:%S')}"
121
218
  internal_refs = locate_internal_refs
122
- @files.each do |identifier, x|
219
+ @files.each_with_index do |(identifier, x), i|
220
+ i.positive? && Array(@directives).include?("bare-after-first") and
221
+ @compile_options.merge!(bare: true)
123
222
  if x[:attachment] then copy_file_to_dest(x)
124
223
  else
125
224
  file, filename = targetfile(x, read: true)
225
+ warn "\n\n\n\n\nProcess #{filename}: #{DateTime.now.strftime('%H:%M:%S')}"
126
226
  file = update_xrefs(file, identifier, internal_refs)
127
227
  Tempfile.open(["collection", ".xml"], encoding: "utf-8") do |f|
128
228
  f.write(file)