metanorma-plugin-lutaml 0.7.76 → 0.7.78

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: ac767ca13e42278a97a80952fc74ea4e3e74e67bf6dcb4e47bb354a3a151f1ef
4
- data.tar.gz: f9258d42298a1b87eee4354f23b5204147ea288ce47c50d332de9a52119aecba
3
+ metadata.gz: 44d568f541b3c0b09ff5b1df046d4f69ee3e4ce678ea613413fc12a85b68f7e9
4
+ data.tar.gz: 212a3e398816cb9b3995a31523c7f979737cd9834605c66e7d6cf9ab30b9c857
5
5
  SHA512:
6
- metadata.gz: 7ae26c5b0818537180037a39e3b40c86565cd6de4be6b802a14019563dc67d5a7789a5974e93efe46ef47f456b72e1b7d3656dd0ab25355b2b965b3527b4aa4a
7
- data.tar.gz: e78fab52229c84d01d70e4bd9a1439800c674cab28995119ed4170cb45343c3c536b20a3d20532a6cd7dba760c2babaf2c02e72e91439a9a50f753ead443733e
6
+ metadata.gz: 8aa5fccb1b8e11143d7af97483f7bb80c4839476c224b4382b13ca0ddf3f8076a39917e168de99c9231ae764c800572e5d6d60e80b0427a27c6f01e644371ca0
7
+ data.tar.gz: d332924baf9d3bcb3bf2cfc5adffb39f105e158990d2e7a89d95151dd4bc0fe50ed6a390d0100ce8cf9f33d099a011835670d610dc0b65fb5aa4e5be511e7a09
@@ -13,15 +13,25 @@ on:
13
13
  default: 'skip'
14
14
  repository_dispatch:
15
15
  types: [ do-release ]
16
+ # The publish leg: when the release PR (head branch release/v*) merges,
17
+ # metanorma/ci tags the merge commit and publishes (metanorma/ci#515).
18
+ # Ordinary PR closes are skipped inside the reusable.
19
+ pull_request:
20
+ types:
21
+ - closed
16
22
 
17
23
  jobs:
18
24
  release:
19
25
  uses: metanorma/ci/.github/workflows/rubygems-release.yml@main
26
+ permissions:
27
+ id-token: write
28
+ contents: write
29
+ pull-requests: write
20
30
  with:
21
31
  next_version: ${{ github.event.inputs.next_version }}
22
- release_command: |
23
- bundle install
24
- bundle exec rake release
32
+ # release_command removed (metanorma/ci#515): the reusable's generic
33
+ # build+push handles the gem on both legs; bundler's git machinery
34
+ # cannot run on the publish leg's detached merge-commit checkout.
25
35
  secrets:
26
36
  rubygems-api-key: ${{ secrets.METANORMA_CI_RUBYGEMS_API_KEY }}
27
37
  pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
@@ -92,7 +92,7 @@ module Metanorma
92
92
 
93
93
  def decorate_remarks(options)
94
94
  promote_schema_prose
95
- stash_listing_imagesdir(options)
95
+ stash_figure_remarks(options)
96
96
  end
97
97
 
98
98
  private
@@ -142,35 +142,18 @@ module Metanorma
142
142
  @model.define_singleton_method(name) { splicer.call }
143
143
  end
144
144
 
