metanorma 2.0.4 → 2.0.5

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: 77856427b06326b7de35ad6782ffc5dbfe5331d9596d6df53a6af4c2bb681c81
4
- data.tar.gz: d63ffb87f0abe973ed040f8567c986d504792433a9b3d46f4618752f9f254f59
3
+ metadata.gz: e6416bb8205d8f155d6affc6566e882a0cc161b16e6753e0df39be3818fb369b
4
+ data.tar.gz: ecfc71eb0cecda61acd433a6a2a1512415375f69a38a9bb2c4f5f779d7ca38f4
5
5
  SHA512:
6
- metadata.gz: 9b252f5a1c35eee2d8c6689bd2c7501964e557401cfc3ba129e962faf0f0c5631feacd6f46fcc606ba973a8e8ac43f4078488d4726f81a3dce087e921db5cd28
7
- data.tar.gz: 66cece76fb4ac1fca9f5795f002f15d7062e73aac558056a5b02fe98a8de45d4fbd68d3c30ae7883b74f6ef6247d84840db4c1a9bfe64a0dc57e37ab70f7f861
6
+ metadata.gz: '0989d2e8fe2373f3e10733fca8e562839e6e264e3e45abc58782ab0d7ec5de8965fefc5a944154acab16968ed6292a42c000454791e782333b8cd47c5b51fce5'
7
+ data.tar.gz: 9004900c903b5cd1fe081cb4ca663a8caf0c0f2a4e016024accce10873261ccd3dacac953a1686a49d647cbe0d4f1914327304df9366ad3530a42078869cda84
@@ -104,7 +104,7 @@ module Metanorma
104
104
  %w(attachment sectionsplit index presentation-xml url
105
105
  bare-after-first).each do |s|
106
106
  ref.respond_to?(s.to_sym) and
107
- ret[s.gsub("-", "").to_sym] = ref.send(s)
107
+ ret[s.delete("-").to_sym] = ref.send(s)
108
108
  end
109
109
  end
110
110
 
@@ -19,6 +19,8 @@ module Metanorma
19
19
  s.each_with_index do |f1, i|
20
20
  add_section_split_instance(f1, manifest, key, i)
21
21
  end
22
+ a = add_section_split_attachments(sectionsplit_manifest, key) and
23
+ manifest["#{key}:attachments"] = a
22
24
  manifest["#{key}:index.html"] =
23
25
  add_section_split_cover(sectionsplit_manifest, key)
24
26
  end
@@ -49,6 +51,15 @@ module Metanorma
49
51
  docs > 1
50
52
  end
51
53
 
54
+ def add_section_split_attachments(manifest, ident)
55
+ attachments = @sectionsplit
56
+ .section_split_attachments(out: File.dirname(manifest.file))
57
+ attachments or return
58
+ @files[ident][:out_path] = attachments
59
+ { attachment: true, index: false, out_path: attachments,
60
+ ref: File.join(File.dirname(manifest.file), attachments) }
61
+ end
62
+
52
63
  def add_section_split_instance(file, manifest, key, idx)
53
64
  presfile, newkey, xml =
54
65
  add_section_split_instance_prep(file, key)
@@ -53,7 +53,7 @@ module Metanorma
53
53
  dest = File.join(@outdir, @disambig.source2dest_filename(out.to_s))
54
54
  FileUtils.mkdir_p(File.dirname(dest))
55
55
  source = @files.get(identifier, :ref)
56
- source != dest and FileUtils.cp source, dest
56
+ source != dest and FileUtils.cp_r source, dest, remove_destination: true
57
57
  end
58
58
 
59
59
  # process each file in the collection
@@ -34,7 +34,8 @@ module Metanorma
34
34
 
35
35
  def wrapping_doc_body(doc)
36
36
  doc.xpath(ns("//annex | //preface | //bibliography")).each(&:remove)
37
- s = doc.at(ns("//sections"))
37
+ s = doc.at(ns("//sections")) ||
38
+ doc.root.elements[-1].after("<sections/>").next
38
39
  repl = <<~BODY
39
40
  <sections><clause id='_collection_placeholder'><p>PLACEHOLDER</p></clause></sections>
40
41
  BODY
@@ -32,6 +32,7 @@ module Metanorma
32
32
  { format: %i(html), output_folder: "#{@output_filename}_collection",
33
33
  coverpage: File.join(@dir, "cover.html") }.merge(@compile_opts),
34
34
  )
35
+ section_split_attachments(out: "#{@output_filename}_collection")
35
36
  end
36
37
 
37
38
  def collection_manifest(filename, files, origxml, _presxml, dir)
@@ -71,8 +72,8 @@ module Metanorma
71
72
  @key = Metanorma::Collection::XrefProcess::xref_preprocess(xml, @isodoc)
