coradoc-mirror 0.1.5 → 0.1.6

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: ec671d9e6bbd3654635451d5a9ae2284f7e778f313b56e4e8d87e237e853b15e
4
- data.tar.gz: 51f63185d93bda861e6f545fdd4bceb0e07a9516db1d8d51011fda4e08236b35
3
+ metadata.gz: 576065e7e1df118cef928c6412777012caa0e8a165ef5c596c9d1b331711c8bb
4
+ data.tar.gz: cb78e786ccf1d4686f6d964fa9c0cfa34bc01fe32eb12132ab406baf45f2e509
5
5
  SHA512:
6
- metadata.gz: 40d4b935ed85cdfb2a0d4845807df32367541498c4921879d5875194f8c1572402ad7bd809055cdb285b9ea2b7457c1847c8039c861c88db9c5094ea42d6edfa
7
- data.tar.gz: 91b105b79f7eef2230869c1cc386d0ec105b08346a36e66f4e18e95b6931a66382ae786910c9d6bc72c04e287dd9f856a38cc569dadfe3a9f2304f710186e0f7
6
+ metadata.gz: a316f677682b17a95a7d86f4e93504a035062c8b1ae39f5b0bcacd20a26ae839534c4dae6458bf54522400ff0f39ce8a899681e71298ab949899f6c7b2136266
7
+ data.tar.gz: bd09f0bb9fb15365bb55f305aa85af2772dbc5dd650ab017c5814ceb3d5dae80d60db6930573037d798b0f203967a6b150316252a92bcec52be8929fe0db7fac
@@ -8,13 +8,16 @@ module Coradoc
8
8
  # Two emission shapes:
9
9
  # - Ruby legacy (default): bare `image` node, title/caption in attrs.
10
10
  # - JS @metanorma/mirror (`partition_structural: true`): when the
11
- # source image has a title, wrap it in a `figure` node with the
12
- # image plus a `caption` child, matching the JS schema.
11
+ # source image is a **block** image with a title, wrap it in a
12
+ # `figure` node with the image plus a `caption` child, matching
13
+ # the JS schema. Inline images never wrap, even if they carry a
14
+ # role or title, because they live inside paragraph flow.
13
15
  module Image
14
16
  def self.call(element, context:)
15
17
  image_node = build_image_node(element)
16
18
 
17
19
  return image_node unless context.partition_structural
20
+ return image_node if element.inline
18
21
  return image_node unless caption_text?(element)
19
22
 
20
23
  Node::Figure.new(
@@ -27,16 +30,19 @@ module Coradoc
27
30
  private
28
31
 
29
32
  def build_image_node(element)
30
- Node::Image.new(
31
- attrs: Node::Image::Attrs.new(
32
- src: element.src,
33
- alt: element.alt,
34
- title: element.title,
35
- caption: element.caption,
36
- width: element.width,
37
- height: element.height,
38
- inline: element.inline || nil
39
- )
33
+ Node::Image.new(attrs: image_attrs(element))
34
+ end
35
+
36
+ def image_attrs(element)
37
+ Node::Image::Attrs.new(
38
+ src: element.src,
39
+ alt: element.alt,
40
+ title: element.title,
41
+ caption: element.caption,
42
+ width: element.width,
43
+ height: element.height,
44
+ role: element.role,
45
+ inline: element.inline
40
46
  )
41
47
  end
42
48
 
@@ -496,6 +496,7 @@ module Coradoc
496
496
  attribute :caption, :string
497
497
  attribute :width, :string
498
498
  attribute :height, :string
499
+ attribute :role, :string
499
500
  attribute :inline, :boolean
500
501
 
501
502
  key_value do
@@ -505,6 +506,7 @@ module Coradoc
505
506
  map 'caption', to: :caption
506
507
  map 'width', to: :width
507
508
  map 'height', to: :height
509
+ map 'role', to: :role
508
510
  map 'inline', to: :inline
509
511
  end
510
512
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Coradoc
4
4
  module Mirror
5
- VERSION = '0.1.5'
5
+ VERSION = '0.1.6'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coradoc-mirror
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.