Skip to content

Commit

Permalink
Merge pull request #1624 from mojavelinux/issue-1582
Browse files Browse the repository at this point in the history
resolves #1582 don't include default toc in nested document
  • Loading branch information
mojavelinux committed Dec 22, 2015
2 parents a5574c9 + 5f112cd commit d46abe7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/asciidoctor/converter/html5.rb
Expand Up @@ -270,11 +270,13 @@ def embedded node
end
end

if (node.attr? 'toc') && !['macro', 'preamble'].include?(node.attr 'toc-placement')
result << %(<div id="toc" class="toc">
unless node.nested?
if (node.attr? 'toc') && !['macro', 'preamble'].include?(node.attr 'toc-placement')
result << %(<div id="toc" class="toc">
<div id="toctitle">#{node.attr 'toc-title'}</div>
#{outline node}
</div>)
end
end

result << node.content
Expand Down Expand Up @@ -952,6 +954,7 @@ def video node
asset_uri_scheme = %(#{asset_uri_scheme}:)
end
rel_param_val = (node.option? 'related') ? 1 : 0
# NOTE start and end must be seconds (t parameter allows XmYs where X is minutes and Y is seconds)
start_param = (node.attr? 'start', nil, false) ? %(&amp;start=#{node.attr 'start'}) : nil
end_param = (node.attr? 'end', nil, false) ? %(&amp;end=#{node.attr 'end'}) : nil
autoplay_param = (node.option? 'autoplay') ? '&amp;autoplay=1' : nil
Expand Down
18 changes: 18 additions & 0 deletions test/tables_test.rb
Expand Up @@ -856,6 +856,24 @@
assert_css 'table > tbody > tr > td:nth-child(2) table > tbody > tr > td', output, 2
end

test 'toc from parent document should not be included in an AsciiDoc table cell' do
input = <<-EOS
= Document Title
:toc:
== Section A
[cols="1a"]
|===
|AsciiDoc content
|===
EOS

output = render_string input
assert_css '.toc', output, 1
assert_css 'table .toc', output, 0
end

test 'nested document in AsciiDoc cell should not see doctitle of parent' do
input = <<-EOS
= Document Title
Expand Down

0 comments on commit d46abe7

Please sign in to comment.