72
73
  SPLITSECTIONS.each_with_object([]) do |n, ret|
73
74
  conflate_floatingtitles(xml.xpath(ns(n[0]))).each do |s|
74
- ret << sectionfile(xml, emptydoc(xml), "#{@base}.#{ret.size}", s,
75
- n[1])
75
+ ret << sectionfile(xml, emptydoc(xml, ret.size),
76
+ "#{@base}.#{ret.size}", s, n[1])
76
77
  end
77
78
  end
78
79
  end
@@ -111,6 +112,7 @@ module Metanorma
111
112
  type = xml.root.name.sub("-standard", "").to_sym
112
113
  sectionsplit_update_xrefs(xml)
113
114
  xml1 = sectionsplit_write_semxml(filename, xml)
115
+ @tmp_filename = xml1
114
116
  [xml1, type]
115
117
  end
116
118
 
@@ -133,13 +135,15 @@ module Metanorma
133
135
  outname
134
136
  end
135
137
 
136
- def emptydoc(xml)
138
+ def emptydoc(xml, ordinal)
137
139
  out = xml.dup
138
140
  out.xpath(
139
141
  ns("//preface | //sections | //annex | //bibliography/clause | " \
140
- "//bibliography/references[not(@hidden = 'true')] | //indexsect | " \
141
- "//colophon"),
142
+ "//bibliography/references[not(@hidden = 'true')] | " \
143
+ "//indexsect | //colophon"),
142
144
  ).each(&:remove)
145
+ ordinal.zero? or out.xpath(ns("//metanorma-ext//attachment"))
146
+ .each(&:remove) # keep only one copy of attachments
143
147
  out
144
148
  end
145
149
 
@@ -155,9 +159,7 @@ module Metanorma
155
159
  Metanorma::Collection::XrefProcess::xref_process(out, xml, @key,
156
160
  @ident, @isodoc)
157
161
  outname = "#{file}.xml"
158
- File.open(File.join(@splitdir, outname), "w:UTF-8") do |f|
159
- f.write(out)
160
- end
162
+ File.open(File.join(@splitdir, outname), "w:UTF-8") { |f| f.write(out) }
161
163
  outname
162
164
  end
163
165
 
@@ -173,7 +175,9 @@ module Metanorma
173
175
  title = section.at(ns("./title")) or return "[Untitled]"
174
176
  t = title.dup
175
177
  t.xpath(ns(".//tab | .//br")).each { |x| x.replace(" ") }
176
- t.xpath(ns(".//strong")).each { |x| x.replace(x.children) }
178
+ t.xpath(ns(".//bookmark")).each(&:remove)
179
+ t.xpath(ns(".//strong | .//span"))
180
+ .each { |x| x.replace(x.children) }
177
181
  t.children.to_xml
178
182
  end
179
183
 
@@ -208,10 +212,30 @@ module Metanorma
208
212
  .new(col, dir, output_folder: "#{ident}_collection",
209
213
  format: %i(html), coverpage: File.join(dir, "cover.html"))
210
214
  r.coverpage
215
+ section_split_cover1(ident, r, dir, _one_doc_coll)
216
+ end
217
+
218
+ def att_dir(file)
219
+ "_#{File.basename(file, '.*')}_attachments"
220
+ end
221
+
222
+ def section_split_attachments(out: nil)
223
+ attachments = att_dir(@tmp_filename)
224
+ File.directory?(attachments) or return
225
+ dir = out || File.dirname(@input_filename)
226
+ ret = File.join(dir, att_dir(@output_filename))
227
+ FileUtils.rm_rf ret
228
+ FileUtils.mv attachments, ret
229
+ File.basename(ret)
230
+ end
231
+
232
+ def section_split_cover1(ident, renderer, dir, _one_doc_coll)
211
233
  # filename = one_doc_coll ? "#{ident}_index.html" : "index.html"
212
- filename = File.basename("#{ident}_index.html") # ident can be a directory with YAML indirection
213
- FileUtils.mv File.join(r.outdir, "index.html"), File.join(dir, filename)
214
- FileUtils.rm_rf r.outdir
234
+ filename = File.basename("#{ident}_index.html")
235
+ # ident can be a directory with YAML indirection
236
+ FileUtils.mv File.join(renderer.outdir, "index.html"),
237
+ File.join(dir, filename)
238
+ FileUtils.rm_rf renderer.outdir
215
239
  filename
216
240
  end
217
241
  end
@@ -1,3 +1,3 @@
1
1
  module Metanorma
2
- VERSION = "2.0.4".freeze
2
+ VERSION = "2.0.5".freeze
3
3
  end
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: 2.0.4
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-02 00:00:00.000000000 Z
11
+ date: 2024-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor