metanorma-ietf 3.7.20 → 3.7.22

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: 01a29754c24fe3e73f52d13534abcda9fb4c7b6a7f9664dbc9f35ebe1ecd6f78
4
- data.tar.gz: d2fc3c04bfe7b898575c090544547bf724b38842bb9c0cef7f642307268f7250
3
+ metadata.gz: 88e3e3cdc038bb5bbd8ccb0f6d64a47a47306c446b14a3fe7c3ac15996c5b7c1
4
+ data.tar.gz: 370fa65a34ed9d3a6a07c648b2963581789f3cacf7e1115178b13b54f71154d3
5
5
  SHA512:
6
- metadata.gz: d87c39b7f5fcdd2568ebed6f06f3f31694fc5302ea632659d07e1f286c944c92269a2f7d8ac2697529229b622124234d2ae0c13ef31e401e5401bec15fc9bc17
7
- data.tar.gz: 1cb9b4c0198cc325598c77dc939836af3953f4ae91a95f87c1ada0eedb6b576cd517ae8066149b19e61e7c6f4e9a1ea1949baa0a14233dbefc56740c2877b48d
6
+ metadata.gz: 3ddc6c3fff7d4291ef83713b0dbf54400ffcf3514cbca854fe57cc340d7be43d4771a29d782474550eb762fa585e2996fb79bef6fac144534aea1c12c665f973
7
+ data.tar.gz: ae2f37c3aa7e7876418e7b2ab9632bbe1dc0ab3b64e7ff7b8e26aea7bbdc7ccbc08e6a5e6160975d509c521589523b60a81400aae09b570e0a7d8fedbdfce4e9
@@ -254,6 +254,9 @@ module Metanorma
254
254
  ol: to_array(model_attr(note_node, :ol)),
255
255
  formula: to_array(model_attr(note_node, :formula)),
256
256
  quote: to_array(model_attr(note_node, :quote)),
257
+ # #297: note sourcecode — the v3 aside admits no
258
+ # sourcecode element, so the listing renders text-at-minimum
259
+ sourcecode: to_array(model_attr(note_node, :sourcecode)),
257
260
  }
258
261
  if blocks.values.any? { |a| !a.empty? } && first
259
262
  label = Rfcxml::V3::Text.new
@@ -272,8 +275,21 @@ module Metanorma
272
275
  list = transform_ordered_list(ol)
273
276
  safe_append(aside, :ol, list) if list
274
277
  end
278
+ blocks[:sourcecode].each do |sc|
279
+ code = transform_sourcecode(sc)
280
+ next unless code
281
+
282
+ # the v3 aside admits no sourcecode element: the listing
283
+ # renders as its text content (#297)
284
+ t = Rfcxml::V3::Text.new
285
+ to_array(code.content).each do |line|
286
+ t.content = to_array(t.content) + [line.to_s]
287
+ track_text_order(t, line.to_s)
288
+ end
289
+ safe_append(aside, :t, t) unless to_array(t.content).empty?
290
+ end
275
291
  # #297: formula and quote are mapped on NoteBlock
276
- # (sourcecode/figure/table are not — model gap)
292
+ # (figure/table are not — model gap)
277
293
  blocks[:formula].each do |f|
278
294
  Array(transform_formula(f)).each do |r|
279
295
  safe_append(aside, r.is_a?(Rfcxml::V3::Dl) ? :dl : :t, r)
@@ -375,9 +391,10 @@ module Metanorma
375
391
  "dl" => :dl,
376
392
  "table" => :table,
377
393
  # #297 additions: mapped on ExampleBlock ("list" is the
378
- # legacy alias for ul; note has no mapping — model gap)
394
+ # legacy alias for ul; note rides the :notes collection)
379
395
  "formula" => :formula,
380
396
  "quote" => :quote,
397
+ "note" => :notes,
381
398
  "list" => :list,
382
399
  }.freeze
383
400
 
@@ -398,6 +415,7 @@ module Metanorma
398
415
  when :table then transform_table(child)
