expressir 2.4.57-arm-linux → 2.4.59-arm-linux

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: 6148eb6cc79eb848d5e80ec39052144f2feda56616a2e900def7201cdf7d8343
4
- data.tar.gz: 653b7d92651dc37a9b4a545025fbd867233b4248178a048c83b5cc22dd6db6ea
3
+ metadata.gz: 88b2c4faa26ba40f3ffabb5bb70ac0a5ecbc2ba72cfc891747d9fbd5ee1cedc3
4
+ data.tar.gz: 8b17373bd40394ed1f2e9376206642c0f2ab838460055f2b885c0ecd137d43b7
5
5
  SHA512:
6
- metadata.gz: b179819ec580678d4db4de0038c70bed6da4a942a6dfe3c5ea40a85e770a94f6a1adddc9fcbd995fb637c1beb7b42d73bcf51f3cea2b619b3dc7b10ce4cf9611
7
- data.tar.gz: 3dda5e2bfaba252fb7300ed276e76c4f5016fe3fafd1a62c72c0c98bed3520e305ec056d4f881d321ea1dd2f1ab6d2593ee769aa79133295c491a4750646b516
6
+ metadata.gz: 1c7d02e4374a96ea2729e8551563dd9f25f5becbf967dda7945490bf393f8504125d3af5564ad7eb6405d7fc59472f5a8c5c38bea6c076346b21a267e060fd4d
7
+ data.tar.gz: c82f9f444d570194ecf30baba70a2458fb2b8c5cbca6aa2dffafb925e9912b35745f4992bce11becb33b49dc3784c902e0ec2f300b16ec7f6718aabfc2c5abc7
Binary file
Binary file
Binary file
Binary file
@@ -44,20 +44,21 @@ module Expressir
44
44
  # attachment run in the core (issue #20): the wire carries the
45
45
  # attached remarks before hydration, so the Ruby RemarkAttacher
46
46
  # never runs on this lane.
47
- def self.parse_to_model_attached(source, path)
48
- ::Expressir::Core.parse_to_model_attached(source, path)
47
+ def self.parse_to_model_attached(source, path, annotations: false)
48
+ ::Expressir::Core.parse_to_model_attached(source, path, annotations)
49
49
  end
50
50
 
51
51
  # Like parse_to_model_attached, but also returns the attached
52
52
  # wire JSON string ([model, wire_json]) so the file retains a
53
53
  # lossless handle for the Rust formatter (issue #22).
54
- def self.parse_to_model_attached_with_wire(source, path)
54
+ def self.parse_to_model_attached_with_wire(source, path, annotations: false)
55
55
  unless NATIVE_AVAILABLE &&
56
56
  ::Expressir::Core.respond_to?(:parse_to_model_attached_with_wire)
57
57
  raise NotImplementedError, "core wire retention unavailable"
58
58
  end
59
59
 
60
- model, wire_json = ::Expressir::Core.parse_to_model_attached_with_wire(source, path)
60
+ model, wire_json =
61
+ ::Expressir::Core.parse_to_model_attached_with_wire(source, path, annotations)
61
62
  model.wire_parents
62
63
  model.core_wire = wire_json
63
64
  model
@@ -66,8 +67,8 @@ module Expressir
66
67
  # Scan remarks (issue #20): an Array of Hashes mirroring
67
68
  # RemarkScanner::Remark's fields (position, end_position, line,
68
69
  # text, tag, format), straight from the Rust scanner.
69
- def self.scan_remarks(source)
70
- ::Expressir::Core.scan_remarks(source)
70
+ def self.scan_remarks(source, annotations: false)
71
+ ::Expressir::Core.scan_remarks(source, annotations)
71
72
  end
72
73
 
73
74
  # SourceFormatter (issue #22): the rendered EXPRESS text for one
@@ -182,7 +182,12 @@ module Expressir
182
182
  end
183
183
 
184
184
  def format_data_types_enumeration_item(node)
185
- node.id
185
+ return node.id unless node.respond_to?(:remark_items) && Array(node.remark_items).any?
186
+
187
+ [
188
+ node.id,
189
+ *Array(node.remark_items).map { |item| ["\n", format(item)].join },
190
+ ].join
186
191
  end
187
192
 
188
193
  def format_data_types_generic_entity(node)
