diff --git a/lib/asciidoctor/foodogsquared/converters/html5-extended.rb b/lib/asciidoctor/foodogsquared/converters/html5-extended.rb index 40e3cff..57e7cf3 100644 --- a/lib/asciidoctor/foodogsquared/converters/html5-extended.rb +++ b/lib/asciidoctor/foodogsquared/converters/html5-extended.rb @@ -67,6 +67,22 @@ module Asciidoctor::Foodogsquared::Converters html.to_html(indent: 2) end + def convert_sidebar(node) + html = Nokogiri::XML::DocumentFragment.parse '' + aside = html.first_element_child + add_common_attributes node, aside + + if node.title? + html.document.create_element 'strong' do |strong| + strong.add_class 'title' + strong.content = node.captioned_title + aside.add_child strong + end + end + + aside.inner_html += node.content + html.to_html(indent: 2) + end # A modified version of the audio node except it can accept multiple # sources. diff --git a/spec/html5_extended_converter.rb b/spec/html5_extended_converter.rb index 36544bf..c4d2174 100644 --- a/spec/html5_extended_converter.rb +++ b/spec/html5_extended_converter.rb @@ -161,4 +161,52 @@ describe Asciidoctor::Foodogsquared::Converters::HTML5Modified do actual = (Asciidoctor.convert input).chomp (expect actual).to eq expected.chomp end + + it 'should have a more semantic sidebar block' do + input = <<~INPUT + **** + A sidebar is used for auxiliary bits of content. + **** + INPUT + + expected = <<~HTML + + HTML + + actual = (Asciidoctor.convert input).chomp + (expect actual).to eq expected.chomp + end + + it 'should have a more semantic sidebar block with a title' do + input = <<~INPUT + .A sidebar title + **** + A sidebar is used for auxiliary bits of content. + **** + INPUT + + expected = <<~HTML + + HTML + + actual = (Asciidoctor.convert input).chomp + (expect actual).to eq expected.chomp + end + + it 'should have a more semantic sidebar block with a title, an ID, and several roles' do + input = <<~INPUT + [#sidebar-id.several.roles] + .A sidebar title + **** + A sidebar is used for auxiliary bits of content. + **** + INPUT + + expected = <<~HTML + + HTML + + actual = (Asciidoctor.convert input).chomp + (expect actual).to eq expected.chomp + end end