metanorma 2.0.6 → 2.0.9

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: f27c1f604a729b827832e208b2ca5db54b8db3f5b3f69fe905e0f0ae87a08f53
4
- data.tar.gz: 781c8396a4c325a34c456ba935e40aba94d4062b283b475cf1bc381aa4ead712
3
+ metadata.gz: 8023ee9f3e35c8192af2ef0cd4231b635b5efc6e5529fe85acb42a641032b3b0
4
+ data.tar.gz: 2875b07c0f94091745d83cea071d96bcffe1a77b5f493eda45970bc7ff3c580b
5
5
  SHA512:
6
- metadata.gz: 8305b0f43fec6a78fc64b2d79fde688d829bacb3e4ce772d14a6c68ceaa71141a6948c4d7c1d6a358f21c4e86e601f44c4e6411a0e5c7c2522a0a8fed71856f1
7
- data.tar.gz: 6d9418c471d3966f00796dd0840cf33400188e93e61585b0b777cc31db70d020b92cd7f89f00754734a5331db29600ec4955b2b52bc86d62da3c11c98f71b45d
6
+ metadata.gz: fae6f061d8fb94d44671e372d802190d205058073a389534241f7958aafe0a0c49e87e75e46cd205d4c9ea227e5c4610f9f4ca430849c084a2493eacdca8419f
7
+ data.tar.gz: a7fa6dcb6a2b379bbc3e6b8de6b4d3f300c0b5e01f40dc79fa784a535f6041d29913b4c904adc3a98e7c8d90ba88ff008e4700549b6c5d397242b33a85040092
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  require "relaton"
4
2
  require "relaton/cli"
5
3
  require "metanorma-utils"
@@ -28,16 +26,20 @@ module Metanorma
28
26
  def initialize(**args)
29
27
  @file = args[:file]
30
28
  @dirname = File.expand_path(File.dirname(@file)) # feeds @manifest
31
- @documents = args[:documents] || {} # feeds initialize_directives
29
+ @documents = args[:documents] || {} # feeds initialize_directives, initialize_docs
32
30
  @bibdatas = args[:documents] || {}
33
31
  initialize_vars
34
32
  initialize_config(args[:config])
35
33
  initialize_directives
34
+ initialize_docs
35
+ validate_flavor(flavor)
36
+ end
37
+
38
+ def initialize_docs
36
39
  @documents.merge! @manifest.documents
37
40
  @bibdatas.merge! @manifest.documents
38
41
  @documents.transform_keys { |k| Util::key(k) }
39
42
  @bibdatas.transform_keys { |k| Util::key(k) }
40
- validate_flavor(flavor)
41
43
  end
42
44
 
43
45
  def initialize_vars
@@ -54,6 +56,8 @@ module Metanorma
54
56
  @final = config.final_content
55
57
  @manifest = ::Metanorma::Collection::Manifest
56
58
  .new(config.manifest, self, @dirname) # feeds initialize_directives
59
+ @format = config.format.map(&:to_sym)
60
+ @format&.empty? and @format = nil
57
61
  end
58
62
 
59
63
  def initialize_directives
@@ -88,7 +92,9 @@ module Metanorma
88
92
  end
89
93
 
90
94
  def render(opts)
91
- opts[:format].nil? || opts[:format].empty? and opts[:format] = [:html]
95
+ if opts[:format].nil? || opts[:format].empty?
96
+ opts[:format] = @format || [:html]
97
+ end
92
98
  opts[:log] = @log
93
99
  opts[:flavor] = @flavor
94
100
  ::Metanorma::Collection::Renderer.render self, opts
@@ -120,7 +126,14 @@ module Metanorma
120
126
  # @return [String] XML
121
127
  def sections(cnt)
122
128
  c = Asciidoctor.convert(cnt, backend: flavor.to_sym, header_footer: true)
