Skip to content

Commit

Permalink
resolves #64 preserve attribute entries above tabs block
Browse files Browse the repository at this point in the history
  • Loading branch information
mojavelinux committed Jul 26, 2023
1 parent 9cd2b69 commit f9d1d08
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ For a detailed view of what has changed, refer to the {url-repo}/commits/main[co

* Repurpose example block as open block if filetype is not html

=== Fixed

* Preserve attribute entries above tabs block (#64)

== 1.0.0-beta.5 (2023-05-28) - @mojavelinux

=== Changed
Expand Down
4 changes: 3 additions & 1 deletion lib/asciidoctor/tabs/block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ def process parent, reader, attrs
tabs_role = 'tabs' + (!(block.option? 'nosync') && ((block.option? 'sync') || (doc.option? 'tabs-sync')) ?
((gid = attrs['sync-group-id']) ? %( is-sync data-sync-group-id=#{gid.gsub ' ', ?\u00a0}) : ' is-sync') : '')
tabs_role += (tabs_user_role = attrs['role']) ? %( #{tabs_user_role} is-loading) : ' is-loading'
(tabs = create_open_block parent, nil, { 'id' => tabs_id, 'role' => tabs_role }).title = attrs['title']
tabs_attrs = { 'id' => tabs_id, 'role' => tabs_role }
tabs_attrs[:attribute_entries] = attrs[:attribute_entries] if attrs.key? :attribute_entries
(tabs = create_open_block parent, nil, tabs_attrs).title = attrs['title']
tablist = create_list parent, :ulist, { 'role' => 'tablist' }
panes = {}
set_id_on_tab = (doc.backend == 'html5') || (list_item_supports_id? doc)
Expand Down
41 changes: 41 additions & 0 deletions spec/tabs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,47 @@
(expect actual).to eql expected
end

it 'should preserve attribute entries above tabs block' do
input = <<~'END'
before
:foo: bar
[tabs]
====
foo:: {foo}
====
END
expected = <<~'END'.chomp
<div class="paragraph">
<p>before</p>
</div>
<div id="_tabs_1" class="openblock tabs is-loading">
<div class="content">
<div class="ulist tablist">
<ul>
<li id="_tabs_1_foo" class="tab">
<p>foo</p>
</li>
</ul>
</div>
<div id="_tabs_1_foo--panel" class="tabpanel" aria-labelledby="_tabs_1_foo">
<div class="paragraph">
<p>bar</p>
</div>
</div>
</div>
</div>
END

with_memory_logger :info do |logger|
doc = Asciidoctor.load input
actual = doc.convert
(expect actual).to eql expected
(expect logger).to be_empty
end
end

it 'should not register docinfo processors for embedded document' do
input = hello_tabs
(expect (Asciidoctor.load input).extensions.docinfo_processors?).to be false
Expand Down

0 comments on commit f9d1d08

Please sign in to comment.