metanorma-standoc 2.9.8 → 2.9.10

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: efa906e1b3067735301a14f3f21119e10cb6d100744f8e732dc4e404bf7c38ae
4
- data.tar.gz: 96cd516c49dffa778854b6097f3264203cf892f7d643572d07e7712d18b3cd2b
3
+ metadata.gz: 79c8cf830c54246b723617aaed726657f4d8f97f6b27d70979d1026b6f08fdfc
4
+ data.tar.gz: 7df78766e14e00b1d655a72cecbb34ab71247baa2c07b56ec1b7dc74e420c5ed
5
5
  SHA512:
6
- metadata.gz: 0103f46742310fd7fd639c59c58d54eb1275b3629c1bfdb47bacf613e185bf4b1e9f407d85f6370247aadcd7331968ff84927a09b0f277401e6762afdc6af1ad
7
- data.tar.gz: aae472585794e5a22e2c0b8fbb666a332915f330a2af058d493076246b8b34333df3321bca5aacd0e53f90fef07ee28265ef1bca0f4a003693b10d6204c017b8
6
+ metadata.gz: dda42107f219d750ca21a3207d07172557328f73b99329f70f675b8243274338272e356d31c9543f606aaa0603ba787527f846735f8f192a8adf8e37980b9815
7
+ data.tar.gz: c47f3d6d64525cd099276dcf294c8244a09b916783b0482a51baa82408e7e5a5ffe8f6b4ba2cafdb0c5147902ae28e7c0e4a64dccd14f173828097ca5e894f6e
@@ -7,6 +7,19 @@ module Metanorma
7
7
  bibdata_embed_hdr_cleanup(xmldoc) # feeds bibdata_embed_id_cleanup
8
8
  bibdata_embed_id_cleanup(xmldoc)
9
9
  biblio_indirect_erefs(xmldoc, @internal_eref_namespaces&.uniq)
10
+ coverpage_images(xmldoc)
11
+ end
12
+
13
+ def coverpage_images(xmldoc)
14
+ %w(coverpage-image innercoverpage-image tocside-image
15
+ backpage-image).each do |n|
16
+ xmldoc.xpath("//bibdata/ext/#{n}").each do |x|
17
+ ins = add_misc_container(xmldoc)
18
+ ins << "<presentation-metadata><name>#{n}</name>" \
19
+ "<value>#{x.remove.children.to_xml}</value>" \
20
+ "</presentation-metadata>"
21
+ end
22
+ end
10
23
  end
11
24
 
12
25
  def bibdata_anchor_cleanup(xmldoc)
@@ -25,7 +25,7 @@ module Metanorma
25
25
  end
26
26
 
27
27
  def norm_ref_boilerplate_insert_location(ref)
28
- while (n = ref.parent) && %w(clause references).include?(n&.name)
28
+ while (n = ref.parent) && %w(clause references).include?(n.name)
29
29
  n.elements.detect do |e|
30
30
  !%(title references).include?(e.name) &&
31
31
  !e.at("./self::clause[@type = 'boilerplate']") &&
@@ -113,6 +113,7 @@ module Metanorma
113
113
  def merge_boilerplate_files(built_in, user_add)
114
114
  %w(copyright license legal feedback).each do |w|
115
115
  resolve_boilerplate_statement(built_in, user_add, w)
116
+ resolve_boilerplate_append(built_in, user_add, w)
116
117
  end
117
118
  to_xml(built_in)
118
119
  end
@@ -126,6 +127,26 @@ module Metanorma
126
127
  end
127
128
  end
128
129
 
130
+ def resolve_boilerplate_append(built_in, user_add, statement)
131
+ b = user_add.at("./#{statement}-statement-append") or return
132
+ if a = built_in.at("./#{statement}-statement")
133
+ resolve_boilerplate_append1(a, b, statement)
134
+ else
135
+ b.name = "#{statement}-statement"
136
+ built_in << b
137
+ end
138
+ end
139
+
140
+ def resolve_boilerplate_append1(built_in, user_add, statement)
141
+ if user_add.at("./clause") then built_in << user_add.children
142
+ else
143
+ user_add.name = "clause"
144
+ user_add["id"].nil? || uuid?(user_add["id"]) and
145
+ user_add["id"] = "_boilerplate-#{statement}-statement-append"
146
+ built_in << user_add
147
+ end
148
+ end
149
+
129
150
  def boilerplate_read(file)
