diff --git a/lib/asciidoctor/foodogsquared/converter.rb b/lib/asciidoctor/foodogsquared/converter.rb index 1c6f835..c72256f 100644 --- a/lib/asciidoctor/foodogsquared/converter.rb +++ b/lib/asciidoctor/foodogsquared/converter.rb @@ -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
- #{node.attributes['name']} + #{node.attributes['avatar']}
- #{node.attributes['name']} + #{node.attributes['avatar']} #{node.content}
diff --git a/lib/asciidoctor/foodogsquared/extensions/chat-block.rb b/lib/asciidoctor/foodogsquared/extensions/chat-block.rb index 08244e7..5abaae9 100644 --- a/lib/asciidoctor/foodogsquared/extensions/chat-block.rb +++ b/lib/asciidoctor/foodogsquared/extensions/chat-block.rb @@ -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'