145
- # The per-schema imagesdir for the listing's attribute entries
146
- # (formatted_hyperlinked_adoc_listing), plus the document's
147
- # imagesdir at decoration time so the listing can restore it
148
- # after the schema's content. The values ride on the schema as
149
- # singleton readers: the liquid drop has no access to the
150
- # asciidoctor document.
151
- def stash_listing_imagesdir(options)
152
- document = options["document"]
153
- dir = ExpressRemarkAdapter.schema_imagesdir(options, @model)
154
- previous = document && document.attributes["imagesdir"]
155
- @model.define_singleton_method(:listing_imagesdir) { dir }
156
- @model.define_singleton_method(:listing_imagesdir_restore) do
157
- previous
158
- end
159
- stash_figure_remarks(options, dir)
160
- end
161
-
162
- # Stashes the drop-facing figure resolver on the schema's
163
- # remark items (ExpressRemarkFigures): templates rendering the
164
- # remarks outside the source listing get their bare figure
165
- # macros resolved through the schema's directory, while the
166
- # listing keeps printing the model source as written. The
167
- # staging runs EAGERLY, at decoration: templates that print the
168
- # remark verbatim ("{{ remark }}") never call the resolved
169
- # accessor, and the staged copy must exist either way for
170
- # their bare targets to resolve against the document's
171
- # imagesdir.
172
- def stash_figure_remarks(options, schema_directory)
145
+ # Stages the schema's EXPRESS-G figures into the directory the
146
+ # document's image targets resolve against and rewrites the
147
+ # remark texts to the staged files' bare basenames — the
148
+ # plugin never sets, checks, or restores the document's
149
+ # imagesdir (metanorma-plugin-lutaml#371): every figure macro
150
+ # the templates print, inside the listing or out, carries a
151
+ # bare target that resolves as-is.
152
+ def stash_figure_remarks(options)
173
153
  document = options["document"]
154
+ schema_directory = ExpressRemarkAdapter.schema_imagesdir(
155
+ options, @model
156
+ )
174
157
  return unless document && schema_directory
175
158
  return unless @model.is_a?(Expressir::Model::Declarations::Schema)
176
159
 
@@ -184,6 +167,9 @@ module Metanorma
184
167
  item.define_singleton_method(:expressg_figure_remarks) do
185
168
  resolved
186
169
  end
170
+ # Resolve in place: the annex templates print `item.remarks`
171
+ # verbatim, outside the listing and outside any accessor.
172
+ item.remarks = resolved
187
173
  end
188
174
  end
189
175
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "digest"
3
4
  require "fileutils"
4
5
  require "pathname"
5
6
 
@@ -46,7 +47,10 @@ module Metanorma
46
47
  # A bare relative image macro: `image::name.svg[]`. Absolute
47
48
  # paths, URLs, data URIs, liquid references and macros carrying
48
49
  # an attribute list stay as written.
49
- IMAGE_MACRO_REGEXP = /\Aimage::([^\/\s:{}][^:\s{}]*)\[\]\s*\z/
50
+ # An optional attribute list is allowed: the WG12 remark figures
51
+ # carry captions (`image::images/x.svg[EXPRESS-G diagram]`), and
52
+ # the empty-list-only form skipped them silently (#371).
53
+ IMAGE_MACRO_REGEXP = /\Aimage::([^\/\s:{}][^:\s{}]*)\[[^\]]*\]\s*\z/
50
54
 
51
55
  # An imagesdir attribute entry; the bang form unsets. The LAST
52
56
  # entry in the source is the one in force where the member
@@ -159,48 +163,83 @@ module Metanorma
159
163
  File.expand_path(imagesdir, docdir)
160
164
  end
161
165
  @schema_directory = schema_directory
166
+ @errors = []
162
167
  end
163
168
 
164
169
  def remarks(texts)
165
170
  texts.map { |text| remark(text) }
166
171
  end
167
172
 
173
+ # The resolved text plus any figure-error lines emitted along
174
+ # the way (a missing figure surfaces as a visible error, never
175
+ # as a broken macro).
168
176
  def remark(text)
169
177
  text.each_line.map { |line| rewrite_line(line) }.join
170
178
  end
171
179
 
180
+ def errors
181
+ @errors.dup
182
+ end
183
+
172
184
  private
173
185
 
174
186
  # The figure file is STAGED into the resolved imagesdir