123
- Nokogiri::XML(c, &:huge).at("//xmlns:sections").children.to_xml
129
+ x = Nokogiri::XML(c)
130
+ x.xpath("//xmlns:clause").each { |n| n["unnumbered"] = true }
131
+ file = Tempfile.new(%w(foo presentation.xml))
132
+ file.write(x.to_xml(indent: 0))
133
+ file.close
134
+ c1 = Util::isodoc_create(@flavor, @manifest.lang, @manifest.script, x, presxml: true)
135
+ .convert(file.path, nil, true)
136
+ Nokogiri::XML(c1).at("//xmlns:sections").children.to_xml
124
137
  end
125
138
 
126
139
  # @param builder [Nokogiri::XML::Builder]
@@ -1,10 +1,10 @@
1
1
  require "relaton"
2
- require "shale"
2
+ require "lutaml/model"
3
3
 
4
4
  module Metanorma
5
5
  class Collection
6
6
  module Config
7
- class Bibdata < ::Shale::Mapper
7
+ class Bibdata < ::Lutaml::Model::Serializable
8
8
  model ::RelatonBib::BibliographicItem
9
9
  end
10
10
  end
@@ -1,12 +1,11 @@
1
- require "shale"
1
+ require "lutaml/model"
2
2
 
3
3
  module Metanorma
4
4
  class Collection
5
5
  module Config
6
- class CompileOptions < ::Shale::Mapper
7
- attribute :install_fonts, ::Shale::Type::Boolean,
8
- default: -> { false }
9
- attribute :agree_to_terms, ::Shale::Type::Boolean, default: -> { true }
6
+ class CompileOptions < ::Lutaml::Model::Serializable
7
+ attribute :install_fonts, :boolean, default: -> { false }
8
+ attribute :agree_to_terms, :boolean, default: -> { true }
10
9
  end
11
10
  end
12
11
  end
@@ -1,5 +1,4 @@
1
- require "shale"
2
- require_relative "../../shale_monkeypatch"
1
+ require "lutaml/model"
3
2
  require_relative "../../array_monkeypatch"
4
3
  require_relative "compile_options"
5
4
  require_relative "converters"
@@ -11,36 +10,35 @@ module Metanorma
11
10
  class Collection
12
11
  module Config
13
12
  require "shale/adapter/nokogiri"
14
- ::Shale.xml_adapter = ::Shale::Adapter::Nokogiri
13
+ Lutaml::Model::Config.configure do |config|
14
+ config.xml_adapter = Lutaml::Model::XmlAdapter::NokogiriAdapter
15
+ end
15
16
 
16
- class Config < ::Shale::Mapper
17
+ class Config < ::Lutaml::Model::Serializable
17
18
  attr_accessor :path, :collection, :from_xml
18
19
 
19
20
  attribute :bibdata, Bibdata
20
21
  attribute :directive, Directive, collection: true
21
22
  attribute :manifest, Manifest
22
- attribute :format, ::Shale::Type::String, collection: true,
23
- default: -> { [:html] }
24
- attribute :output_folder, ::Shale::Type::String
25
- attribute :coverpage, ::Shale::Type::String, default: -> {
26
- "cover.html"
27
- }
23
+ attribute :coverpage, :string, default: -> { "cover.html" }
24
+ attribute :format, :string, collection: true, default: -> { [:html] }
25
+ attribute :output_folder, :string
28
26
  attribute :compile, CompileOptions
29
- attribute :prefatory_content, ::Shale::Type::String
30
- attribute :final_content, ::Shale::Type::String
27
+ attribute :prefatory_content, :string, raw: true
28
+ attribute :final_content, :string, raw: true
31
29
  attribute :documents, Bibdata, collection: true
32
- attribute :xmlns, ::Shale::Type::String, default: -> { "http://metanorma.org" }
30
+ attribute :xmlns, :string, default: -> { "http://metanorma.org" }
33
31
 
34
32
  yaml do
35
- map "directives", using: { from: :directives_from_yaml,
36
- to: :directives_to_yaml }
37
- map "bibdata", using: { from: :bibdata_from_yaml,
38
- to: :bibdata_to_yaml }
33
+ map "directives", to: :directive, with: { from: :directives_from_yaml,
34
+ to: :directives_to_yaml }
35
+ map "bibdata", to: :bibdata, with: { from: :bibdata_from_yaml,
36
+ to: :bibdata_to_yaml }
39
37
  map "manifest", to: :manifest