@@ -91,6 +91,7 @@ module Expressir
91
91
  end,
92
92
  ";",
93
93
  format_inline_tail_remark(node),
94
+ *format_remark_items(node).map { |x| ["\n", x].join },
94
95
  ].join
95
96
  end
96
97
 
@@ -106,6 +107,7 @@ module Expressir
106
107
  " ",
107
108
  format(node.expression),
108
109
  ";",
110
+ *format_remark_items(node).map { |x| ["\n", x].join },
109
111
  ].join
110
112
  end
111
113
 
@@ -218,6 +220,7 @@ module Expressir
218
220
  indent(node.where_rules.map { |x| format(x) }.join("\n")),
219
221
  ]
220
222
  end,
223
+ *format_remark_items(node).map { |x| indent(x) },
221
224
  [
222
225
  "END_ENTITY",
223
226
  ";",
@@ -302,6 +305,7 @@ module Expressir
302
305
  indent(node.statements.map { |x| format(x) }.join("\n"))
303
306
  end,
304
307
  *format_trailing_region_remarks(node, :statements).map { |x| indent(x) },
308
+ *format_remark_items(node).map { |x| indent(x) },
305
309
  [
306
310
  "END_FUNCTION",
307
311
  ";",
@@ -347,6 +351,7 @@ module Expressir
347
351
  node.id,
348
352
  ]
349
353
  end,
354
+ *format_remark_items(node).map { |x| ["\n", x].join },
350
355
  ].join
351
356
  end
352
357
 
@@ -363,6 +368,7 @@ module Expressir
363
368
  ":",
364
369
  " ",
365
370
  format(node.type),
371
+ *format_remark_items(node).map { |x| ["\n", x].join },
366
372
  ].join
367
373
  end
368
374
 
@@ -426,6 +432,7 @@ module Expressir
426
432
  indent(node.statements.map { |x| format(x) }.join("\n"))
427
433
  end,
428
434
  *format_trailing_region_remarks(node, :statements).map { |x| indent(x) },
435
+ *format_remark_items(node).map { |x| indent(x) },
429
436
  [
430
437
  "END_PROCEDURE",
431
438
  ";",
@@ -529,6 +536,7 @@ module Expressir
529
536
  end,
530
537
  # A comment after the last where rule closes the WHERE section.
531
538
  *format_trailing_region_remarks(node, :where_rules).map { |x| indent(x) },
539
+ *format_remark_items(node).map { |x| indent(x) },
532
540
  [
533
541
  "END_RULE",
534
542
  ";",
@@ -611,6 +619,7 @@ module Expressir
611
619
  "",
612
620
  ]
613
621
  end,
622
+ *format_remark_items(node),
614
623
  [
615
624
  "END_SCHEMA",
616
625
  ";",
@@ -667,6 +676,7 @@ module Expressir
667
676
  ";",
668
677
  ].join)
669
678
  end,
679
+ *format_remark_items(node).map { |x| indent(x) },
670
680
  [
671
681
  "END_SUBTYPE_CONSTRAINT",
672
682
  ";",
@@ -693,6 +703,7 @@ module Expressir
693
703
  indent(node.where_rules.map { |x| format(x) }.join("\n")),
694
704
  ]
695
705
  end,
706
+ *format_remark_items(node).map { |x| indent(x) },
696
707
  [
697
708
  "END_TYPE",
698
709
  ";",
@@ -712,6 +723,7 @@ module Expressir
712
723
  end,
713
724
  Array(node.attributes).map { |x| format(x) }.join(", "),
714
725
  ";",
726
+ *format_remark_items(node).map { |x| ["\n", x].join },
715
727
  ].join
716
728
  end
717
729
 
@@ -745,6 +757,7 @@ module Expressir
745
757
  end,
746
758
  format(node.expression),
747
759
  ";",
760
+ *format_remark_items(node).map { |x| ["\n", x].join },
748
761
  ].join
749
762
  end
750
763
 
@@ -757,6 +770,7 @@ module Expressir
757
770
  " ",
758
771
  ].join
759
772
  end,
773
+ *format_remark_items(node).map { |x| ["\n", x].join },
760
774
  ].join
761
775
  end
762
776
  end
@@ -41,8 +41,14 @@ module Expressir
41
41
 
