coradoc-adoc 2.0.31 → 2.0.32

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: 22eb5a515f97c8954148e99ef280dd4bb8ac3bed03d59d745291dc3d7ac302c2
4
- data.tar.gz: 0435ded18a2f7895426d1de9aba45c5c3ccaeea442c287fb1f5cd6d14581b117
3
+ metadata.gz: 451e2ccdd5dbbd4771079ee9bdc1041c3ee0d3ff74847237d7f3d4aea5064031
4
+ data.tar.gz: 9f161020aca1c07565f9f20c510114b562925cbfb55d4666db14f1d61a68ed81
5
5
  SHA512:
6
- metadata.gz: cc35eb17f93b7c78fc2f935cf71ef18d76af08eb36a52ab7040d90e735c72a4d1f990339fc414803ccbf767d0b57bf636be79d76940fa8a091e52bcd37091544
7
- data.tar.gz: 8c93968c63d400dfb86d0855c6bb1a2ebc6bbe200a85b07da5d2861771baeacf2beb11cd811c136e912fae302d0003c8aa822f12c73ef2ae5d127ced9caea829
6
+ metadata.gz: 20150d6a118ae76db46737ca68c47b87a1195cd716ee88700de2afdb06094dd3edee9c66a5b224702e20c6333d28c4082d9840e24b590210154abe46643aad7a
7
+ data.tar.gz: a881fc61dd3bce4e276f3db93fd250d3cf0cd0ab18a2e93a296887a416070b43b0da61972818e79ff0d7c00bd9f4af6320bb8cae8976402fff8519943ce05299
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Coradoc
4
+ module AsciiDoc
5
+ module ReferenceMaterializers
6
+ # Render a navigation edge as a first-class CrossReferenceElement
7
+ # — the model-driven xref node the AsciiDoc serializer already
8
+ # knows how to emit (never a raw macro string). Materializing for
9
+ # AsciiDoc fills in the visible text from the authored label or
10
+ # the resolved target's title.
11
+ class Navigation < Coradoc::Reference::Materializer::Base
12
+ class << self
13
+ def kind
14
+ :navigation
15
+ end
16
+
17
+ def presentation
18
+ :any
19
+ end
20
+
21
+ def format
22
+ :asciidoc
23
+ end
24
+ end
25
+
26
+ def materialize(edge:, result:, **)
27
+ text = display_text(edge, result)
28
+ Coradoc::CoreModel::CrossReferenceElement.new(
29
+ target: xref_target(edge.address),
30
+ content: text,
31
+ children: [
32
+ Coradoc::CoreModel::TextElement.new(content: text)
33
+ ]
34
+ )
35
+ end
36
+
37
+ private
38
+
39
+ def xref_target(address)
40
+ [address.target, address.fragment].compact.join('#')
41
+ end
42
+
43
+ def display_text(edge, result)
44
+ return edge.label if edge.label && !edge.label.empty?
45
+ return result.target.title if result.is_a?(Coradoc::Reference::Result::Resolved) && result.target&.title
46
+
47
+ edge.address.to_s
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Coradoc
4
+ module AsciiDoc
5
+ # Materializers rendering resolved reference Edges into
6
+ # AsciiDoc-shaped CoreModel nodes. They live in the format gem
7
+ # (not coradoc core) so format knowledge stays at the spoke of the
8
+ # hub-and-spoke architecture; registration is a load-time side
9
+ # effect via the Materializer registry's global extension point.
10
+ module ReferenceMaterializers
11
+ autoload :Navigation, "#{__dir__}/reference_materializers/navigation"
12
+ end
13
+ end
14
+ end
15
+
16
+ Coradoc::Reference::Materializer::Registry.register_global(
17
+ Coradoc::AsciiDoc::ReferenceMaterializers::Navigation
18
+ )
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Coradoc
4
4
  module AsciiDoc
5
- VERSION = '2.0.31'
5
+ VERSION = '2.0.32'
6
6
  end
7
7
  end
@@ -94,6 +94,12 @@ module Coradoc
94
94
  document.to_adoc
95
95
  end
96
96
  end
97
+
98
+ # AsciiDoc round-trips include:: directives natively — graph-mode
99
+ # documents serialize losslessly, no hydration required.
100
+ def preserves_unresolved_includes?
101
+ true
102
+ end
97
103
  end
98
104
 
99
105
  # Backward-compatible aliases for model classes
@@ -152,3 +158,7 @@ Coradoc.register_format(:asciidoc, Coradoc::AsciiDoc,
152
158
  # Backward-compatibility: Coradoc::Model is now Coradoc::AsciiDoc::Model
153
159
  # This alias is provided for legacy code that hasn't been updated
154
160
  Coradoc::Model = Coradoc::AsciiDoc::Model unless defined?(Coradoc::Model)
161
+
162
+ # Reference materializers for format: :asciidoc. Required (not autoloaded)
163
+ # because registration is a load-time side effect, like register_format.
164
+ require 'coradoc/asciidoc/reference_materializers'
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.31
4
+ version: 2.0.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -235,6 +235,8 @@ files:
235
235
  - lib/coradoc/asciidoc/parser/table.rb
236
236
  - lib/coradoc/asciidoc/parser/term.rb
237
237
  - lib/coradoc/asciidoc/parser/text.rb
238
+ - lib/coradoc/asciidoc/reference_materializers.rb
239
+ - lib/coradoc/asciidoc/reference_materializers/navigation.rb
238
240
  - lib/coradoc/asciidoc/serializer.rb
239
241
  - lib/coradoc/asciidoc/serializer/adoc_serializer.rb
240
242
  - lib/coradoc/asciidoc/serializer/element_registry.rb