40
- map "format", to: :format
38
+ map "format", to: :format, render_default: true
41
39
  map "output_folder", to: :output_folder
42
- map "coverpage", to: :coverpage
43
- map "compile", to: :compile
40
+ map "coverpage", to: :coverpage, render_default: true
41
+ map "compile", to: :compile, render_default: true
44
42
  map "prefatory-content", to: :prefatory_content
45
43
  map "final-content", to: :final_content
46
44
  end
@@ -49,27 +47,31 @@ module Metanorma
49
47
  root "metanorma-collection"
50
48
  # namespace "http://metanorma.org", "m"
51
49
  # map_attribute "xmlns", to: :xmlns
52
- map_element "bibdata", using: { from: :bibdata_from_xml,
53
- to: :bibdata_to_xml }
54
- map_element "directive", using: { from: :directive_from_xml,
55
- to: :directive_to_xml }
56
- map_element "entry", using: { from: :manifest_from_xml,
57
- to: :manifest_to_xml }
58
- map_element "format", to: :format
50
+ map_element "bibdata", to: :bibdata, with: { from: :bibdata_from_xml,
51
+ to: :bibdata_to_xml }
52
+ map_element "directive", to: :directive
53
+ map_element "entry", to: :manifest, with: { from: :manifest_from_xml,
54
+ to: :manifest_to_xml }
55
+ map_element "format", to: :format, render_default: true
59
56
  map_element "output_folder", to: :output_folder
60
- map_element "coverpage", to: :coverpage
61
- map_element "compile", to: :compile
62
- map_element "prefatory-content", using: { from: :prefatory_from_xml,
63
- to: :prefatory_to_xml }
57
+ map_element "coverpage", to: :coverpage, render_default: true
58
+ map_element "compile", to: :compile, render_default: true
59
+ map_element "prefatory-content",
60
+ to: :prefatory_content,
61
+ with: { from: :prefatory_from_xml,
62
+ to: :prefatory_to_xml }
64
63
  map_element "doc-container",
65
- using: { from: :documents_from_xml,
66
- to: :documents_to_xml }
67
- map_element "final-content", using: { from: :final_from_xml,
68
- to: :final_to_xml }
64
+ to: :documents,
65
+ with: { from: :documents_from_xml,
66
+ to: :documents_to_xml }
67
+ map_element "final-content",
68
+ to: :final_content,
69
+ with: { from: :final_from_xml,
70
+ to: :final_to_xml }
69
71
  end
70
72
 
71
73
  def manifest_from_xml(model, node)
72
- model.manifest = Manifest.from_xml(node.to_xml)
74
+ model.manifest = Manifest.from_xml(node.node.to_xml)
73
75
  end
74
76
 
75
77
  def manifest_to_xml(model, parent, doc)
@@ -78,7 +80,7 @@ module Metanorma
78
80
  end
79
81
 
80
82
  def prefatory_from_xml(model, node)
81
- model.prefatory_content = node.to_xml
83
+ model.prefatory_content = node
82
84
  end
83
85
 
84
86
  def prefatory_to_xml(model, parent, doc)
@@ -92,7 +94,8 @@ module Metanorma
92
94
  def content_to_xml(model, parent, doc, type)
93
95
  x = model.send("#{type}_content") or return
94
96
  n = Nokogiri::XML(x)
95
- elem = if n.elements.size == 1 then n.root
97
+ elem = if n.elements.size == 1
98
+ "<#{type}-content>#{x}</#{type}-content>" # n.root
96
99
  else
97
100
  b = Nokogiri::XML::Builder.new
98
101
  model.collection.content_to_xml(type, b)
@@ -102,19 +105,7 @@ module Metanorma
102
105
  end
103
106
 
104
107
  def final_from_xml(model, node)
