metanorma 2.0.3 → 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: 5c79c55687d9f7906deff9b1c0e1b0ea0b34bc12bdc457ee50b8f2ae317379d5
4
- data.tar.gz: 9d4cb1f6ebbff8f9fef492db09a08e3b703d6abe370281eac70be19fd0cd0a74
3
+ metadata.gz: e6416bb8205d8f155d6affc6566e882a0cc161b16e6753e0df39be3818fb369b
4
+ data.tar.gz: ecfc71eb0cecda61acd433a6a2a1512415375f69a38a9bb2c4f5f779d7ca38f4
5
5
  SHA512:
6
- metadata.gz: 209ad8c6bbf50736898ad555ad681ada496848b0050aec7683ac166b9ae86d403c6454e7ac9bec805a0f90ab3f24e0c35ad59f7af9d0d1156e3f3a6465dad2c2
7
- data.tar.gz: f56c230c821be5f285e5bb8919ea6314664db0ff761bd16b0aaa434725ece3c8738cf7586711481454c031186aa0b548988d687d2d1977d3c8cdd45992db7b4f
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
 
@@ -123,7 +123,7 @@ module Metanorma
123
123
  def url_in_css_styles(doc, document_suffix)
124
124
  doc.xpath("//*[@style]").each do |s|
125
125
  s["style"] = s["style"]
126
- .gsub(%r{url\(#([^)]+)\)}, "url(#\\1_#{document_suffix})")
126
+ .gsub(%r{url\(#([^()]+)\)}, "url(#\\1_#{document_suffix})")
127
127
  end
128
128
  end
129
129
 
@@ -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)
@@ -110,6 +110,7 @@ module Metanorma
110
110
 
111
111
  def svgmap_resolve_eref(eref, isodoc, _docxml, ids)
112
112
  href = isodoc.eref_target(eref) or return
113
+ href = href[:link]
113
114
  href == "##{eref['bibitemid']}" ||
114
115
  (href =~ /^#/ && !ids[href.sub(/^#/, "")]) and return
115
116
  eref["target"] = href.strip
@@ -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
@@ -28,8 +28,8 @@ module Metanorma
28
28
  def compile(filename, options = {})
29
29
  options_process(filename, options)
30
30
  @processor = @registry.find_processor(options[:type].to_sym)
31
- extensions = get_extensions(options) or return nil
32
31
  (file, isodoc = process_input(filename, options)) or return nil
32
+ extensions = get_extensions(options) or return nil
33
33
  relaton_export(isodoc, options)
34
34
  extract(isodoc, options[:extract], options[:extract_type])
35
35
  process_exts(filename, extensions, file, isodoc, options)
@@ -16,8 +16,8 @@ module Metanorma
16
16
  @aliases = { csd: :cc, m3d: :m3aawg, mpfd: :mpfa, csand: :csa }
17
17
  end
18
18
 
19
- def alias(x)
20
- @aliases[x]
19
+ def alias(flavour)
20
+ @aliases[flavour]
21
21
  end
22
22
 
23
23
  def register(processor)
@@ -1,3 +1,3 @@
1
1
  module Metanorma
2
- VERSION = "2.0.3".freeze
2
+ VERSION = "2.0.5".freeze
3
3
  end
data/metanorma.gemspec CHANGED
@@ -46,4 +46,5 @@ Gem::Specification.new do |spec|
46
46
  spec.add_development_dependency "rubocop", "~> 1.5.2"
47
47
  spec.add_development_dependency "sassc", "~> 2.4.0"
48
48
  spec.add_development_dependency "simplecov", "~> 0.15"
49
+ spec.add_development_dependency "xml-c14n"
49
50
  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.3
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-07-22 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
@@ -262,6 +262,20 @@ dependencies:
262
262
  - - "~>"
263
263
  - !ruby/object:Gem::Version
264
264
  version: '0.15'
265
+ - !ruby/object:Gem::Dependency
266
+ name: xml-c14n
267
+ requirement: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - ">="
270
+ - !ruby/object:Gem::Version
271
+ version: '0'
272
+ type: :development
273
+ prerelease: false
274
+ version_requirements: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - ">="
277
+ - !ruby/object:Gem::Version
278
+ version: '0'
265
279
  description: Library to process any Metanorma standard.
266
280
  email:
267
281
  - open.source@ribose.com