399
416
  when :formula then transform_formula(child)
400
417
  when :quote then transform_quote(child)
418
+ when :notes then transform_note(child, nil)
401
419
  when :list then transform_unordered_list(child)
402
420
  end
403
421
  end
@@ -414,6 +432,7 @@ module Metanorma
414
432
  when Rfcxml::V3::Dl then :dl
415
433
  when Rfcxml::V3::Table then :table
416
434
  when Rfcxml::V3::Blockquote then :blockquote
435
+ when Rfcxml::V3::Aside then :aside
417
436
  else :t
418
437
  end
419
438
  end
@@ -428,6 +447,13 @@ module Metanorma
428
447
  markers = sc_node.markers
429
448
  sourcecode.markers = markers if markers && !markers.to_s.empty?
430
449
 
450
+ # src= references an external listing (#296 item 4; the model
451
+ # mapping ships in metanorma-document 0.5.13)
452
+ if sc_node.respond_to?(:src)
453
+ src_val = sc_node.src
454
+ sourcecode.src = src_val if src_val && !src_val.to_s.empty?
455
+ end
456
+
431
457
  name = sc_node.filename
432
458
  sourcecode.name = name if name && !name.to_s.empty?
433
459
 
@@ -571,6 +597,19 @@ module Metanorma
571
597
  safe_append(aside, :t, t) if t
572
598
  end
573
599
 
600
+ # #297: admonition list bodies render like note list bodies
601
+ # (the v3 aside admits ul/ol/dl)
602
+ {
603
+ dl: :transform_definition_list,
604
+ ul: :transform_unordered_list,
605
+ ol: :transform_ordered_list,
606
+ }.each do |tag, renderer|
607
+ to_array(model_attr(admon_node, tag)).each do |child|
608
+ rendered = public_send(renderer, child)
609
+ safe_append(aside, tag, rendered) if rendered
610
+ end
611
+ end
612
+
574
613
  aside
575
614
  end
576
615
 
@@ -784,8 +823,7 @@ module Metanorma
784
823
  # flatten_inline_text (not the p's own text runs): a
785
824
  # footnote's inline markup lost even its TEXT (#293). The
786
825
  # paragraph id rides along so xrefs to the footnote body
787
- # resolve to the endnote. (A non-paragraph fn body — a bare
788
- # ul — is a 0.2.9 parse ghost: FnElement maps only p.)
826
+ # resolve to the endnote.
789
827
  entries = to_array(fn_elem.p).map do |p|
790
828
  text = flatten_inline_text(p)
791
829
  next if text.nil? || text.strip.empty?
@@ -793,6 +831,20 @@ module Metanorma
793
831
  { text: text.strip, anchor: anchor_for(p) }
794
832
  end.compact
795
833
 
834
+ # non-paragraph fn bodies (ul/ol/table — mapped since the
835
+ # 0.2.9 ledger) render like their clause counterparts
836
+ # (#293 item 2)
837
+ {
838
+ "ul" => :transform_unordered_list,
839
+ "ol" => :transform_ordered_list,
840
+ "table" => :transform_table,
841
+ }.each do |tag, renderer|
842
+ to_array(model_attr(fn_elem, tag)).each do |node|
843
+ rendered = public_send(renderer, node)
844
+ entries << { block: rendered } if rendered
845
+ end
846
+ end
847
+
796
848
  @collected_footnotes[num] = entries if entries.any?
797
849
  end
798
850
 
@@ -24,6 +24,10 @@ module Metanorma
24
24
  src_order = figure_node.element_order
25
25
  if src_order && src_order.any?
26
26
  counters = Hash.new(0)
27
+ # pre-artwork paragraphs fold into the preamble,
28
+ # post-artwork ones into the postamble (#296 item 2) —
29
+ # the figure element admits no bare <t>
30
+ seen_art = false
27
31
  src_order.each do |e|
28
32
  next if e.text?
