Module: Coradoc::Mirror::Handlers::Image
- Defined in:
- lib/coradoc/mirror/handlers/image.rb
Overview
Image handler.
Two emission shapes:
- Ruby legacy (default): bare `image` node, title/caption in attrs.
- JS @metanorma/mirror (`partition_structural: true`): when the
source image is a **block** image with a title, wrap it in a
`figure` node with the image plus a `caption` child, matching
the JS schema. Inline images never wrap, even if they carry a
role or title, because they live inside paragraph flow.
Class Method Summary collapse
Class Method Details
.call(element, context:) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/coradoc/mirror/handlers/image.rb', line 16 def self.call(element, context:) image_node = build_image_node(element) return image_node unless context.partition_structural return image_node if element.inline return image_node unless caption_text?(element) Node::Figure.new( attrs: Node::Figure::Attrs.new(id: element.id, title: caption_value(element)), content: [image_node, Node::Caption.new(content: caption_text_nodes(element, context))] ) end |