metanorma-standoc 2.9.9 → 2.10.0

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: a7ea12bf51408c095b7c95aaa93ae80274cfdea888c7fc2ce268387f27f59404
4
- data.tar.gz: 3bbbb4f465143a199a585313fbb118cc2517ca63a47cbfd2ff6d8f27c0310cf9
3
+ metadata.gz: be2ed59cc5913ed2c104fdd03479643b39183682a8e17d977d2afb6a6617cc1f
4
+ data.tar.gz: 38fa43ef39ca71510411b98a492d332f71d3ec4d234e4ccb3cbfc987c5d548bb
5
5
  SHA512:
6
- metadata.gz: dee30eacb6d886527e49813809b03a505c0f75a2bf1582bf9da97253ec45cdf852ba9510805f12043da72e2531242a2c63675cf26a1ee876f868ecac4a17edce
7
- data.tar.gz: aaf678d5931ac11dc684a71878a321b2bd311b6ad4e1b631b199b2a92268ce1a3388ac2dd01eebb5b0c75b60bc6286ee505b3ec68a34692af857cd8fc1dd188e
6
+ metadata.gz: f5db76444b5bc527f3edc10723f26a0fb230e826473b1426f812494128966bf21391922859f35112546d29ab9fd66ee7d71f4d298736d6b67359a4df7d2ebf69
7
+ data.tar.gz: 7d3fc23fab73965d54475bbc7b0be492b746eb8f351cc4123ee4f8b8870bc4c572634e2f37340649ab2d529ff39054f1faccadc82707204e1c754911e863334a
@@ -212,7 +212,6 @@ module Metanorma
212
212
  noko do |xml|
213
213
  xml.passthrough **attr_code(formats:
214
214
  node.attr("format") || "metanorma") do |p|
215
- # p << @c.encode(@c.decode(node.content), :basic, :hexadecimal)
216
215
  p << @c.encode(node.content, :basic, :hexadecimal)
217
216
  end
218
217
  end
@@ -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
@@ -17,7 +17,7 @@
17
17
  these elements; we just want one namespace for any child grammars
18
18
  of this.
19
19
  -->
20
- <!-- VERSION v1.3.4 -->
20
+ <!-- VERSION v1.4.0 -->
21
21
  <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
22
22
  <include href="reqt.rng"/>
23
23
  <include href="basicdoc.rng">
@@ -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|
@@ -111,7 +112,7 @@ module Metanorma
111
112
  line = CSV.parse_line(m[:keys], liberal_parsing: true) or return ret
112
113
  line.size > 1 or return ret
113
114
  ret[:id] = line.first
114
- ret[m[:type].to_sym] = line[1..-1].map(&:strip)
115
+ ret[m[:type].to_sym] = line[1..].map(&:strip)
115
116
  ret
116
117
  end
117
118
 
@@ -24,7 +24,7 @@ module Metanorma
24
24
  ret1 = preface_main_filter(sectiontype_streamline(ret), node)
25
25
  ret1 == "symbols and abbreviated terms" and return ret1
26
26
  !level || node.level == 1 || node.attr("heading") or return nil
27
- @seen_headers.include? ret and return nil
27
+ !node.attr("heading") && @seen_headers.include?(ret) and return nil
28
28
  @seen_headers << ret unless ret1.nil?
29
29
  @seen_headers_canonical << ret1 unless ret1.nil?
30
30
  ret1
@@ -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
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "2.9.9".freeze
22
+ VERSION = "2.10.0".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.1"
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.9
4
+ version: 2.10.0
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-11-11 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.1
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.1
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: metanorma
85
85
  requirement: !ruby/object:Gem::Requirement