29
33
  tag = e.element_tag
@@ -31,73 +35,168 @@ module Metanorma
31
35
  counters[tag] += 1
32
36
  case tag
33
37
  when "image"
38
+ next unless figure_node.respond_to?(:image)
34
39
  img = to_array(figure_node.image || [])[idx]
35
40
  if img
36
41
  artwork = transform_image_to_artwork(img)
37
42
  safe_append(figure, :artwork, artwork) if artwork
43
+ seen_art = true if artwork
38
44
  end
39
45
  when "pre"
46
+ next unless figure_node.respond_to?(:pre)
40
47
  pre_node = to_array(figure_node.pre || [])[idx]
41
48
  if pre_node
42
49
  artwork = transform_pre_to_artwork(pre_node)
43
50
  safe_append(figure, :artwork, artwork) if artwork
51
+ seen_art = true if artwork
44
52
  end
45
53
  when "sourcecode"
46
- sourcecodes = to_array(model_attr(figure_node,
47
- :sourcecode_blocks) || [])
48
- if sourcecodes[idx]
49
- src = transform_sourcecode(sourcecodes[idx])
54
+ # 0.5.12 maps figure sourcecode as :sourcecode;
55
+ # :sourcecode_blocks is the older vintage
56
+ scs = to_array(model_attr(figure_node, :sourcecode) || [])
57
+ scs = to_array(model_attr(figure_node,
58
+ :sourcecode_blocks) || []) if scs.empty?
59
+ if (sc = scs[idx])
60
+ src = transform_sourcecode(sc)
50
61
  safe_append(figure, :sourcecode, src) if src
62
+ seen_art = true if src
51
63
  end
52
64
  # subfigures were dropped outright (#296): the walk had
53
65
  # no figure branch though the model maps it
54
66
  when "figure"
55
- sub = to_array(model_attr(figure_node, :figure) || [])[idx]
67
+ next unless figure_node.respond_to?(:figure)
68
+ sub = to_array(figure_node.figure || [])[idx]
56
69
  append_subfigure_content(figure, sub) if sub
70
+ seen_art = true if sub
57
71
  # the figure key <dl> was dropped outright (#296)
58
72
  when "dl"
59
- dl_node = to_array(model_attr(figure_node, :dl) || [])[idx]
73
+ next unless figure_node.respond_to?(:dl)
74
+ dl_node = to_array(figure_node.dl || [])[idx]
60
75
  append_figure_key(figure, dl_node) if dl_node
76
+ # the figure surroundings (#296 item 2): pre/post-artwork
77
+ # paragraphs render in source order like the tables'
78
+ # surroundings machinery
79
+ when "p"
80
+ next unless figure_node.respond_to?(:p)
81
+ paras = to_array(figure_node.p || [])[idx]
82
+ build_figure_surrounding(figure, paras, seen_art) if paras
61
83
  when "key"
62
- k = to_array(model_attr(figure_node, :key) || [])[idx]
84
+ next unless figure_node.respond_to?(:key)
85
+ k = to_array(figure_node.key || [])[idx]
63
86
  k && to_array(model_attr(k, :dl)).each do |d|
64
87
  append_figure_key(figure, d)
65
88
  end
66
89
  end
67
90
  end
68
91
  else
69
- # Fallback without element_order
70
- to_array(figure_node.image || []).each do |img|
92
+ # Fallback without element_order (raw-semantic parses carry
93
+ # no element_order): canonical authoring order - paragraphs,
94
+ # subfigures, art, sourcecode, key (#296 items 1 and 2: the
95
+ # old fallback carried images only). model_attr throughout:
96
+ # Subfigure maps a strict subset of FigureBlock, and a raw
97
+ # read on an unmapped accessor raises.
98
+ to_array(model_attr(figure_node, :p)).each do |para|
99
+ build_figure_surrounding(figure, para, false)
100
+ end
101
+ to_array(model_attr(figure_node, :figure)).each do |sub|
102
+ append_subfigure_content(figure, sub)
103
+ end
104
+ to_array(model_attr(figure_node, :image)).each do |img|
71
105
  artwork = transform_image_to_artwork(img)