42
42
  formatted_text = remark.tagged? ? "\"#{remark.tag}\" #{text}" : text
43
43
 
44
- if remark.tail?
44
+ if remark.tail_annotation?
45
+ "--- #{formatted_text}"
46
+ elsif remark.tail?
45
47
  "-- #{formatted_text}"
48
+ elsif remark.embedded_annotation? && text.include?("\n")
49
+ ["(**", formatted_text, "**)"].join("\n")
50
+ elsif remark.embedded_annotation?
51
+ "(** #{formatted_text} *)"
46
52
  elsif text.include?("\n")
47
53
  ["(*", formatted_text, "*)"].join("\n")
48
54
  else
@@ -62,7 +68,15 @@ module Expressir
62
68
  return "" if text.nil? || text.empty?
63
69
 
64
70
  formatted_text = remark.tagged? ? "\"#{remark.tag}\" #{text}" : text
65
- remark.tail? ? " -- #{formatted_text}" : " (* #{formatted_text} *)"
71
+ if remark.tail_annotation?
72
+ " --- #{formatted_text}"
73
+ elsif remark.tail?
74
+ " -- #{formatted_text}"
75
+ elsif remark.embedded_annotation?
76
+ " (** #{formatted_text} *)"
77
+ else
78
+ " (* #{formatted_text} *)"
79
+ end
66
80
  end
67
81
 
68
82
  def format_end_scope_remark(node)
@@ -82,7 +96,7 @@ module Expressir
82
96
  return "" unless remark.tail?
83
97
 
84
98
  formatted_text = remark.tagged? ? "\"#{remark.tag}\" #{text}" : text
85
- " -- #{formatted_text}"
99
+ remark.tail_annotation? ? " --- #{formatted_text}" : " -- #{formatted_text}"
86
100
  end
87
101
 
88
102
  def format_preamble_remark(remark, indent_str = "")
@@ -91,8 +105,19 @@ module Expressir
91
105
  text = remark.text
92
106
  text = "\"#{remark.tag}\" #{text}" if remark.tagged?
93
107
 
94
- if remark.tail?
108
+ if remark.tail_annotation?
109
+ "#{indent_str}--- #{text}"
110
+ elsif remark.tail?
95
111
  "#{indent_str}-- #{text}"
112
+ elsif remark.embedded_annotation? && text.include?("\n")
113
+ lines = text.split("\n")
114
+ [
115
+ "#{indent_str}(**",
116
+ *lines.map { |line| "#{indent_str} #{line.strip}" },
117
+ "#{indent_str}**)",
118
+ ].join("\n")
119
+ elsif remark.embedded_annotation?
120
+ "#{indent_str}(** #{text} *)"
96
121
  elsif text.include?("\n")
97
122
  lines = text.split("\n")
98
123
  [
@@ -264,6 +289,15 @@ module Expressir
264
289
 
265
290
  remarks
266
291
  end
292
+
293
+ # The tagged remark-item blocks attached to this node
294
+ # (expressir#603: RemarkItem children render with their owners).
295
+ def format_remark_items(node)
296
+ return [] if @no_remarks
297
+ return [] unless node.respond_to?(:remark_items)
298
+
299
+ Array(node.remark_items).map { |item| format(item) }.reject(&:empty?)
300
+ end
267
301
  end
268
302
  end
269
303
  end
@@ -12,14 +12,24 @@ module Expressir
12
12
 
13
13
  # Check if any remark contains newlines
14
14
  has_newlines = node.remarks.any? { |r| r.to_s.include?("\n") }
15
+ remarks_text = node.remarks.join("\n")
15
16
 
16
- if has_newlines
17
+ # The tag is the schema-relative EXPRESS path: node.path is
18
+ # rooted at the ExpFile, whose id is the file path — drop that
19
+ # leading segment so the tag reads like the source form
20
+ # (expressir#603).
21
+ tag = node.path.to_s
22
+ root = node
23
+ root = root.parent while root.respond_to?(:parent) && root.parent
24
+ prefix = "#{root.id}." if root.respond_to?(:id) && root.id
25
+ tag = tag.delete_prefix(prefix) if prefix && tag.start_with?(prefix)
26
+
27
+ if has_newlines || node.remarks.length > 1
17
28
  # Multi-line format: (*"path" remarks *)
18
- remarks_text = node.remarks.join("\n")
19
- "(*\"#{node.path}\"\n#{remarks_text}\n*)"
29
+ "(*\"#{tag}\"\n#{remarks_text}\n*)"
20
30
  else
21
- # Single-line format: --"path"
22
- "--\"#{node.path}\""
31
+ # Single-line format: --"path" text
32
+ "--\"#{tag}\" #{remarks_text}"
23
33
  end
24
34
  end
25
35
  end
@@ -54,9 +54,13 @@ module Expressir
54
54
  # parser_core_parity_spec)
55
55
  # @return [Model::ExpFile] ExpFile containing parsed schemas
56
56
  # @raise [Error::SchemaParseFailure] if the schema file fails to parse
57
+ # @param annotations [Boolean] recognize EXPRESSdoc annotations
58
+ # (`--- note`, `(** note *)`) in addition to remarks; they come
59
+ # back with the annotation remark formats (core lane).
57
60
  def self.from_file(file, skip_references: nil, include_source: nil,
58
61
  root_path: nil, use_native: nil,
59
- use_core: nil, dialect: nil) # rubocop:disable Metrics/AbcSize
62
+ use_core: nil, dialect: nil,
63
+ annotations: false) # rubocop:disable Metrics/AbcSize
60
64
  Dialect.normalize(dialect)
