metanorma 2.1.5 → 2.1.6

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: f6fcf07578e0bbbcd55d7ea1cbdafbe588333b5060ad10b1bb4e0851b33e4036
4
- data.tar.gz: 7a91ca6650c240fe06eb68fc5986617662cdd6958160ecea1dafeeb09dd644e6
3
+ metadata.gz: e5610f75a03c358a9dbcc8fcc08e67a40c69f7375bc33c06014658da3682d716
4
+ data.tar.gz: 8a567c76df2967c2fab2d5a26e9652555b10b74070a2d1cd94b688eee922101b
5
5
  SHA512:
6
- metadata.gz: 34989eb8241876f89038ecc1dd1353c09f9c54961b74b50048eddd330eb0a24eca628ad0e8a893108042ad4b89b57b8de8e9ff32166b7eb2e3098f0ef4340bb2
7
- data.tar.gz: 2f9d6d4f182481d8b02b46082bafd6d75fb8d6b1a72c42987a161c60fb3a00fb4d8c5cc53674a9d001996f64bc8cea9b9e854b9d544af5126db1070c30413ac5
6
+ metadata.gz: e320a80eeccbd8cff86f87c82a6e3efc63d1411669338189b19dc99caf80f4435a1ae488dd17e572139967fb97a9613b54a471c838ecb312b9767f84c4102c56
7
+ data.tar.gz: a5019b0c731f53c78b92a5b6ce8c3675fa82dc79ec507f35520d0e2b3faca14f93e149fa5aadfb21bc3df41454520a0b4f5e2c46620bfa2d5db8560adef47b07
@@ -92,15 +92,22 @@ module Metanorma
92
92
  end
93
93
 
94
94
  def render(opts)
95
- if opts[:format].nil? || opts[:format].empty?
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
 
@@ -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)
@@ -13,7 +13,7 @@ module Metanorma
13
13
 
14
14
  class Manifest < ::Lutaml::Model::Serializable
15
15
  attribute :identifier, :string,
16
- default: -> { UUIDTools::UUID.random_create.to_s }
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
@@ -24,16 +24,24 @@ module Metanorma
24
24
  @files_to_delete = []
25
25
  @disambig = Util::DisambigFiles.new
26
26
  @manifest = parent.manifest
27
- read_files(@manifest.entry)
27
+ read_files(@manifest.entry, parent.manifest)
28
+ #warn pp @files
28
29
  end
29
30
 
30
- def read_files(entries)
31
+ def read_files(entries, parent)
31
32
  Array(entries).each do |e|
33
+ derive_format(e, parent)
32
34
  e.file and read_file(e)
33
- read_files(e.entry)
35
+ read_files(e.entry, e)
34
36
  end
35
37
  end
36
38
 
39
+ def derive_format(entry, parent)
40
+ entry.attachment and return
41
+ entry.format ||= parent.format || %w(xml presentation html)
42
+ entry.format |= ["xml", "presentation"]
43
+ end
44
+
37
45
  def read_file(manifest)
38
46
  i, k = read_file_idents(manifest)
39
47
  entry = file_entry(manifest, k) or return
@@ -97,7 +105,8 @@ module Metanorma
97
105
  abs = @documents[Util::key identifier].file
98
106
  ret = if ref.file
99
107
  { type: "fileref", ref: abs, rel_path: ref.file, url: ref.url,
100
- out_path: output_file_path(ref) }
108
+ out_path: output_file_path(ref),
109
+ format: ref.format&.map(&:to_sym) }.compact
101
110
  else { type: "id", ref: ref.id }
102
111
  end
103
112
  file_entry_copy(ref, 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?
@@ -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,7 +129,6 @@ 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
134
  entry&.entry&.each do |f|
@@ -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
- def file_compile_formats(filename, identifier)
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
- concatenate_presentation?({ format: @format }) and
40
- @format << :presentation
41
- @format.each do |e|
42
- ext = @compile.processor.output_formats[e]
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
@@ -91,12 +91,22 @@ module Metanorma
91
91
  warn "\n\n\n\n\nRender Init: #{DateTime.now.strftime('%H:%M:%S')}"
92
92
  cr = new(col, File.dirname(col.file), options)
93
93
  cr.files
94
+ cr.rxl(options)
94
95
  cr.concatenate(col, options)
95
96
  options[:format]&.include?(:html) and cr.coverpage
96
97
  cr.flush_files
97
98
  cr
98
99
  end
99
100
 
101
+ def rxl(options)
102
+ @bibdata or return
103
+ options[:site_generate] and options[:format] << :xml
104
+ options[:format].include?(:rxl) or return
105
+ File.open(File.join(@outdir, "collection.rxl"), "w:UTF-8") do |f|
106
+ f.write(@bibdata.to_xml)
107
+ end
108
+ end
109
+
100
110
  def concatenate(col, options)
101
111
  warn "\n\n\n\n\nConcatenate: #{DateTime.now.strftime('%H:%M:%S')}"
102
112
  concatenate_presentation?(options) and
@@ -112,6 +122,7 @@ module Metanorma
112
122
  end
113
123
 
114
124
  def concatenate_prep(col, options)
125
+ warn options[:format]
115
126
  %i(xml presentation).each do |e|
116
127
  options[:format].include?(e) or next
117
128
  ext = e == :presentation ? "presentation.xml" : e.to_s
@@ -1,3 +1,3 @@
1
1
  module Metanorma
2
- VERSION = "2.1.5".freeze
2
+ VERSION = "2.1.6".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.1.5
4
+ version: 2.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-17 00:00:00.000000000 Z
11
+ date: 2025-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor