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
# 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_html = renderer.capture_output do
    if note.content && !note.content.empty?
      note.content.each { |para| renderer.render_paragraph(para) }
    else
      renderer.render_mixed_inline(note)
    end
    note.ul&.each { |ul| renderer.render_unordered_list(ul) }
    note.ol&.each { |ol| renderer.render_ordered_list(ol) }
    note.dl&.then { |dl| renderer.render_definition_list(dl) }
  end

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