175
- # directory — the one directory this document's image targets
176
- # resolve against, since asciidoctor joins every target with
177
- # the imagesdir (the author's value, or its own "images"
178
- # default) before use — and the emitted target is the staged
179
- # file's bare basename. A ../-composed target escapes the
180
- # imagesdir join and is dropped silently by asciidoctor's path
181
- # handling (measured: the figure vanished from every output
182
- # format, exit 0), and an absolute target leaks the build path
183
- # (issue #359's original report). The staged copy is a build
184
- # artifact; no path enters the output.
187
+ # directory at the exact path the imagesdir join computes for
188
+ # its target — asciidoctor joins every image target with the
189
+ # imagesdir (the author's value, or its own "images" default)
190
+ # before use, so staging MIRRORS the target path under that
191
+ # directory and the emitted line stands exactly as written:
192
+ # the target is a static path whose composed location exists.
193
+ # No target rewriting, no imagesdir attribute entry
194
+ # (metanorma-plugin-lutaml#371). Only when that static spot is
195
+ # taken by a DIFFERENT figure (two schemas shipping a same-named
196
+ # file) does the line rewrite — to the unique staged path,
197
+ # still static.
185
198
  def rewrite_line(line)
186
199
  match = IMAGE_MACRO_REGEXP.match(line) or return line
187
- return line unless stage_figure(match[1])
200
+ before = @errors.length
201
+ final = final_target(match[1])
202
+ return @errors[before..].join("\n") if final.nil? && @errors.length > before
203
+
204
+ return line if final == match[1]
188
205
 
189
206
  trailing = line.length - line.rstrip.length
190
207
  suffix = trailing.positive? ? line[-trailing, trailing] : ""
191
- "#{line[/\Aimage::/]}#{File.basename(match[1])}[]#{suffix}"
208
+ "#{line[/\Aimage::/]}#{final}[]#{suffix}"
192
209
  end
193
210
 
194
- def stage_figure(bare)
195
- file = File.expand_path(bare, @schema_directory.to_s)
196
- return unless File.file?(file)
211
+ def final_target(target)
212
+ file = File.expand_path(target, @schema_directory.to_s)
213
+ unless File.file?(file)
214
+ # A missing figure must NOT reach asciidoctor as a broken
215
+ # image macro — metanorma's image-existence check then
216
+ # FATALs the whole build (#371). Emit a visible, localized
217
+ # error line in its place: what was expected, where it was
218
+ # looked for.
219
+ @errors << (
220
+ "[EXPRESS-G figure error] '#{target}' not found beside " \
221
+ "the schema (looked in '#{@schema_directory}')"
222
+ )
223
+ return
224
+ end
197
225
 
198
- staged = File.join(@imagesdir_directory, File.basename(bare))
199
- return true if File.file?(staged)
226
+ staged = File.join(@imagesdir_directory, target)
227
+ if File.file?(staged)
228
+ return target if FileUtils.identical?(file, staged)
229
+
230
+ unique = File.join(@imagesdir_directory,
231
+ Digest::SHA256.hexdigest(file)[0, 12],
232
+ target)
233
+ return target if File.file?(unique)
234
+
235
+ FileUtils.mkdir_p(File.dirname(unique))
236
+ FileUtils.cp(file, unique)
237
+ return unique.sub("#{@imagesdir_directory}/", "")
238
+ end
200
239
 
201
- FileUtils.mkdir_p(@imagesdir_directory)
240
+ FileUtils.mkdir_p(File.dirname(staged))
202
241
  FileUtils.cp(file, staged)
203
- true
242
+ target
204
243
  end
205
244
  end
206
245
  end
@@ -9,10 +9,9 @@ module Metanorma
9
9
  # whose fence is computed from the content so that no dash run
10
10
  # inside remark prose can close the listing early — 43 of the 125
11
11
  # SRL schema listings close early under the templates' hardcoded
12
- # two-dash fence — plus the imagesdir attribute entries that let
13
- # the schema's relative image macros resolve as written, with no
14
- # build path in the remark text (TRThurman's source-fidelity
15
- # requirements).
12
+ # two-dash fence — the figure blocks re-emitted after it carry
13
+ # static targets staged by the adapter, with no build path in the
14
+ # remark text (TRThurman's source-fidelity requirements).
16
15
  #