61
65
  # use_native: false pins the Ruby grammar path; the core path
62
66
  # must not silently take over that request.
@@ -64,7 +68,8 @@ module Expressir
64
68
  if use_core && Core::NATIVE_AVAILABLE
65
69
  return from_file_core(file, skip_references: skip_references,
66
70
  include_source: include_source,
67
- root_path: root_path)
71
+ root_path: root_path,
72
+ annotations: annotations)
68
73
  end
69
74
 
70
75
  Expressir::Benchmark.measure_file(file) do
@@ -198,7 +203,8 @@ module Expressir
198
203
  # directly (lutaml wire shape); Ruby hydrates, then remark
199
204
  # attachment runs on the source as usual.
200
205
  def self.from_file_core(file, skip_references: nil,
201
- include_source: nil, root_path: nil, &block)
206
+ include_source: nil, root_path: nil,
207
+ annotations: false, &block)
202
208
  unless Core::NATIVE_AVAILABLE
203
209
  raise Error::StreamingUnsupportedError,
204
210
  "core parse requires the native extension"
@@ -213,7 +219,8 @@ module Expressir
213
219
  begin
214
220
  if Core.respond_to?(:parse_to_model_attached_with_wire)
215
221
  remarks_attached = true
216
- Core.parse_to_model_attached_with_wire(source, schema_file)
222
+ Core.parse_to_model_attached_with_wire(source, schema_file,
223
+ annotations: annotations)
217
224
  .tap(&:wire_parents)
218
225
  else
219
226
  Core.parse_to_model(source, schema_file).tap(&:wire_parents)
@@ -232,7 +239,8 @@ module Expressir
232
239
 
233
240
  finalize_loaded_file(exp_file, source, schema_file,
234
241
  include_source: include_source,
235
- remarks_attached: remarks_attached)
242
+ remarks_attached: remarks_attached,
243
+ annotations: annotations)
236
244
 
237
245
  unless skip_references
238
246
  Expressir::Benchmark.measure_references do
@@ -248,9 +256,10 @@ module Expressir
248
256
  # Shared post-parse steps for every core-path file: remark
249
257
  # attachment, header-remark transfer, and path wiring.
250
258
  def self.finalize_loaded_file(exp_file, source, schema_file,
251
- include_source: nil, remarks_attached: false)
259
+ include_source: nil, remarks_attached: false,
260
+ annotations: false)
252
261
  if source && include_source != false && !remarks_attached
253
- RemarkAttacher.new(source).attach(exp_file)
262
+ RemarkAttacher.new(source, annotations: annotations).attach(exp_file)
254
263
  end
255
264
 
256
265
  transfer_header_to_schema(exp_file, source)
@@ -39,8 +39,9 @@ module Expressir
39
39
  # 1-based line number(s) it appears on.
40
40
  WHERE_CLAUSE_PATTERN = /\A\s*WHERE\s+(\w+)\s*:/i
