Multiple paragraphs in AsciiDoctor table cell
Asked Answered
N

2

7

Edit: Since my problem seems to be specific to my setup, I provide a complete minimal working example here.

This is my maven setup (pom.xml):

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>foo</groupId>
    <artifactId>bar</artifactId>
    <version>1.0-SNAPSHOT</version>

    <name>AsciiDoc Test</name>

    <build>
        <plugins>
            <plugin>
                <groupId>org.asciidoctor</groupId>
                <artifactId>asciidoctor-maven-plugin</artifactId>
                <version>1.5.3</version>
                <dependencies>
                    <dependency>
                        <groupId>org.asciidoctor</groupId>
                        <artifactId>asciidoctorj-pdf</artifactId>
                        <version>1.5.0-alpha.11</version>
                    </dependency>
                    <dependency>
                        <groupId>org.asciidoctor</groupId>
                        <artifactId>asciidoctorj</artifactId>
                        <version>1.5.4</version>
                    </dependency>
                    <!-- beware, jruby 1.7.23 breaks asciidoctorj -->
                    <dependency>
                        <groupId>org.jruby</groupId>
                        <artifactId>jruby-complete</artifactId>
                        <version>1.7.21</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <sourceDirectory>${project.basedir}/src</sourceDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>generate-pdf-doc</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>process-asciidoc</goal>
                        </goals>
                        <configuration>
                            <backend>pdf</backend>
                            <doctype>book</doctype>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

This is my AsciiDoc source (src/test.adoc):

[cols="a"]
|===
|First paragraph

second paragraph

|===

The AsciiDoc file is compiled with:

mvn generate-resources

This is the generated output (target/generated-docs/test.pdf)

Why doesn't AsciiDoc render two paragraphs?

Other things that do not work as expected (every example pushes the whole cell content in one paragraph):

  • explicitly specifying a for the cell:
|===
a|First paragraph

second paragraph

|===
  • list:
[cols="a"]
|===
|First paragraph

 * second paragraph

|===
  • As non-heading:
[cols="1"]
|===

a|First paragraph

second paragraph

|===
Nolanolan answered 30/6, 2016 at 12:54 Comment(0)
D
7

From the documentation: http://asciidoctor.org/docs/user-manual/#cell

The direct Asciidoctor PDF rendering do not support this yet. See #6


This is what I get:

With paragraph:

[cols="1"]
|===

a|First paragraph

second paragraph

|===

The relevant thing is the empty line between |== and a|your cell

With the HTML renderer: Table with a second paragraph in Asciidoctor HTML

With the PDF renderer: Table with a second paragraph in Asciidoctor PDF

With list:

It works the same way:

[cols="1"]
|===

a|First paragraph

* second paragraph

|===

With the HTML renderer: Table with list in Asciidoctor HTML

With the PDF renderer: Table with list in Asciidoctor PDF


A possible solution might be to use the DocBook Pipeline with jDocBook as in this example docbook-pipeline-jdocbook-example. With this setup I get the expected output:

Complex Table example with the Asciidoctor docbook pipeline

Delicate answered 1/7, 2016 at 7:37 Comment(3)
This does not work for me, everything gets dumped into the same paragraph. I'll try to make a minimal working example of my whole setup.Nolanolan
I will give your setup a try. The screenshots I have added are not PDF rendering but the HTML one.Delicate
I can reproduce your problem. This is a known Issue of the PDF rendering: #6. I will update my answer.Delicate
B
3

I don't know anything about Maven and I don't use AsciiDoctor for PDF output, but the proposed answer could be (probably, not sure) outdated. Here is another solution (works for HTML for me. I post it here because I haven't found this syntax in official manual):

|===
| Column 1 | Column 2

| Foo
| Bar

Baz

| Aaa

Bbb

| Ccc
|===

enter image description here

I haven't found any examples of this syntax in official manual. The syntax was taken from here:

The same, if one prefer multiline syntax in header:

[cols="2"]
[options="header"]
|===
| Column 1
| Column 2

| Foo
| Bar

Baz

| Aaa

Bbb

| Ccc
|===
Bushcraft answered 29/8, 2018 at 1:7 Comment(2)
Thanks for the answer. Since the question is quite old, I do not have the environment available to test your suggestion. I hope someone else can verify this.Nolanolan
This works fine. Just tried it with a simple .adoc file and asciidoctor-pdf.Pedraza

© 2022 - 2024 — McMap. All rights reserved.