expressir 2.4.74 → 2.4.75

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: 19f78c30ad7c890dbb0123db01a391cd00209d3ea3fc811dbc4f76c091beeab2
4
- data.tar.gz: 5d7e212fdc39fcac60e4f236321212bb89a5ad77da02b52cb6291e86fd0c5db0
3
+ metadata.gz: eea8ef3f1f79afd1235bb0a13a136e7a50d7f4f6395c54164c3c2f31c2009f03
4
+ data.tar.gz: 4487392b6a24a864b28b78c653ba0fff636a29490da97d6119d41689df130840
5
5
  SHA512:
6
- metadata.gz: 1e15f304c4651b7ce5bddf828ff969f2a7f59ede2280c3f686496e09164517b8a86230b07f46c12eb7c9048df5a4c28481a43bf3b1fd53246855e341ee89d847
7
- data.tar.gz: 22fac1d6d214d319f975b968a4407d38a77cf9dacfe7e2ca00770d230f2883e628c5ef6519a6dc778a7144996d8fc7f2353c8f2422b42e4f861a739372045677
6
+ metadata.gz: 9cc7a3801afde6460d369f006623b4124921529bcef9c4cbdfc0bbe74fcc45d2c7bc7c20b8bd3c7738acb0975beb6f68eb694f581c2079a0a7dbc8662101c198
7
+ data.tar.gz: 0124d05e8572f01189a1123513d3028556ee58cc98951467c977dc03c6045ef5f85e3fb0ba6169dfd8cc358169cee6cde5af04e8ba330894a56dcd53f04e5804
@@ -255,10 +255,20 @@ module Expressir
255
255
  # end far too early and pushed END-scope tail remarks past their
256
256
  # scope (#653).
257
257
  last = last_slice(data, slice, 0)
258
- text = src[slice.offset...(last.offset + last.length)]&.strip
258
+ # Slice offsets are BYTE offsets; String#[] indexes characters,
259
+ # so any multibyte character earlier in the document shifts the
260
+ # window and .strip then shaves the shifted tail off the span
261
+ # (late-file constructs lost their END tokens). Extract the
262
+ # window by bytes and keep the RAW byte span: the rs reference
263
+ # stamps source_length = stop - start, and every byte consumer
264
+ # (position index, remark attacher) reads offset + length as
265
+ # bytes.
266
+ text = src.byteslice(slice.offset...(last.offset + last.length))
267
+ &.force_encoding(src.encoding)
259
268
  {
260
269
  text: text,
261
270
  offset: slice.offset,
271
+ length: last.offset + last.length - slice.offset,
262
272
  }
263
273
  end
264
274
 
@@ -295,7 +305,7 @@ module Expressir
295
305
  # The original span length rides on every node (independent of
296
306
  # include_source) so remark attachment measures positions against
297
307
  # what the parser captured, never against rendered text (#653).
298
- result.source_length = source_info[:text]&.length
308
+ result.source_length = source_info[:length]
299
309
  result.source = source_info[:text] if include_source
300
310
  end
301
311
 
@@ -66,10 +66,13 @@ module Expressir
66
66
  Model::SupertypeExpressions::BinarySupertypeExpression::ANDOR => 2,
67
67
  }.freeze
68
68
 
69
- attr_accessor :no_remarks
69
+ attr_accessor :no_remarks, :keep_untagged_remarks
70
70
 
71
- def initialize(no_remarks: false)
71
+ def initialize(no_remarks: false, keep_untagged_remarks: false)
72
72
  @no_remarks = no_remarks
73
+ # The plain face: no tagged description blocks, but the source's
74
+ # untagged comments (header, separators, inline notes) render.
75
+ @keep_untagged_remarks = keep_untagged_remarks
73
76
  end
74
77
 
75
78
  def self.format(node)
@@ -57,7 +57,7 @@ module Expressir
57
57
  end
58
58
 
59
59
  def format_inline_tail_remark(node)
60
- return "" if @no_remarks
60
+ return "" if @no_remarks && !@keep_untagged_remarks
61
61
  return "" unless node.is_a?(Model::ModelElement)
62
62
  return "" if node.untagged_remarks.nil? || node.untagged_remarks.empty?
63
63
 
@@ -80,7 +80,7 @@ module Expressir
80
80
  end
81
81
 
82
82
  def format_end_scope_remark(node)
83
- return "" if @no_remarks
83
+ return "" if @no_remarks && !@keep_untagged_remarks
84
84
  return "" unless node.is_a?(Model::ModelElement)
85
85
 
86
86
  # Only legacy (unplaced) remarks belong after the END_* keyword.
@@ -131,7 +131,7 @@ module Expressir
131
131
  end
132
132
 
133
133
  def format_preamble_remarks(node, indent_str = "")
134
- return nil if @no_remarks
134
+ return nil if @no_remarks && !@keep_untagged_remarks
135
135
  return nil unless node.is_a?(Model::ModelElement)
136
136
  return nil if node.untagged_remarks.nil? || node.untagged_remarks.empty?
137
137
 
@@ -168,7 +168,7 @@ module Expressir
168
168
  # region qualify: legacy (nil) remarks keep their historical emission
169
169
  # path so old caches render exactly as they did before.
170
170
  def format_trailing_region_remarks(node, region)
171
- return [] if @no_remarks
171
+ return [] if @no_remarks && !@keep_untagged_remarks
172
172
  return [] unless node.is_a?(Model::ModelElement)
173
173
 
174
174
  Array(node.untagged_remarks).filter_map do |remark|
@@ -219,7 +219,7 @@ module Expressir
219
219
  end
220
220
 
221
221
  def format_leading_statement_remarks(node)
222
- return [] if @no_remarks
222
+ return [] if @no_remarks && !@keep_untagged_remarks
223
223
  return [] unless node.is_a?(Model::Statement)
224
224
 
225
225
  Array(node.untagged_remarks).filter_map do |remark|
@@ -235,7 +235,7 @@ module Expressir
235
235
  # untagged text (add_remark dual-store), so "genuinely tagged" is
236
236
  # derivable only by multiset-subtracting the untagged texts.
237
237
  def format_block_end_remarks(node)
238
- return [] if @no_remarks
238
+ return [] if @no_remarks && !@keep_untagged_remarks
239
239
 
240
240
  untagged = Array(node.untagged_remarks)
241
241
  remaining = untagged.map(&:text).tally
@@ -337,8 +337,9 @@ module Expressir
337
337
  # @param no_remarks [Boolean] omit remarks from the output
338
338
  # @param formatter [Express::Formatter, nil] use a specific formatter
339
339
  # @return [String]
340
- def format(no_remarks: false, formatter: nil)
341
- f = formatter || Express::Formatter.new(no_remarks: no_remarks)
340
+ def format(no_remarks: false, keep_untagged_remarks: false, formatter: nil)
341
+ f = formatter || Express::Formatter.new(no_remarks: no_remarks,
342
+ keep_untagged_remarks: keep_untagged_remarks)
342
343
  f.format(self)
343
344
  end
344
345
 
@@ -3,6 +3,6 @@ module Expressir
3
3
  # autoload it (Ruby autoload only works for module/class constants, not
4
4
  # for string constants like `Expressir::VERSION`).
5
5
  module Version
6
- VERSION = "2.4.74".freeze
6
+ VERSION = "2.4.75".freeze
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expressir
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.74
4
+ version: 2.4.75
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-20 00:00:00.000000000 Z
11
+ date: 2026-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rb_sys