Module: Coradoc::AsciiDoc::Transform::AttributeListToMetadata

Defined in:
lib/coradoc/asciidoc/transform/attribute_list_to_metadata.rb

Overview

Single source of truth for AsciiDoc Model::AttributeList -> CoreModel::Metadata conversion (DRY/MECE).

Promotes the first positional attribute to ‘style` and the `role=` named attribute to `role`, matching the AsciiDoc block-header semantics that downstream consumers (coradoc-mirror) dispatch on to pick a JS section type (annex, abstract, …).

Returns nil for anything that isn’t a typed AttributeList so callers can pass through optional/missing inputs without an extra guard.

Class Method Summary collapse

Class Method Details

.call(list) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/coradoc/asciidoc/transform/attribute_list_to_metadata.rb', line 20

def call(list)
  return nil unless list.is_a?(Coradoc::AsciiDoc::Model::AttributeList)

   = Coradoc::CoreModel::Metadata.new
  first_positional = list.positional.first
  ['style'] = first_positional.value if first_positional
  named_role = list.named.find { |n| n.name == 'role' }
  ['role'] = named_role.value.first if named_role&.value&.any?
  
end