130
151
  ret = File.read(file, encoding: "UTF-8")
131
152
  /\.adoc$/.match?(file) and
@@ -139,7 +160,6 @@ module Metanorma
139
160
  boilerplate_file_restructure(file)
140
161
  end
141
162
 
142
- # If Asciidoctor, convert top clauses to tags and wrap in <boilerplate>
143
163
  def boilerplate_file_restructure(file)
144
164
  ret = adoc2xml(file, backend.to_sym)
145
165
  boilerplate_xml_cleanup(ret)
@@ -165,7 +185,8 @@ module Metanorma
165
185
 
166
186
  def boilerplate_top_elements(xml)
167
187
  xml.elements.each do |e|
168
- (t = e.at("./title") and /-statement$/.match?(t.text)) or next
188
+ (t = e.at("./title") and
189
+ /-statement(-append)?$/.match?(t.text)) or next
169
190
  e.name = t.remove.text
170
191
  e.keys.each { |a| e.delete(a) } # rubocop:disable Style/HashEachMethods
171
192
  end
@@ -1,5 +1,4 @@
1
1
  require "date"
2
- require "nokogiri"
3
2
  require "htmlentities"
4
3
  require "pathname"
5
4
  require_relative "./front_contributor"
@@ -91,9 +90,7 @@ module Metanorma
91
90
  a == "date" || /^date_\d+$/.match(a) or next
92
91
  type, date = node.attr(a).split(/ /, 2)
93
92
  type or next
94
- xml.date(type:) do |d|
95
- d.on date
96
- end
93
+ xml.date(type:) { |d| d.on date }
97
94
  end
98
95
  end
99
96
 
@@ -126,8 +123,7 @@ module Metanorma
126
123
 
127
124
  def relation_normalise(type)
128
125
  type.sub(/-by$/, "By").sub(/-of$/, "Of").sub(/-from$/, "From")
129
- .sub(/-in$/, "In")
130
- .sub(/^has-([a-z])/) { "has#{$1.upcase}" }
126
+ .sub(/-in$/, "In").sub(/^has-([a-z])/) { "has#{$1.upcase}" }
131
127
  end
132
128
 
133
129
  def metadata_getrelation(node, xml, type, desc = nil)
@@ -193,6 +189,7 @@ module Metanorma
193
189
  metadata_flavor(node, ext)
194
190
  metadata_committee(node, ext)
195
191
  metadata_ics(node, ext)
192
+ metadata_coverpage_images(node, ext)
196
193
  end
197
194
 
198
195
  def metadata_doctype(node, xml)
@@ -220,9 +217,9 @@ module Metanorma
220
217
  ["en"].each do |lang|
221
218
  at = { language: lang, format: "text/plain" }
222
219
  xml.title **attr_code(at) do |t|
223
- t << (Metanorma::Utils::asciidoc_sub(node.attr("title") ||
224
- node.attr("title-en")) ||
225
- node.title)
220
+ title = Metanorma::Utils::asciidoc_sub(node.attr("title") ||
221
+ node.attr("title-en"))
222
+ t << (title || node.title)
226
223
  end
227
224
  end
228
225
  end
@@ -234,6 +231,17 @@ module Metanorma
234
231
  xml.title v, { language: titlelang, format: "text/plain" }
235
232
  end
236
233
  end
234
+
235
+ def metadata_coverpage_images(node, xml)
236
+ %w(coverpage-image innercoverpage-image tocside-image
237
+ backpage-image).each do |n|
238
+ if a = node.attr(n)
239
+ xml.send n do |c|
240
+ a.split(",").each { |x| c.image src: x }
241
+ end
242
+ end
243
+ end
244
+ end
237
245
  end
238
246
  end
239
247
  end
@@ -110,10 +110,10 @@ module Metanorma
110
110
 
111
111
  def refitem_render1(match, code, bib)
112
112
  refitem_uri(code, bib)
