diff --git a/htmlbook-autogen/block_example.html.erb b/htmlbook-autogen/block_example.html.erb
index b29b4f0..df4684c 100644
--- a/htmlbook-autogen/block_example.html.erb
+++ b/htmlbook-autogen/block_example.html.erb
@@ -1,4 +1,9 @@
-<%#encoding:UTF-8%>
data-type="example"<%= attr?('role') ? %( class="#{attr 'role'}") : nil %>>
+<%#encoding:UTF-8%><% if option? 'collapsible' %>
<%= attr?('role') ? %( class="#{attr 'role'}") : nil %>>
+<%= title %>
+
+<%= content %>
+
+ <% else %>
data-type="example"<%= attr?('role') ? %( class="#{attr 'role'}") : nil %>>
<%= title %>
-<%= content
-%>
+<%= content
+%>
<% end %>
diff --git a/htmlbook/block_example.html.erb b/htmlbook/block_example.html.erb
index b29b4f0..df4684c 100644
--- a/htmlbook/block_example.html.erb
+++ b/htmlbook/block_example.html.erb
@@ -1,4 +1,9 @@
-<%#encoding:UTF-8%> data-type="example"<%= attr?('role') ? %( class="#{attr 'role'}") : nil %>>
+<%#encoding:UTF-8%><% if option? 'collapsible' %>
<%= attr?('role') ? %( class="#{attr 'role'}") : nil %>>
+<%= title %>
+
+<%= content %>
+
+ <% else %>
data-type="example"<%= attr?('role') ? %( class="#{attr 'role'}") : nil %>>
<%= title %>
-<%= content
-%>
+<%= content
+%>
<% end %>
diff --git a/spec/htmlbook_spec.rb b/spec/htmlbook_spec.rb
index c3a2327..5e1cdd1 100755
--- a/spec/htmlbook_spec.rb
+++ b/spec/htmlbook_spec.rb
@@ -203,6 +203,45 @@
expect(html.xpath("//div[@data-type='example'][1]/pre[@data-type='programlisting']/@data-code-language").text).to eq("php")
end
+ # Tests collapsible block (details tag) support
+ it "should convert collapsible blocks to details/summary elements" do
+ html = Nokogiri::HTML(convert("
+.Details
+[%collapsible]
+====
+This would be the show and hide!
+====
+"))
+ expect(html.xpath("//details/summary[@class='title']").text).to eq("Details")
+ expect(html.xpath("//details/div[@class='content']/p").text).to eq("This would be the show and hide!")
+ end
+
+ it "should convert collapsible blocks with an id" do
+ html = Nokogiri::HTML(convert("
+[[my-details]]
+.Click to expand
+[%collapsible]
+====
+Hidden content here.
+====
+"))
+ expect(html.xpath("//details/@id").text).to eq("my-details")
+ expect(html.xpath("//details/summary[@class='title']").text).to eq("Click to expand")
+ expect(html.xpath("//details/div[@class='content']/p").text).to eq("Hidden content here.")
+ end
+
+ it "should convert collapsible blocks with a role attribute" do
+ html = Nokogiri::HTML(convert("
+.Summary text
+[%collapsible,role='special']
+====
+Content with a role.
+====
+"))
+ expect(html.xpath("//details/@class").text).to eq("special")
+ expect(html.xpath("//details/summary[@class='title']").text).to eq("Summary text")
+ end
+
it "should convert line numbering attribute in informal code listing" do
html = Nokogiri::HTML(convert("
[source, php, linenums]