Class: Asciidoctor::Foodogsquared::Extensions::ChatBlock

Inherits:
Extensions::BlockProcessor
  • Object
show all
Defined in:
lib/asciidoctor/foodogsquared/extensions/chat-block.rb

Instance Method Summary collapse

Instance Method Details

#process(parent, reader, attrs) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/asciidoctor/foodogsquared/extensions/chat-block.rb', line 12

def process(parent, reader, attrs)
  attrs['name'] ||= attrs['avatar']

  # Configuring the avatar-related attributes.
  attrs['avatarsdir'] ||= File.expand_path('./avatars', attrs['iconsdir'])
  attrs['avatarstype'] ||= parent.attributes['avatarstype'] || 'avif'
  attrs['avatarsticker'] = "#{attrs['avatar'].to_kebab}/#{attrs['state'].to_kebab}.#{attrs['avatarstype']}"

  block = create_block parent, :chat, nil, attrs, content_model: :compound
  block.add_role 'dialogblock'

  block
end