105
- model.final_content = node.to_xml
106
- end
107
-
108
- def directive_from_xml(model, node)
109
- model.directive ||= []
110
- model.directive << Directive.from_xml(node.to_xml)
111
- end
112
-
113
- def directive_to_xml(model, parent, doc)
114
- Array(model.directive).each do |e|
115
- elem = e.to_xml
116
- doc.add_element(parent, elem)
117
- end
108
+ model.final_content = node
118
109
  end
119
110
 
120
111
  def directives_from_yaml(model, value)
@@ -134,28 +125,6 @@ module Metanorma
134
125
  end
135
126
  end
136
127
 
137
- def documents_from_xml(model, value)
138
- x = if value.is_a?(Shale::Adapter::Nokogiri::Node)
139
- value.content
140
- else Nokogiri::XML(value)
141
- end
142
- model.documents = x.xpath(".//bibdata")
143
- .each_with_object([]) do |b, m|
144
- m << Bibdata.from_xml(b.to_xml)
145
- end
146
- end
147
-
148
- def documents_to_xml(model, parent, doc)
149
- b = Nokogiri::XML::Builder.new do |xml|
150
- xml.document do |m|
151
- model.collection.doccontainer(m) or return
152
- end
153
- end
154
- b.parent.elements.first.elements.each do |x|
155
- doc.add_element(parent, x)
156
- end
157
- end
158
-
159
128
  include Converters
160
129
  end
161
130
  end
@@ -14,7 +14,8 @@ module Metanorma
14
14
  end
15
15
 
16
16
  def bibdata_from_xml(model, node)
17
- model.bibdata = Relaton::Cli.parse_xml(node.content)
17
+ node and
18
+ model.bibdata = Relaton::Cli.parse_xml(node.node.adapter_node)
18
19
  end
19
20
 
20
21
  def bibdata_to_xml(model, parent, doc)
@@ -24,6 +25,31 @@ module Metanorma
24
25
  end
25
26
 
26
27
  def nop_to_yaml(model, doc); end
28
+
29
+ def documents_from_xml(model, value)
30
+ model.documents = value
31
+ .each_with_object([]) do |b, m|
32
+ m << b
33
+ end
34
+ end
35
+
36
+ def documents_to_xml(model, parent, doc)
37
+ documents_to_xml?(doc) or return
38
+ b = Nokogiri::XML::Builder.new do |xml|
39
+ xml.document do |m|
40
+ model.collection.doccontainer(m) or return
41
+ end
42
+ end
43
+ b.parent.elements.first.elements
44
+ .each { |x| doc.add_element(parent, x) }
45
+ end
46
+
47
+ def documents_to_xml?(doc)
48
+ ret = doc.parent.elements.detect do |x|
49
+ x.name == "doc-container"
50
+ end
51
+ !ret
52
+ end
27
53
  end
28
54
  end
29
55
  end
@@ -1,9 +1,15 @@
1
1
  module Metanorma
2
2
  class Collection
3
3
  module Config
4
- class Directive < ::Shale::Mapper
5
- attribute :key, ::Shale::Type::String
6
- attribute :value, ::Shale::Type::String
4
+ class Directive < ::Lutaml::Model::Serializable
5
+ attribute :key, :string
6
+ attribute :value, :string
7
+
8
+ xml do
9
+ root "directive"
10
+ map_element "key", to: :key
11
+ map_element "value", to: :value
12
+ end
7
13
  end
8
14
  end
9
15
  end
@@ -1,5 +1,5 @@
1
- require "shale"
2
- require_relative "../../shale_monkeypatch"
1
+ require "lutaml/model"
2
+ require "lutaml/model/xml_adapter/nokogiri_adapter"
3
3
  require_relative "../../array_monkeypatch"
4
4
  require_relative "converters"
5
5
  require_relative "bibdata"
@@ -8,58 +8,65 @@ module Metanorma
8
8
  class Collection
9
9
  module Config
10
10
  require "shale/adapter/nokogiri"
11
- ::Shale.xml_adapter = ::Shale::Adapter::Nokogiri
11
+ Lutaml::Model::Config.configure do |config|
12
+ config.xml_adapter = Lutaml::Model::XmlAdapter::NokogiriAdapter
13
+ end
12
14
 
