lib/asciidoctor_fb2.rb in asciidoctor-fb2-0.2.2 vs lib/asciidoctor_fb2.rb in asciidoctor-fb2-0.2.3
- old
+ new
@@ -135,11 +135,11 @@
end
# @param node [Asciidoctor::Block]
def convert_verse(node)
body = node.content&.split("\n\n")&.map do |stanza|
- %(<stanza>\n<v>#{stanza.split("\n").join("</v>\n<v>")}</v>\n</stanza>)
+ %(<stanza>\n<v>#{stanza.split("\n") * "</v>\n<v>"}</v>\n</stanza>)
end&.join("\n")
citetitle = node.attr('citetitle')
citetitle_tag = citetitle.nil_or_empty? ? '' : %(<title>#{citetitle}</title>)
@@ -153,10 +153,15 @@
</poem>)
end
# @param node [Asciidoctor::Block]
def convert_listing(node)
+ convert_literal(node)
+ end
+
+ # @param node [Asciidoctor::Block]
+ def convert_literal(node)
lines = []
node.content.split("\n").each do |line|
lines << %(<p><code>#{line}</code></p>)
end
lines << '<empty-line/>' unless node.has_role?('last')
@@ -184,15 +189,15 @@
# @param node [Asciidoctor::Inline]
def convert_inline_menu(node)
caret = ' <strong>›</strong> '
menu = node.attr('menu')
menuitem = node.attr('menuitem')
- submenus = node.attr('submenus').join(%(</b>#{caret}<b>))
+ submenus = node.attr('submenus') * %(</b>#{caret}<b>)
result = %(<strong>#{menu}</strong>)
- result += %(#{caret}<strong>#{submenus}</strong>) unless submenus.empty?
- result += %(#{caret}<strong>#{menuitem}</strong>) unless menuitem.empty?
+ result += %(#{caret}<strong>#{submenus}</strong>) unless submenus.nil_or_empty?
+ result += %(#{caret}<strong>#{menuitem}</strong>) unless menuitem.nil_or_empty?
result
end
# @param node [Asciidoctor::Inline]
@@ -205,11 +210,11 @@
%([<strong>#{node.text}</strong>])
end
# @param node [Asciidoctor::Inline]
def convert_inline_kbd(node)
- %(<strong>#{node.attr('keys').join('</strong>+<strong>')}</strong>)
+ %(<strong>#{node.attr('keys') * '</strong>+<strong>'}</strong>)
end
# @param node [Asciidoctor::Inline]
def convert_inline_anchor(node) # rubocop:disable Metrics/MethodLength
case node.type
@@ -285,10 +290,17 @@
</p>)]
lines << '<empty-line/>' unless node.has_role?('last')
lines * "\n"
end
+ # @param node [Asciidoctor::Block]
+ def convert_sidebar(node)
+ title_tag = node.title.nil_or_empty? ? '' : %(<p><strong>#{node.title}</strong></p>)
+ %(#{title_tag}
+#{node.content})
+ end
+
# @param node [Asciidoctor::List]
def convert_ulist(node)
lines = []
@stack ||= []
@@ -363,10 +375,10 @@
when :asciidoc
cell.content
when :literal
%(<p><pre>#{cell.text}</pre></p>)
else
- (cell_content = cell.content).empty? ? '' : %(<p>#{cell_content.join "</p>\n<p>"}</p>)
+ (cell_content = cell.content).empty? ? '' : %(<p>#{cell_content * "</p>\n<p>"}</p>)
end
end
cell_tag_name = (tsec == :head || cell.style == :header ? 'th' : 'td')
cell_attrs = [