113
- # code[:id].sub!(/[:-](19|20)[0-9][0-9]$/, "")
114
- docid(bib, match[:usrlbl]) if match[:usrlbl]
115
- docid(bib, code[:usrlabel]) if code[:usrlabel]
116
- i = code[:id] and docid(bib, /^\d+$/.match?(i) ? "[#{i}]" : i)
113
+ match[:usrlbl] and docid(bib, match[:usrlbl])
114
+ code[:usrlabel] and docid(bib, code[:usrlabel])
115
+ i = code[:id] and
116
+ docid(bib, /^\d+$/.match?(i) ? "[#{i}]" : i, code[:type])
117
117
  code[:type] == "repo" and
118
118
  bib.docidentifier code[:key], type: "repository"
119
119
  end
@@ -39,11 +39,12 @@ module Metanorma
39
39
  ref
40
40
  end
41
41
 
42
- def docid(bib, code)
42
+ def docid(bib, code, codetype = nil)
43
43
  type, code1 = if /^\[\d+\]$|^\([^)]+\).*$/.match?(code)
44
44
  ["metanorma", mn_code(code)]
45
- else
46
- @bibdb&.docid_type(code) || [nil, code]
45
+ elsif %w(attachment repo path).include?(codetype)
46
+ [nil, code]
47
+ else @bibdb&.docid_type(code) || [nil, code]
47
48
  end
48
49
  code1.sub!(/^nofetch\((.+)\)$/, "\\1")
49
50
  bib.docidentifier **attr_code(type:) do |d|
@@ -112,9 +112,17 @@ module Metanorma
112
112
  def adoc2xml(text, flavour)
113
113
  Nokogiri::XML(text).root and return text
114
114
  f = @flush_caches ? ":flush-caches:\n" : ""
115
- c = Asciidoctor.convert("= X\nA\n:semantic-metadata-headless: true\n" \
116
- ":no-isobib:\n#{f}:novalid:\n\n#{text}\n",
117
- backend: flavour, header_footer: true)
115
+ doc = <<~ADOC
116
+ = X
117
+ A
118
+ :semantic-metadata-headless: true
119
+ :no-isobib:
120
+ #{f}:novalid:
121
+ :!sectids:
122
+
123
+ #{text}
124
+ ADOC
125
+ c = Asciidoctor.convert(doc, backend: flavour, header_footer: true)
118
126
  Nokogiri::XML(c).at("//xmlns:sections")
119
127
  end
120
128
 
@@ -141,6 +149,11 @@ module Metanorma
141
149
  @refids.include? ref
142
150
  end
143
151
 
152
+ def uuid?(ref)
153
+ /^_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
154
+ .match?(ref)
155
+ end
156
+
144
157
  module_function :adoc2xml
145
158
 
146
159
  class EmptyAttr
@@ -14,11 +14,11 @@ module Metanorma
14
14
 
15
15
  def versioned(mod, flavour)
16
16
  all_modules(mod).select { |c| defined? c::VERSION }
17
- .select { |c| c.name =~ /::#{flavour}$/ }
17
+ .select { |c| c.name =~ /Metanorma::#{flavour}$/ }
18
18
  end
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "2.9.8".freeze
22
+ VERSION = "2.9.10".freeze
23
23
  end
24
24
  end
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_dependency "asciidoctor", "~> 2.0.0"
33
33
  spec.add_dependency "crass", "~> 1.0.0"
34
34
  spec.add_dependency "iev", "~> 0.3.0"
35
- spec.add_dependency "isodoc", "~> 2.11.0"
35
+ spec.add_dependency "isodoc", "~> 2.12.0"
36
36
  spec.add_dependency "metanorma", ">= 1.6.0"
37
37
  spec.add_dependency "metanorma-plugin-datastruct", "~> 0.3.0"
38
38
  spec.add_dependency "metanorma-plugin-glossarist", "~> 0.2.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-standoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.8
4
+ version: 2.9.10
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-10-14 00:00:00.000000000 Z
11
+ date: 2024-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 2.11.0
75
+ version: 2.12.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 2.11.0
82
+ version: 2.12.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: metanorma
85
85
  requirement: !ruby/object:Gem::Requirement