mirror of
https://github.com/foo-dogsquared/asciidoctor-foodogsquared-extensions.git
synced 2025-01-30 22:57:56 +00:00
Update chat block attributes
This commit is contained in:
parent
5cb366fb2a
commit
586cc8daee
@ -12,16 +12,15 @@ module Asciidoctor::Foodogsquared::Converter
|
||||
attributes << %(id="#{node.id}") if node.id
|
||||
attributes << %(class="#{node.role}") if node.role
|
||||
|
||||
avatar_sticker = node.attributes['avatarsticker']
|
||||
avatar_uri = node.parent.image_uri avatar_sticker, 'avatarsdir'
|
||||
avatar_uri = node.parent.image_uri "#{node.attr 'avatarsticker'}/#{node.attr 'state'}.#{node.attr 'avatarstype'}", 'avatarsdir'
|
||||
|
||||
<<~HTML
|
||||
<div role="figure" #{attributes.join ' '}>
|
||||
<div class="dialogblock-avatar">
|
||||
<img src="#{avatar_uri}" alt="#{node.attributes['name']}">
|
||||
<img src="#{avatar_uri}" alt="#{node.attributes['avatar']}">
|
||||
</div>
|
||||
<div class="dialogblock-text">
|
||||
<small>#{node.attributes['name']}</small>
|
||||
<small>#{node.attributes['avatar']}</small>
|
||||
#{node.content}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -9,13 +9,13 @@ module Asciidoctor::Foodogsquared::Extensions
|
||||
name_positional_attributes 'avatar', 'state'
|
||||
default_attributes 'state' => 'default'
|
||||
|
||||
def process(parent, reader, attrs)
|
||||
attrs['name'] ||= attrs['avatar']
|
||||
def process(parent, _, attrs)
|
||||
doc_attrs = parent.document.attributes
|
||||
|
||||
# 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']}"
|
||||
attrs['avatarsdir'] ||= doc_attrs['avatarsdir'] || File.expand_path('./avatars', attrs['iconsdir'])
|
||||
attrs['avatarstype'] ||= doc_attrs['avatarstype'] || 'avif'
|
||||
attrs['avatarsticker'] = attrs['avatar'].to_kebab
|
||||
|
||||
block = create_block parent, :chat, nil, attrs, content_model: :compound
|
||||
block.add_role 'dialogblock'
|
||||
|
Loading…
Reference in New Issue
Block a user