Skip to content

Commit

Permalink
Merge 'veselov-13': support block table col style
Browse files Browse the repository at this point in the history
Add support for AsciiDoc "a" operator block-level table styling, which
supports block elements in a table cell by internally nesting a
separate document.

Thanks to @veselov for contributing this fix.

Closes both
<#13> and
<#1>.

See <#14>.
  • Loading branch information
owenh000 committed Jun 28, 2021
2 parents 926c5fc + fc133ae commit 9cf003c
Show file tree
Hide file tree
Showing 6 changed files with 199 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/asciidoctor-multipage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def generate_nav_links(doc)
# Html5Converter convert_outline().
def generate_outline(node, opts = {})
# Do the same as Html5Converter convert_outline() here
return unless node.sections?
return unless node.sections? && node.sections.length > 0
sectnumlevels = opts[:sectnumlevels] || (node.document.attributes['sectnumlevels'] || 3).to_i
toclevels = opts[:toclevels] || (node.document.attributes['toclevels'] || 2).to_i
sections = node.sections
Expand Down
112 changes: 112 additions & 0 deletions test/black-box-docs/table-block-operator/_oops.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<div id="toc" class="toc">
<div id="toctitle">Table of Contents</div>
<p><span class="toc-root"><a href="table-block-operator.html">TOP</a></span></p><ul class="sectlevel1">
<li><a href="_second.html">SECOND</a>
<ul class="sectlevel2">
<li><a href="_oops.html"><span class="toc-current">OOPS</span></a>
</li>
</ul>
</li>
</ul>
</div>
<div class="sect2">
<h3 id="_oops">OOPS</h3>
<div class="sect3">
<h4 id="_danger">DANGER</h4>
<div class="paragraph">
<p>This tests the use of the AsciiDoc "a" block-level styling for a single cell.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">abc.${ext}</p></td>
<td class="tableblock halign-left valign-top"><div class="content"><div class="ulist">
<ul>
<li>
<p>item</p>
</li>
</ul>
</div>
<div class="ulist">
<ul>
</ul>
</div>
<div class="paragraph nav-footer">
<p></p>
</div></div></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The following table from the
<a href="https://docs.asciidoctor.org/asciidoc/latest/tables/format-column-content/#use-asciidoc-block-elements-in-a-column">AsciiDoc
Language Documentation</a> uses the "a" operator for the entire first column.</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Column with the <code>a</code> style operator applied to its specifier</th>
<th class="tableblock halign-left valign-top">Column using the default style</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="ulist">
<ul>
<li>
<p>List item 1</p>
</li>
<li>
<p>List item 2</p>
</li>
<li>
<p>List item 3</p>
</li>
</ul>
</div>
<div class="ulist">
<ul>
</ul>
</div>
<div class="paragraph nav-footer">
<p></p>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">* List item 1
* List item 2
* List item 3</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="listingblock">
<div class="content">
<pre class="highlight"><code class="language-python" data-lang="python">import os
print "%s" %(os.uname())</code></pre>
</div>
</div>
<div class="ulist">
<ul>
</ul>
</div>
<div class="paragraph nav-footer">
<p></p>
</div></div></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">[source,python]
----
import os
print ("%s" %(os.uname()))
----</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="paragraph nav-footer">
<p>↑ Up: <a href="_second.html">SECOND</a> | ⌂ Home: <a href="table-block-operator.html">TOP</a></p>
</div>
19 changes: 19 additions & 0 deletions test/black-box-docs/table-block-operator/_second.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<div id="toc" class="toc">
<div id="toctitle">Table of Contents</div>
<p><span class="toc-root"><a href="table-block-operator.html">TOP</a></span></p>
</div>
<div class="sect1">
<h2 id="_second">SECOND</h2>
<div class="sectionbody">
<div class="ulist">
<ul>
<li>
<p><a href="_oops.html">OOPS</a></p>
</li>
</ul>
</div>
</div>
</div>
<div class="paragraph nav-footer">
<p>↑ Up: <a href="table-block-operator.html">TOP</a> | Next: <a href="_oops.html">OOPS</a> →</p>
</div>
49 changes: 49 additions & 0 deletions test/black-box-docs/table-block-operator/table-block-operator.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
= TOP
:toc:
:multipage-level: 2

== SECOND

=== OOPS

==== DANGER

This tests the use of the AsciiDoc "a" block-level styling for a single cell.

[cols=","]
|===
|abc.$\{ext} a|
* item

|===

The following table from the
link:https://docs.asciidoctor.org/asciidoc/latest/tables/format-column-content/#use-asciidoc-block-elements-in-a-column[AsciiDoc
Language Documentation] uses the "a" operator for the entire first column.

[cols="2a,2"]
|===
|Column with the `a` style operator applied to its specifier |Column using the default style

|
* List item 1
* List item 2
* List item 3
|
* List item 1
* List item 2
* List item 3

|
[source,python]
----
import os
print "%s" %(os.uname())
----
|
[source,python]
----
import os
print ("%s" %(os.uname()))
----
|===
17 changes: 17 additions & 0 deletions test/black-box-docs/table-block-operator/table-block-operator.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div id="toc" class="toc">
<div id="toctitle">Table of Contents</div>
<p><span class="toc-root toc-current"><a href="table-block-operator.html">TOP</a></span></p><ul class="sectlevel1">
<li><a href="_second.html">SECOND</a>
</li>
</ul>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="_second.html">SECOND</a></p>
</li>
</ul>
</div>
<div class="paragraph nav-footer">
<p>Next: <a href="_second.html">SECOND</a> →</p>
</div>
2 changes: 1 addition & 1 deletion test/test_asciidoctor-multipage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def test_black_box_docs
Dir.foreach(dir) do |filename|
next if filename == '.' or filename == '..'
doc_path = File.join(dir, filename)
next if !File.directory?(doc_path)
next unless File.directory?(doc_path)
adoc_path = File.join(doc_path, filename + '.adoc')
doc = Asciidoctor.convert_file(adoc_path,
:to_dir => 'test/out',
Expand Down

0 comments on commit 9cf003c

Please sign in to comment.