coradoc-adoc 2.0.15 → 2.0.16

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: 258eb5dcb2991ad51c70456519c056ae29672aeee86cde93e5eeb20a32d5427d
4
- data.tar.gz: c19119a118adc0121d5d627287bd435349a09647636729a57dd0ce005de5a2f1
3
+ metadata.gz: e3b72474cf0652bc8f5702011009cab0caeb9dd5180a6f17510a2e081286951d
4
+ data.tar.gz: 8218895ed5672fe9932747a025c54621ba02870daea6f964b1cc28d506968a1d
5
5
  SHA512:
6
- metadata.gz: e7defb7e91f6db2f0b09d1a433d4f662254ebcb93c01125a419127881b9e15854c3f78c226b203dc8d818fc3c8d5f8615c05edfed2afced0f4f273881078b150
7
- data.tar.gz: 17cc53fb4f42adcd77e2817a04087c2f49eec3643010905fecf1dfab887b936780a7a1b9e665bcbdd90a296b3fbaa7a070a7e98098364e87b7dda25d1d8879d9
6
+ metadata.gz: 46c11254ea13b32498f66d11eb0ead0d13df136f7a0cca65e701373cf48f1edf9d9e1beb447553ddc1a14e4459052d559038aa1b6edb580731a6f91d27969616
7
+ data.tar.gz: 3d6b4701f38cfd0042bcd14d77d094c6c48626bc85ffab3557a274f2fd90041d1df95f37a156a18ef7a73e8d2d9d4900f8048c8c8d021425ddd8ec38a587db84
@@ -35,11 +35,16 @@ module Coradoc
35
35
 
36
36
  # Walks the input children left-to-right. When a paragraph whose
37
37
  # content is composed entirely of `<N> text` lines follows a
38
- # verbatim block (SourceBlock or ListingBlock), each `<N>` line
39
- # becomes a Callout attached to that block instead of a separate
40
- # paragraph.
38
+ # verbatim block (SourceBlock, ListingBlock, LiteralBlock), each
39
+ # `<N>` line becomes a Callout attached to that block instead of
40
+ # a separate paragraph.
41
41
  #
42
- # Annotations that do not follow a verbatim block are preserved
42
+ # Annotations that follow any other block (e.g. a Table) cannot
43
+ # attach as Callouts — those blocks don't carry callouts. Convert
44
+ # the paragraph to an ordered ListBlock so the downstream
45
+ # serializer renders `1. text` instead of leaking `<N>` markers.
46
+ #
47
+ # Annotations with no preceding block at all are preserved
43
48
  # verbatim — they may be legitimate prose.
44
49
  def merge(children)
45
50
  children.each.with_object([]) do |child, result|
@@ -47,6 +52,8 @@ module Coradoc
47
52
  target = annotations && preceding_verbatim_block(result)
48
53
  if target
49
54
  target.callouts.concat(annotations)
55
+ elsif annotations && result.any?
56
+ result << callout_list(annotations)
50
57
  else
51
58
  result << child
52
59
  end
@@ -55,6 +62,21 @@ module Coradoc
55
62
 
56
63
  private
57
64
 
65
+ def callout_list(annotations)
66
+ ordered = annotations.sort_by { |c| c.index || Float::INFINITY }
67
+ items = ordered.map do |callout|
68
+ Coradoc::CoreModel::ListItem.new(
69
+ marker: '.',
70
+ content: callout.content.to_s
71
+ )
72
+ end
73
+ Coradoc::CoreModel::ListBlock.new(
74
+ marker_type: 'ordered',
75
+ marker_level: 1,
76
+ items: items
77
+ )
78
+ end
79
+
58
80
  # Returns an Array of Callout if the paragraph is entirely
59
81
  # callout annotations, otherwise nil.
60
82
  def extract_annotations(child)
@@ -150,10 +150,19 @@ module Coradoc
150
150
  )
151
151
  else
152
152
  content_lines = lines.map { |line| ToCoreModel.extract_text_content(line) }.join("\n")
153
+ children = lines.map do |line|
154
+ inline = ToCoreModel.transform_inline_content(line)
155
+ inline = [Coradoc::CoreModel::TextContent.new(text: "")] if inline.empty?
156
+ Coradoc::CoreModel::ParagraphBlock.new(
157
+ content: ToCoreModel.extract_text_content(line),
158
+ children: Array(inline)
159
+ )
160
+ end
153
161
  klass.new(
154
162
  id: block.id,
155
163
  title: ToCoreModel.extract_title_text(block.title),
156
164
  content: content_lines,
165
+ children: children,
157
166
  language: ToCoreModel.extract_block_language(block),
158
167
  **extra_attrs
159
168
  )
@@ -426,6 +426,8 @@ module Coradoc
426
426
  content
427
427
  when Array
428
428
  content.map { |item| safe_content_to_string(item) }.join
429
+ when Coradoc::CoreModel::Base
430
+ content.flat_text
429
431
  when Lutaml::Model::Serializable
430
432
  if content.is_a?(Coradoc::AsciiDoc::Model::Base)
431
433
  content.to_adoc
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Coradoc
4
4
  module AsciiDoc
5
- VERSION = '2.0.15'
5
+ VERSION = '2.0.16'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coradoc-adoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.15
4
+ version: 2.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.