41
41
 
42
- def initialize(source)
42
+ def initialize(source, annotations: false)
43
43
  @source = source
44
+ @annotations = annotations
44
45
  @attached_spans = Set.new
45
46
  @line_map = LineMap.new(source.b)
46
47
  @model = nil
@@ -52,7 +53,7 @@ module Expressir
52
53
 
53
54
  def attach(model)
54
55
  @model = model
55
- remarks = RemarkScanner.new(@source).scan
56
+ remarks = RemarkScanner.new(@source, annotations: @annotations).scan
56
57
 
57
58
  @node_index = NodePositionIndex.new(model, @line_map)
58
59
  @scope_resolver = ScopeResolver.new(
@@ -32,12 +32,22 @@ module Expressir
32
32
  # occupied in the original source.
33
33
  Remark = Struct.new(:position, :end_position, :line, :text, :tag,
34
34
  :format, keyword_init: true) do
35
+ # Tail annotations sit where tails sit; the renderer asks
36
+ # #tail_annotation? for the marker.
35
37
  def tail?
36
- format == Model::RemarkFormat::TAIL
38
+ [Model::RemarkFormat::TAIL, Model::RemarkFormat::TAIL_ANNOTATION].include?(format)
37
39
  end
38
40
 
39
41
  def embedded?
40
- format == Model::RemarkFormat::EMBEDDED
42
+ [Model::RemarkFormat::EMBEDDED, Model::RemarkFormat::EMBEDDED_ANNOTATION].include?(format)
43
+ end
44
+
45
+ def tail_annotation?
46
+ format == Model::RemarkFormat::TAIL_ANNOTATION
47
+ end
48
+
49
+ def embedded_annotation?
50
+ format == Model::RemarkFormat::EMBEDDED_ANNOTATION
41
51
  end
42
52
 
43
53
  def tagged?
@@ -56,6 +66,12 @@ module Expressir
56
66
  EMBEDDED_CLOSE = "*)"
57
67
  STRING_QUOTE = "'"
58
68
 
69
+ # EXPRESSdoc annotation markers (metanorma/annotated-express#94):
70
+ # a `---` tail annotation takes exactly three dashes, and a `(**`
71
+ # embedded annotation closes with the plain remark closer.
72
+ TAIL_ANNOTATION_MARKER = "---"
73
+ EMBEDDED_ANNOTATION_OPEN = "(**"
74
+
59
75
  # Byte value of `)` — used to detect the `(*)` overlap pattern where
60
76
  # the embedded-remark opener `(*` and closer `*)` share the `*`.
61
77
  RPAREN_BYTE = ")".ord
@@ -67,8 +83,11 @@ module Expressir
67
83
  QUOTED_TAG = /\A"([^"]*)"\s*(.*)\z/m
68
84
 
69
85
  # @param source [String] EXPRESS source text (any encoding).
70
- def initialize(source)
86
+ # @param annotations [Boolean] recognize the EXPRESSdoc annotation
87
+ # forms (`--- note`, `(** note *)`) in addition to remarks.
88
+ def initialize(source, annotations: false)
71
89
  @source = source
90
+ @annotations = annotations
72
91
  @source_bytes = source.b
73
92
  @line_map = LineMap.new(@source_bytes)
74
93
  end
@@ -92,7 +111,7 @@ module Expressir
92
111
  end
93
112
 
94
113
  def native_scan