72
106
  safe_append(figure, :artwork, artwork) if artwork
73
107
  end
74
-
75
- to_array(figure_node.pre || []).each do |pre_node|
108
+ to_array(model_attr(figure_node, :pre)).each do |pre_node|
76
109
  artwork = transform_pre_to_artwork(pre_node)
77
110
  safe_append(figure, :artwork, artwork) if artwork
78
111
  end
112
+ scs = to_array(model_attr(figure_node, :sourcecode))
113
+ scs += to_array(model_attr(figure_node, :sourcecode_blocks))
114
+ scs.each do |sc|
115
+ src = transform_sourcecode(sc)
116
+ safe_append(figure, :sourcecode, src) if src
117
+ end
118
+ to_array(model_attr(figure_node, :dl)).each do |dl_node|
119
+ append_figure_key(figure, dl_node)
120
+ end
79
121
  end
80
122
 
81
123
  # Figure source/citation (model_attr: a Subfigure model has
82
- # no source accessor — #296 crash)
83
- sources = model_attr(figure_node, :source)
84
- if sources
85
- sources = [sources] unless sources.is_a?(Array)
86
- sources.each do |src|
87
- src_text = format_figure_source(src)
88
- if src_text && !src_text.empty?
89
- postamble = figure.postamble || Rfcxml::V3::Postamble.new
90
- t = Rfcxml::V3::Text.new
91
- t.content = ["[SOURCE: #{src_text}]"]
92
- safe_append(postamble, :t, t)
93
- figure.postamble = postamble
124
+ # no source accessor — #296 crash). v3 figure admits no
125
+ # bare <t>: the [SOURCE:] bracket rides the postamble
126
+ # (#296 item 3). The <source> elements are mapped as
127
+ # :sources (SourceElement); @source stays a string attr.
128
+ src_models = to_array(model_attr(figure_node, :sources))
129
+ if src_models.any?
130
+ src_t = transform_term_sources(src_models)
131
+ if src_t
132
+ postamble = figure.postamble || Rfcxml::V3::Postamble.new
133
+ # mirror the bracket from the term-source Text's tracked
134
+ # element order in source order (not its content array -
135
+ # under the orderable serialisation the content read-back
136
+ # loses the interleaving)
137
+ counters = Hash.new(0)
138
+ to_array(src_t.element_order).each do |e|
139
+ if e.text?
140
+ postamble.content = to_array(postamble.content) + [e.text_content]
141
+ track_text_order(postamble, e.text_content)
142
+ else
143
+ tag = e.element_tag
144
+ idx = counters[tag]
145
+ counters[tag] += 1
146
+ child = src_t.respond_to?(tag) &&
147
+ to_array(src_t.public_send(tag))[idx]
148
+ next unless child.is_a?(Rfcxml::V3::Xref)
149
+
150
+ safe_append(postamble, :xref, child)
151
+ track_element_order(postamble, :xref, child)
152
+ end
94
153
  end
154
+ figure.postamble = postamble
95
155
  end
156
+ elsif (legacy = model_attr(figure_node, :source)) &&
157
+ !legacy.to_s.strip.empty?
158
+ postamble = figure.postamble || Rfcxml::V3::Postamble.new
159
+ bracket = "[SOURCE: #{legacy}]"
160
+ postamble.content = to_array(postamble.content) + [bracket]
161
+ track_text_order(postamble, bracket)
162
+ figure.postamble = postamble
96
163
  end
97
164
 
98
165
  figure
99
166
  end
100
167
 
