Class: Docbook::Mirror::Handlers::Annotation

Inherits:
Object
  • Object
show all
Defined in:
lib/docbook/mirror/handlers/annotation.rb

Class Method Summary collapse

Class Method Details

.call(element, context:) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/docbook/mirror/handlers/annotation.rb', line 7

def self.call(element, context:)
  attrs = { xml_id: element.xml_id }.compact
  content = []
  if element.para&.any?
    element.para.filter_map do |p|
      context.paragraph_handler(p)
    end.each { |n| content << n }
  else
    text = context.extract_text(element)
    content << context.text_node(text) unless text.empty?
  end
  return nil if content.empty?

  Node.new(type: "annotation", attrs: attrs, content: content)
end