13
- class Manifest < ::Shale::Mapper
14
- attribute :identifier, ::Shale::Type::String,
15
- default: -> { UUIDTools::UUID.random_create.to_s }
16
- attribute :id, ::Shale::Type::String
15
+ class Manifest < ::Lutaml::Model::Serializable
16
+ attribute :identifier, :string,
17
+ default: -> { UUIDTools::UUID.random_create.to_s }
18
+ attribute :id, :string
17
19
  attribute :bibdata, Bibdata
18
- attribute :type, ::Shale::Type::String
19
- attribute :title, ::Shale::Type::String
20
- attribute :url, ::Shale::Type::String
21
- attribute :attachment, ::Shale::Type::Boolean
22
- attribute :sectionsplit, ::Shale::Type::Boolean
23
- attribute :index, ::Shale::Type::Boolean, default: -> { true }
20
+ attribute :type, :string
21
+ attribute :title, :string
22
+ attribute :url, :string
23
+ attribute :level, :string
24
+ attribute :attachment, :boolean
25
+ attribute :sectionsplit, :boolean
26
+ attribute :index, :boolean, default: -> { true }
24
27
  attribute :entry, Manifest, collection: true
25
- attribute :file, ::Shale::Type::String
28
+ attribute :file, :string
26
29
 
27
30
  yaml do
28
31
  map "identifier", to: :identifier
29
32
  map "type", to: :type
30
- map "level", using: { from: :level_from_yaml, to: :nop_to_yaml }
33
+ map "level", to: :level,
34
+ with: { from: :level_from_yaml, to: :nop_to_yaml }
31
35
  map "title", to: :title
32
36
  map "url", to: :url
33
37
  map "attachment", to: :attachment
34
38
  map "sectionsplit", to: :sectionsplit
35
39
  map "index", to: :index
36
40
  map "file", to: :file
37
- map "fileref", using: { from: :fileref_from_yaml, to: :nop_to_yaml }
41
+ map "fileref", to: :file,
42
+ with: { from: :fileref_from_yaml, to: :nop_to_yaml }
38
43
  map "entry", to: :entry
39
- map "docref", using: { from: :docref_from_yaml, to: :nop_to_yaml }
40
- map "manifest", using: { from: :docref_from_yaml, to: :nop_to_yaml }
41
- map "bibdata", using: { from: :bibdata_from_yaml,
42
- to: :bibdata_to_yaml }
44
+ map "docref", to: :entry,
45
+ with: { from: :docref_from_yaml, to: :nop_to_yaml }
46
+ map "manifest", to: :entry,
47
+ with: { from: :docref_from_yaml, to: :nop_to_yaml }
48
+ map "bibdata", to: :bibdata, with: { from: :bibdata_from_yaml,
49
+ to: :bibdata_to_yaml }
43
50
  end
44
51
 
45
52
  xml do
46
53
  root "entry"
47
- map_attribute "id", to: :id
54
+ map_attribute "target", to: :id
48
55
  map_attribute "attachment", to: :attachment
49
56
  map_attribute "sectionsplit", to: :sectionsplit
50
57
  map_attribute "index", to: :index
51
58
  map_attribute "url", to: :url
52
59
  map_attribute "fileref", to: :file
53
- map_element "identifier", to: :identifier
60
+ map_element "identifier", to: :identifier, render_default: true
54
61
  map_element "type", to: :type
55
62
  map_element "title", to: :title
56
- map_element "bibdata", using: { from: :bibdata_from_xml,
57
- to: :bibdata_to_xml }
58
- map_element "entry", to: :entry # using: { from: :entry_from_xml, to: :entry_to_xml }
63
+ map_element "bibdata", to: :bibdata, with: { from: :bibdata_from_xml,
64
+ to: :bibdata_to_xml }
65
+ map_element "entry", to: :entry
59
66
  end
60
67
 
61
68
  def entry_from_xml(model, node)
62
- model.entry = Manifest.from_xml(node.content)
69
+ model.entry = Manifest.from_xml(node.node.to_xml)
63
70
  end