168
+ # figure-adjacent paragraphs have no v3 home as bare <t>: they
169
+ # fold into the preamble (before art) or postamble (after) as
170
+ # interleaved inline content (#296 item 2)
171
+ def build_figure_surrounding(figure, p_node, seen_art)
172
+ if seen_art
173
+ holder = figure.postamble || Rfcxml::V3::Postamble.new
174
+ fill_figure_surrounding(holder, p_node)
175
+ figure.postamble = holder
176
+ else
177
+ holder = figure.preamble || Rfcxml::V3::Preamble.new
178
+ fill_figure_surrounding(holder, p_node)
179
+ figure.preamble = holder
180
+ end
181
+ end
182
+
183
+ def fill_figure_surrounding(holder, p_node)
184
+ order = p_node.respond_to?(:element_order) ? p_node.element_order : nil
185
+ if order && order.any?
186
+ prev = to_array(holder.content)
187
+ build_interleaved_content(holder, p_node, order)
188
+ # interleaved content overwrites the text fragments; the
189
+ # inline children ride safe_append, so merge the texts
190
+ holder.content = prev + to_array(holder.content)
191
+ else
192
+ text = extract_paragraph_text(p_node)
193
+ return if text.nil? || text.empty?
194
+
195
+ holder.content = to_array(holder.content) + [text]
196
+ track_text_order(holder, text)
197
+ end
198
+ end
199
+
101
200
  # v3 figure admits no nested figure: fold a subfigure's
102
201
  # artworks/sourcecode into the parent (the released path
103
202
  # promoted subfigures to sibling figures); each subfigure's
@@ -127,7 +226,11 @@ module Metanorma
127
226
  end
128
227
 
129
228
  # v3 figure admits no dl: the key flattens into the postamble
130
- # as "term: definition" lines — text-at-minimum (#296)
229
+ # as "term: definition" lines — text-at-minimum (#296). The
230
+ # lines must ride the postamble's tracked element order too:
231
+ # under the orderable serialisation an untracked write is
232
+ # dropped (the orderless vintage serialises from content, the
233
+ # orderable one from the tracked order)
131
234
  def append_figure_key(figure, dl_node)
132
235
  dts = to_array(model_attr(dl_node, :dt))
133
236
  dds = to_array(model_attr(dl_node, :dd))
@@ -142,7 +245,10 @@ module Metanorma
142
245
  return if lines.empty?
143
246
 
144
247
  postamble = figure.postamble || Rfcxml::V3::Postamble.new
145
- postamble.content = to_array(postamble.content) + lines
248
+ lines.each do |line|
249
+ postamble.content = to_array(postamble.content) + [line]
250
+ track_text_order(postamble, line)
251
+ end
146
252
  figure.postamble = postamble
147
253
  end
148
254
 
@@ -302,14 +408,6 @@ module Metanorma
302
408
  asides
303
409
  end
304
410
 
305
- def format_figure_source(source)
306
- return nil unless source
307
- if source.is_a?(String)
308
- source
309
- else
310
- ls_text(source)
311
- end
312
- end
313
411
  end
314
412
  end
315
413
  end
@@ -181,8 +181,18 @@ module Metanorma
181
181
  return nil unless node
182
182
 
183
183
  order = node.respond_to?(:element_order) ? node.element_order : nil
184
- return ls_text(node) unless order&.any?
184
+ if order&.any?
185
+ joined = flatten_ordered_text(node, order)
186
+ # the order walk can come up empty when this vintage
187
+ # carries the text runs outside the element order (the
188
+ # pipeline's lutaml config changes the shape) - fall back
189
+ # to the node's own text (#292/#296)
190
+ return joined unless joined.gsub(/[[:space:] ]/, "").empty?
191
+ end
192
+ ls_text(node)
193
+ end
185
194
 
195
+ def flatten_ordered_text(node, order)
186
196
  counters = Hash.new(0)
187
197
  order.map do |e|
188
198
  if e.text?
@@ -211,8 +221,12 @@ module Metanorma
211
221
  if order&.any?
212
222
  build_interleaved_content(name, name_node, order)
213
223
  else
224
+ # no element_order (raw-semantic parses): own text plus
225
+ # any mapped inline children - ls_text alone dropped them
226
+ # (#292 figure-caption xref)
214
227
  text = ls_text(name_node)
