mirror of
https://github.com/foo-dogsquared/asciidoctor-foodogsquared-extensions.git
synced 2025-01-30 22:57:56 +00:00
Add sidebar block for HTML5-modified
This commit is contained in:
parent
d868c0964c
commit
e7e973d1c6
@ -67,6 +67,22 @@ module Asciidoctor::Foodogsquared::Converters
|
||||
html.to_html(indent: 2)
|
||||
end
|
||||
|
||||
def convert_sidebar(node)
|
||||
html = Nokogiri::XML::DocumentFragment.parse '<aside></aside>'
|
||||
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.
|
||||
|
@ -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
|
||||
<aside><p>A sidebar is used for auxiliary bits of content.</p></aside>
|
||||
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
|
||||
<aside><strong class="title">A sidebar title</strong><p>A sidebar is used for auxiliary bits of content.</p></aside>
|
||||
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
|
||||
<aside id="sidebar-id" class="several roles"><strong class="title">A sidebar title</strong><p>A sidebar is used for auxiliary bits of content.</p></aside>
|
||||
HTML
|
||||
|
||||
actual = (Asciidoctor.convert input).chomp
|
||||
(expect actual).to eq expected.chomp
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user