64
71
 
65
72
  def entry_to_xml(model, parent, doc)
@@ -62,12 +62,24 @@ module Metanorma
62
62
  file, _filename = targetfile(entry, read: true)
63
63
  xml = Nokogiri::XML(file, &:huge)
64
64
  add_document_suffix(ident, xml)
65
- entry.merge!(anchors: read_anchors(xml), ids: read_ids(xml),
66
- bibdata: xml.at(ns("//bibdata")),
67
- document_suffix: xml.root["document_suffix"])
65
+ entry.merge!(bibdata_extract(xml))
68
66
  end
69
67
  end
70
68
 
69
+ def anchors_lookup(anchors)
70
+ anchors.values.each_with_object({}) do |v, m|
71
+ v.each_value { |v1| m[v1] = true }
72
+ end
73
+ end
74
+
75
+ def bibdata_extract(xml)
76
+ anchors = read_anchors(xml)
77
+ { anchors: anchors, anchors_lookup: anchors_lookup(anchors),
78
+ ids: read_ids(xml),
79
+ bibdata: xml.at(ns("//bibdata")),
80
+ document_suffix: xml.root["document_suffix"] }
81
+ end
82
+
71
83
  def bibitem_process(entry)
72
84
  entry[:bibitem] = entry[:bibdata].dup
73
85
  entry[:bibitem].name = "bibitem"
@@ -76,7 +88,7 @@ module Metanorma
76
88
  end
77
89
 
78
90
  # ref is the absolute source file address
79
- # rel_path is the relative source file address, relative to the YAML locaton
91
+ # rel_path is the relative source file address, relative to the YAML location
80
92
  # out_path is the destination file address, with any references outside
81
93
  # the working directory (../../...) truncated, and based on relative path
82
94
  # identifier is the id with only spaces, no nbsp
@@ -198,10 +210,10 @@ module Metanorma
198
210
  ret[val[:type]] ||= {}
199
211
  index = if val[:container] || val[:label].nil? || val[:label].empty?
200
212
  UUIDTools::UUID.random_create.to_s
201
- else val[:label]
213
+ else val[:label].gsub(%r{<[^>]+>}, "")
202
214
  end
203
215
  ret[val[:type]][index] = key
204
- ret[val[:type]][val[:value]] = key if val[:value]
216
+ v = val[:value] and ret[val[:type]][v.gsub(%r{<[^>]+>}, "")] = key
205
217
  end
206
218
 
207
219
  # Also parse all ids in doc (including ones which won't be xref targets)
@@ -216,8 +228,8 @@ module Metanorma
216
228
  end
217
229
 
218
230
  def key(ident)
219
- @c.decode(ident).gsub(/(\p{Zs})+/, " ").sub(/^metanorma-collection /,
220
- "")
231
+ @c.decode(ident).gsub(/(\p{Zs})+/, " ")
232
+ .sub(/^metanorma-collection /, "")
221
233
  end
222
234
 
223
235
  def keys
@@ -1,4 +1,5 @@
1
1
  require_relative "../sectionsplit/sectionsplit"
2
+ # require "concurrent-ruby"
2
3
 
3
4
  module Metanorma
4
5
  class Collection
@@ -16,13 +17,25 @@ module Metanorma
16
17
 
17
18
  def process_section_split_instance(key, manifest)
18
19
  s, sectionsplit_manifest = sectionsplit(key)
20
+ # section_split_instance_threads(s, manifest, key)
19
21
  s.each_with_index do |f1, i|
20
22
  add_section_split_instance(f1, manifest, key, i)
21
23
  end
22
24
  a = add_section_split_attachments(sectionsplit_manifest, key) and
23
25
  manifest["#{key}:attachments"] = a