17
16
  # The schema's EXPRESS-G figure remark (`__expressg`, carrying the
18
17
  # svgmap figure blocks) is not source: it is extraction fodder.
@@ -21,9 +20,10 @@ module Metanorma
21
20
  # listings only rendered figures because their hardcoded fence
22
21
  # closed early, an accident the computed fence removed). The
23
22
  # listing therefore prints the EXPRESS source only, and the figure
24
- # blocks are re-emitted after the fence as real adoc, still inside
25
- # the schema's imagesdir attribute entries so the image macros
26
- # resolve as written.
23
+ # blocks are re-emitted after the fence as real adoc with bare
24
+ # basenames — the adapter stages the files and rewrites the
25
+ # remarks at decoration time, so no imagesdir attribute entry is
26
+ # ever emitted (metanorma/metanorma-plugin-lutaml#371).
27
27
  module ExpressSchemaListing
28
28
  SOURCE_BLOCK_HEADING = '[source%unnumbered,subs="+macros"]'
29
29
  # A dash run of two or more at line start: only such a run can
@@ -114,13 +114,11 @@ module Metanorma
114
114
  end
115
115
 
116
116
  # Methods mixed into the schema's liquid drop class. The
117
- # decorated schema carries its imagesdir values as singleton
118
- # readers (the drop has no access to the asciidoctor document);
119
- # attribute entries are emitted immediately before and after the
120
- # block, since attribute entries take effect sequentially and
121
- # cannot be changed inside the listing itself. The extracted
122
- # EXPRESS-G figures go after the block, still inside those
123
- # entries, so their relative image macros resolve as written.
117
+ # adapter stages the EXPRESS-G figures at decoration time, so
118
+ # the extracted figure blocks after the listing carry static,
119
+ # as-written targets — no attribute entries wrap the output
120
+ # (attribute entries could not be changed inside the listing
121
+ # anyway).
124
122
  module DropMethods
125
123
  def formatted_hyperlinked_adoc_listing
126
124
  source, figures = ExpressSchemaListing
@@ -128,27 +126,25 @@ module Metanorma
128
126
  @object.formatted_hyperlinked_adoc.to_s,
129
127
  )
130
128
  fence = ExpressSchemaListing.fence(source)
131
- listing = [
129
+ # The figure macros are bare basenames — the adapter stages
130
+ # the files and rewrites the remarks at decoration time — so
131
+ # no imagesdir attribute entry wraps the output (#371): the
132
+ # document's imagesdir state is the template layer's alone.
133
+ [
134
+ listing_block(source, fence),
135
+ *figures,
136
+ ].reject(&:empty?).join("\n\n")
137
+ end
138
+
139
+ private
140
+
141
+ def listing_block(source, fence)
142
+ [
132
143
  SOURCE_BLOCK_HEADING,
133
144
  fence,
134
145
  source,
135
146
  fence,
136
147
  ].join("\n")
137
- with_imagesdir_entries(listing, figures)
138
- end
139
-
140
- private
141
-
142
- def with_imagesdir_entries(listing, figures = [])
143
- body = [listing, *figures].reject(&:empty?).join("\n\n")
144
- return body unless @object.respond_to?(:listing_imagesdir)
145
-
146
- dir = @object.listing_imagesdir
147
- return body unless dir
148
-
149
- restore = @object.listing_imagesdir_restore
150
- closing = restore ? ":imagesdir: #{restore}" : ":!imagesdir:"
151
- ":imagesdir: #{dir}\n\n#{body}\n\n#{closing}"
152
148
  end
153
149
  end
154
150
  end
@@ -1,7 +1,7 @@
1
1
  module Metanorma
2
2
  module Plugin
3
3
  module Lutaml
4
- VERSION = "0.7.76".freeze
4
+ VERSION = "0.7.78".freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-plugin-lutaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.76
4
+ version: 0.7.78
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-11-18 00:00:00.000000000 Z
11
+ date: 2026-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor