Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sidebars for semantic HTML 5 converter #4545

Open
wants to merge 1 commit into
base: feature/html-converter-next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/asciidoctor/converter/semantic_html5.rb
Expand Up @@ -207,6 +207,18 @@ def convert_inline_menu node
end
end

def convert_sidebar node
attributes = common_html_attributes node.id, node.role

ret = [ %(<aside#{attributes}>) ]
if node.title?
ret << %(<p role="heading"><strong class="title">#{node.title}</strong></p>)
end
ret << node.content
ret << %(</aside>)
ret.join LF
end

def generate_section_numbering node
level = node.level
doc_attrs = node.document.attributes
Expand Down
@@ -0,0 +1,11 @@
This is a paragraph.

.Sidebar Title
[#the_sidebar]
****
This is a sidebar.

This is another paragraph in the sidebar.
****

This is a paragraph.
@@ -0,0 +1,15 @@
<p>
This is a paragraph.
</p>
<aside id="the_sidebar">
<p role="heading"><strong class="title">Sidebar Title</strong></p>
<p>
This is a sidebar.
</p>
<p>
This is another paragraph in the sidebar.
</p>
</aside>
<p>
This is a paragraph.
</p>
@@ -0,0 +1,11 @@
This is a paragraph.

.Sidebar Title
[.role1.role2]
****
This is a sidebar.

This is another paragraph in the sidebar.
****

This is a paragraph.
@@ -0,0 +1,15 @@
<p>
This is a paragraph.
</p>
<aside class="role1 role2">
<p role="heading"><strong class="title">Sidebar Title</strong></p>
<p>
This is a sidebar.
</p>
<p>
This is another paragraph in the sidebar.
</p>
</aside>
<p>
This is a paragraph.
</p>
@@ -0,0 +1,10 @@
This is a paragraph.

.Sidebar Title
****
This is a sidebar.

This is another paragraph in the sidebar.
****

This is a paragraph.
@@ -0,0 +1,15 @@
<p>
This is a paragraph.
</p>
<aside>
<p role="heading"><strong class="title">Sidebar Title</strong></p>
<p>
This is a sidebar.
</p>
<p>
This is another paragraph in the sidebar.
</p>
</aside>
<p>
This is a paragraph.
</p>
9 changes: 9 additions & 0 deletions test/fixtures/semantic-html5-scenarios/sidebar-multi.adoc
@@ -0,0 +1,9 @@
This is a paragraph.

****
This is a sidebar.

This is another paragraph in the sidebar.
****

This is a paragraph.
14 changes: 14 additions & 0 deletions test/fixtures/semantic-html5-scenarios/sidebar-multi.html
@@ -0,0 +1,14 @@
<p>
This is a paragraph.
</p>
<aside>
<p>
This is a sidebar.
</p>
<p>
This is another paragraph in the sidebar.
</p>
</aside>
<p>
This is a paragraph.
</p>
@@ -0,0 +1,6 @@
This is a paragraph.

[sidebar#the_sidebar]
This is a sidebar.

This is a paragraph.
@@ -0,0 +1,9 @@
<p>
This is a paragraph.
</p>
<aside id="the_sidebar">
This is a sidebar.
</aside>
<p>
This is a paragraph.
</p>
@@ -0,0 +1,7 @@
This is a paragraph.

[sidebar#the_sidebar]
.Sidebar Title
This is a sidebar.

This is a paragraph.
@@ -0,0 +1,10 @@
<p>
This is a paragraph.
</p>
<aside id="the_sidebar">
<p role="heading"><strong class="title">Sidebar Title</strong></p>
This is a sidebar.
</aside>
<p>
This is a paragraph.
</p>
@@ -0,0 +1,7 @@
This is a paragraph.

[sidebar]
.Sidebar Title
This is a sidebar.

This is a paragraph.
@@ -0,0 +1,10 @@
<p>
This is a paragraph.
</p>
<aside>
<p role="heading"><strong class="title">Sidebar Title</strong></p>
This is a sidebar.
</aside>
<p>
This is a paragraph.
</p>
6 changes: 6 additions & 0 deletions test/fixtures/semantic-html5-scenarios/sidebar-single.adoc
@@ -0,0 +1,6 @@
This is a paragraph.

[sidebar]
This is a sidebar.

This is a paragraph.
9 changes: 9 additions & 0 deletions test/fixtures/semantic-html5-scenarios/sidebar-single.html
@@ -0,0 +1,9 @@
<p>
This is a paragraph.
</p>
<aside>
This is a sidebar.
</aside>
<p>
This is a paragraph.
</p>