24
- manifest["#{key}:index.html"] =
25
- add_section_split_cover(sectionsplit_manifest, key)
26
+ add_section_split_cover(manifest, sectionsplit_manifest, key)
27
+ end
28
+
29
+ def section_split_instance_threads(s, manifest, key)
30
+ @mutex = Mutex.new
31
+ pool = Concurrent::FixedThreadPool.new(4)
32
+ s.each_with_index do |f1, i|
33
+ pool.post do
34
+ add_section_split_instance(f1, manifest, key, i)
35
+ end
36
+ end
37
+ pool.shutdown
38
+ pool.wait_for_termination
26
39
  end
27
40
 
28
41
  def cleanup_section_split_instance(key, manifest)
@@ -31,24 +44,34 @@ module Metanorma
31
44
  @files[key][:indirect_key] = @sectionsplit.key
32
45
  end
33
46
 
34
- def add_section_split_cover(manifest, ident)
47
+ def add_section_split_cover(manifest, sectionsplit_manifest, ident)
35
48
  cover = @sectionsplit
36
- .section_split_cover(manifest, @parent.dir_name_cleanse(ident),
49
+ .section_split_cover(sectionsplit_manifest,
50
+ @parent.dir_name_cleanse(ident),
37
51
  one_doc_collection?)
38
52
  @files[ident][:out_path] = cover
39
- { attachment: true, index: false, out_path: cover,
40
- ref: File.join(File.dirname(manifest.file), cover) }
53
+ src = File.join(File.dirname(sectionsplit_manifest.file), cover)
54
+ m = { attachment: true, index: false, out_path: cover, ref: src }
55
+ manifest["#{ident}:index.html"] = m
56
+ one_doc_collection? and
57
+ add_cover_one_doc_coll(manifest, sectionsplit_manifest, ident, m)
58
+ end
59
+
60
+ def add_cover_one_doc_coll(manifest, sectionsplit_manifest, key, entry)
61
+ idx = File.join(File.dirname(sectionsplit_manifest.file), "index.html")
62
+ FileUtils.cp entry[:ref], idx
63
+ manifest["#{key}:index1.html"] =
64
+ entry.merge(out_path: "index.html", ref: idx)
41
65
  end
42
66
 
43
67
  def one_doc_collection?
44
- return false
45
68
  docs = 0
46
69
  @files.each_value do |v|
47
70
  v[:attachment] and next
48
71
  v[:presentationxml] and next
49
72
  docs += 1
50
73
  end
51
- docs > 1
74
+ docs <= 1
52
75
  end
53
76
 
54
77
  def add_section_split_attachments(manifest, ident)
@@ -62,15 +85,16 @@ module Metanorma
62
85
 
63
86
  def add_section_split_instance(file, manifest, key, idx)
64
87
  presfile, newkey, xml = add_section_split_instance_prep(file, key)
65
- manifest[newkey] =
66
- { parentid: key, presentationxml: true, type: "fileref",
67
- rel_path: file[:url], out_path: File.basename(file[:url]),
68
- anchors: read_anchors(xml), ids: read_ids(xml),
69
- sectionsplit_output: true,
70
- bibdata: @files[key][:bibdata], ref: presfile }
88
+ anchors = read_anchors(xml)
89
+ m = { parentid: key, presentationxml: true, type: "fileref",
90
+ rel_path: file[:url], out_path: File.basename(file[:url]),
91
+ anchors: anchors, anchors_lookup: anchors_lookup(anchors),
92
+ ids: read_ids(xml),
93
+ sectionsplit_output: true, indirect_key: @sectionsplit.key,
94
+ bibdata: @files[key][:bibdata], ref: presfile }
95
+ m[:bare] = true unless idx.zero?
96
+ manifest[newkey] = m
71
97
  @files_to_delete << file[:url]
72
- manifest[newkey][:indirect_key] = @sectionsplit.key
73
- manifest[newkey][:bare] = true unless idx.zero?
74
98
  end
75
99
 
76
100
  def add_section_split_instance_prep(file, key)
@@ -6,7 +6,7 @@ module Metanorma
6
6
  class Collection
7
7
  class Manifest
8
8
  # @return [Metanorma::Collection]
9
- attr_reader :collection, :config
9
+ attr_reader :collection, :config, :lang, :script
10
10
 
11
11
  # @param level [String]
12
12
  # @param dir [String]