Class: Metanorma::Html::Drops::NoteDrop

Inherits:
BlockElementDrop show all
Defined in:
lib/metanorma/html/drops/note_drop.rb

Instance Attribute Summary

Attributes inherited from BlockElementDrop

#content_html, #css_class, #id, #label_html, #type

Class Method Summary collapse

Methods inherited from BlockElementDrop

#initialize

Constructor Details

This class inherits a constructor from Metanorma::Html::Drops::BlockElementDrop

Class Method Details

.from_model(note, renderer:) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/metanorma/html/drops/note_drop.rb', line 7

def self.from_model(note, renderer:)
  id = renderer.safe_attr(note, :id)
  label = renderer.extract_block_label(note, "NOTE")

  content_parts = []
  if note.content && !note.content.empty?
    note.content.each do |para|
      content_parts << (renderer.render_paragraph(para) || "")
    end
  else
    inline = renderer.render_mixed_inline(note)
    content_parts << inline if inline
  end
  content_parts << (renderer.render_note_children(note) || "")
  content_html = content_parts.join

  new(
    id: id,
    label_html: renderer.escape_html(label),
    content_html: content_html,
    css_class: "note-block",
  )
end