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 +4 -4
- data/lib/coradoc/mirror/handlers/image.rb +18 -12
- data/lib/coradoc/mirror/node.rb +2 -0
- data/lib/coradoc/mirror/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 576065e7e1df118cef928c6412777012caa0e8a165ef5c596c9d1b331711c8bb
|
|
4
|
+
data.tar.gz: cb78e786ccf1d4686f6d964fa9c0cfa34bc01fe32eb12132ab406baf45f2e509
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
12
|
-
# image plus a `caption` child, matching
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
|
data/lib/coradoc/mirror/node.rb
CHANGED
|
@@ -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
|