95
- Core.scan_remarks(@source).map do |unit|
114
+ Core.scan_remarks(@source, annotations: @annotations).map do |unit|
96
115
  Remark.new(
97
116
  position: unit[:position],
98
117
  end_position: unit[:end_position],
@@ -124,19 +143,34 @@ module Expressir
124
143
  embedded_depth = 0
125
144
  tail_start = nil # byte position of first content char after "--"
126
145
  tail_line = nil
146
+ tail_annotation = false
127
147
  embedded_start = nil # byte position of first content char after "(*"
128
148
  embedded_line = nil
149
+ embedded_annotation = false
150
+
151
+ # A `---` tail annotation takes exactly three dashes, the fourth
152
+ # byte (if any) not a dash — dash runs of four or more stay remarks.
153
+ tail_annotation_at = lambda do |at|
154
+ return false unless @annotations
155
+
156
+ src[at, TAIL_ANNOTATION_MARKER.bytesize] == TAIL_ANNOTATION_MARKER &&
157
+ src.getbyte(at + TAIL_ANNOTATION_MARKER.bytesize) != "-".ord
158
+ end
159
+
160
+ embedded_annotation_at = lambda do |at|
161
+ @annotations && src[at, EMBEDDED_ANNOTATION_OPEN.bytesize] == EMBEDDED_ANNOTATION_OPEN
162
+ end
129
163
 
130
164
  while pos < src.bytesize
131
165
  case state
132
166
  when :in_tail
133
167
  nl = src.index("\n", pos)
134
168
  if nl
135
- emit_tail(remarks, tail_start, nl, tail_line)
169
+ emit_tail(remarks, tail_start, nl, tail_line, tail_annotation)
136
170
  pos = nl + 1
137
171
  state = :top
138
172
  else
139
- emit_tail(remarks, tail_start, src.bytesize, tail_line)
173
+ emit_tail(remarks, tail_start, src.bytesize, tail_line, tail_annotation)
140
174
  return remarks
141
175
  end
142
176
  when :in_embedded
@@ -154,7 +188,7 @@ module Expressir
154
188
  embedded_depth -= 1
155
189
  pos = closing + EMBEDDED_CLOSE.bytesize
156
190
  if embedded_depth.zero?
157
- emit_embedded(remarks, embedded_start, closing, embedded_line)
191
+ emit_embedded(remarks, embedded_start, closing, embedded_line, embedded_annotation)
158
192
  state = :top
159
193
  end
160
194
  else
@@ -194,21 +228,36 @@ module Expressir
194
228
  # share the `*`. Emit with empty content and continue.
195
229
  emit_embedded(remarks, next_embed + EMBEDDED_OPEN.bytesize,
196
230
  next_embed + EMBEDDED_OPEN.bytesize,
197
- @line_map.line_number(next_embed))
231
+ @line_map.line_number(next_embed), false)
198
232
  pos = next_embed + 3
199
233
  state = :top
200
234
  else
201
- embedded_start = next_embed + EMBEDDED_OPEN.bytesize
235
+ # `(**` opens an annotation when annotations mode is on;
236
+ # the byte after `(*` is a `*`, so the `(*)` overlap can
237
+ # never collide with it.
238
+ embedded_annotation = embedded_annotation_at.call(next_embed)
239
+ open_len = if embedded_annotation
240
+ EMBEDDED_ANNOTATION_OPEN.bytesize
241
+ else
242
+ EMBEDDED_OPEN.bytesize
243
+ end
244
+ embedded_start = next_embed + open_len
202
245
  embedded_line = @line_map.line_number(next_embed)
203
246
  embedded_depth = 1
204
247
  state = :in_embedded
205
- pos = next_embed + EMBEDDED_OPEN.bytesize
248
+ pos = embedded_start
206
249
  end
207
250
  else
208
- tail_start = next_tail + TAIL_MARKER.bytesize
251
+ tail_annotation = tail_annotation_at.call(next_tail)
252
+ marker_len = if tail_annotation
253
+ TAIL_ANNOTATION_MARKER.bytesize
254
+ else
255
+ TAIL_MARKER.bytesize
256
+ end
257
+ tail_start = next_tail + marker_len
209
258
  tail_line = @line_map.line_number(next_tail)
210
259
  state = :in_tail
211
- pos = next_tail + TAIL_MARKER.bytesize
260
+ pos = tail_start
212
261
  end
213
262
  end
214
263
  end
@@ -216,31 +265,47 @@ module Expressir
216
265
  remarks
217
266
  end
218
267
 
219
- def emit_tail(remarks, content_start, content_end, line)
268
+ def emit_tail(remarks, content_start, content_end, line, annotation)
220
269
  # Slice content from the original (UTF-8) source so the returned text
221
270
  # preserves the source encoding. Byte offsets come from the BINARY copy.
222
271
  raw = @source.byteslice(content_start...content_end)
223
272
  tag, content = parse_tail(raw.strip)
