Class: Metanorma::Plugin::Lutaml::LutamlDiagramBlock

Inherits:
Asciidoctor::Extensions::BlockProcessor
  • Object
show all
Defined in:
lib/metanorma/plugin/lutaml/lutaml_diagram_block.rb

Instance Method Summary collapse

Instance Method Details

#abort(parent, reader, attrs, msg) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/metanorma/plugin/lutaml/lutaml_diagram_block.rb', line 19

def abort(parent, reader, attrs, msg)
  warn(msg)
  attrs["language"] = "lutaml"
  create_listing_block(
    parent,
    reader.source,
    attrs.reject { |k, v| k == 1 })
end

#process(parent, reader, attrs) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/metanorma/plugin/lutaml/lutaml_diagram_block.rb', line 28

def process(parent, reader, attrs)
  uml_document = ::Lutaml::Uml::Parsers::Dsl.parse(lutaml_temp(reader))
  filename = generate_file(parent, reader, uml_document)
  through_attrs = generate_attrs(attrs)
  through_attrs["target"] = filename
  through_attrs["title"] = uml_document.caption
  create_image_block(parent, through_attrs)
rescue => e
  abort(parent, reader, attrs, e.message)
end