215
228
  name.content = [text] if text && !text.empty?
229
+ build_nested_inline(name, name_node)
216
230
  end
217
231
  text_empty = to_array(name.content).join.strip.empty?
218
232
  has_inlines = %i[bcp14 cref em eref iref relref strong sub
@@ -290,7 +304,7 @@ module Metanorma
290
304
  to_array(model.public_send(tag))[idx]
291
305
  next unless child
292
306
 
293
- if SIMPLE_INLINE_TAGS.include?(tag)
307
+ if SIMPLE_INLINE_TAGS.include?(tag) && elem.respond_to?(tag)
294
308
  built = build_simple_inline_model(child, tag)
295
309
  next unless built
296
310
 
@@ -298,7 +312,9 @@ module Metanorma
298
312
  track_element_order(elem, tag.to_sym, built)
299
313
  built_children += 1
300
314
  else
301
- # no nested v3 home (link, xref inside em): keep the text
315
+ # no v3 home in this container (strong inside em, link
316
+ # inside em): keep the child's text - structure is
317
+ # unrepresentable, content is not (#292)
302
318
  text = flatten_inline_text(child)
303
319
  if text && !text.empty?
304
320
  fragments << text
@@ -256,6 +256,11 @@ module Metanorma
256
256
 
257
257
  @collected_footnotes.keys.sort.each do |num|
258
258
  @collected_footnotes[num].each do |entry|
259
+ if entry[:block]
260
+ append_ordered(section, example_result_tag(entry[:block]),
261
+ entry[:block])
262
+ next
263
+ end
259
264
  t = Rfcxml::V3::Text.new
260
265
  # the body paragraph's id (#293): xrefs into the
261
266
  # footnote body resolve to its endnote
@@ -479,6 +484,15 @@ module Metanorma
479
484
  aside = transform_admonition(admonitions[idx])
480
485
  append_ordered(section, :aside, aside) if aside
481
486
  end
487
+ when "pre"
488
+ # clause-level literal blocks render as ascii-art
489
+ # artwork (#296 item 7; the model mapping ships in
490
+ # metanorma-standoc)
491
+ pres = to_array(model_attr(clause, :literal_blocks))
492
+ if pres[idx]
493
+ artwork = transform_pre_to_artwork(pres[idx])
494
+ append_ordered(section, :artwork, artwork) if artwork
495
+ end
482
496
  end
483
497
  end
484
498
  end
@@ -525,6 +539,11 @@ module Metanorma
525
539
  append_ordered(section, :blockquote, bq) if bq
526
540
  end
527
541
 
542
+ to_array(model_attr(clause, :literal_blocks)).each do |pre|
543
+ artwork = transform_pre_to_artwork(pre)
544
+ append_ordered(section, :artwork, artwork) if artwork
545
+ end
546
+
528
547
  to_array(clause.admonitions).each do |admon|
529
548
  aside = transform_admonition(admon)
530
549
  append_ordered(section, :aside, aside) if aside
@@ -29,6 +29,15 @@ module Metanorma
29
29
  end
30
30
  end
31
31
 
32
+ # a bare <dl> directly inside the terms section rendered as
33
+ # nothing at all (metanorma-ietf#376): the term and
34
+ # definitions handlers both pass definition lists through,
35
+ # the terms section itself did not
36
+ to_array(model_attr(terms_node, :definition_lists)).each do |dl|
37
+ list = transform_definition_list(dl)
38
+ safe_append(section, :dl, list) if list
39
+ end
40
+
32
41
  term_entries =
33
42
  terms_node.respond_to?(:term) ? to_array(terms_node.term) : []
34
43
  nested_sections = []
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ietf
3
- VERSION = "3.7.20".freeze
3
+ VERSION = "3.7.22".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-ietf
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.20
4
+ version: 3.7.22
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-24 00:00:00.000000000 Z
11
+ date: 2026-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64