224
273
  remarks << Remark.new(
225
- position: content_start - TAIL_MARKER.bytesize,
274
+ position: content_start - (if annotation
275
+ TAIL_ANNOTATION_MARKER.bytesize
276
+ else
277
+ TAIL_MARKER.bytesize
278
+ end),
226
279
  end_position: content_end,
227
280
  line: line,
228
281
  text: content,
229
282
  tag: tag,
230
- format: Model::RemarkFormat::TAIL,
283
+ format: if annotation
284
+ Model::RemarkFormat::TAIL_ANNOTATION
285
+ else
286
+ Model::RemarkFormat::TAIL
287
+ end,
231
288
  )
232
289
  end
233
290
 
234
- def emit_embedded(remarks, content_start, content_end, line)
291
+ def emit_embedded(remarks, content_start, content_end, line, annotation)
235
292
  raw = @source.byteslice(content_start...content_end)
236
293
  tag, content = parse_embedded(raw)
237
294
  remarks << Remark.new(
238
- position: content_start - EMBEDDED_OPEN.bytesize,
295
+ position: content_start - (if annotation
296
+ EMBEDDED_ANNOTATION_OPEN.bytesize
297
+ else
298
+ EMBEDDED_OPEN.bytesize
299
+ end),
239
300
  end_position: content_end + EMBEDDED_CLOSE.bytesize,
240
301
  line: line,
241
302
  text: content,
242
303
  tag: tag,
243
- format: Model::RemarkFormat::EMBEDDED,
304
+ format: if annotation
305
+ Model::RemarkFormat::EMBEDDED_ANNOTATION
306
+ else
307
+ Model::RemarkFormat::EMBEDDED
308
+ end,
244
309
  )
245
310
  end
246
311
 
@@ -12,6 +12,13 @@ module Expressir
12
12
  module RemarkFormat
13
13
  TAIL = "tail"
14
14
  EMBEDDED = "embedded"
15
+
16
+ # EXPRESSdoc annotations (metanorma/annotated-express#94): the
17
+ # display channel, parsed only in annotations mode. `---` tail
18
+ # annotations take exactly three dashes; `(** ... *)` embedded
19
+ # annotations close with the remark closer.
20
+ TAIL_ANNOTATION = "tail_annotation"
21
+ EMBEDDED_ANNOTATION = "embedded_annotation"
15
22
  end
16
23
  end
17
24
  end
@@ -16,16 +16,30 @@ module Expressir
16
16
  attribute :region, :string
17
17
  attribute :source_offset, :integer # byte offset in source text
18
18
 
19
- # Check if this is a tail remark
20
- # @return [Boolean] True if format is 'tail'
19
+ # Check if this is a tail remark. Tail annotations sit where
20
+ # tails sit, so placement semantics treat them as tails; the
21
+ # renderer asks {#tail_annotation?} for the marker.
22
+ # @return [Boolean] True if format is 'tail' or 'tail_annotation'
21
23
  def tail?
22
- format == RemarkFormat::TAIL
24
+ [RemarkFormat::TAIL, RemarkFormat::TAIL_ANNOTATION].include?(format)
23
25
  end
24
26
 
25
- # Check if this is an embedded remark
26
- # @return [Boolean] True if format is 'embedded'
27
+ # Check if this is an embedded remark or embedded annotation
28
+ # @return [Boolean] True if format is 'embedded' or 'embedded_annotation'
27
29
  def embedded?
28
- format == RemarkFormat::EMBEDDED
30
+ [RemarkFormat::EMBEDDED, RemarkFormat::EMBEDDED_ANNOTATION].include?(format)
31
+ end
32
+
33
+ # Check if this is a `---` tail annotation
34
+ # @return [Boolean] True if format is 'tail_annotation'
35
+ def tail_annotation?
36
+ format == RemarkFormat::TAIL_ANNOTATION
37
+ end
38
+
39
+ # Check if this is a `(** ... *)` embedded annotation
40
+ # @return [Boolean] True if format is 'embedded_annotation'
41
+ def embedded_annotation?
42
+ format == RemarkFormat::EMBEDDED_ANNOTATION
29
43
  end
30
44
 
31
45
  # Check if this remark has a tag
@@ -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.57".freeze
6
+ VERSION = "2.4.59".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.57
4
+ version: 2.4.59
5
5
  platform: arm-linux
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-11-07 00:00:00.000000000 Z
11
+ date: 2026-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64