Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple paragraphs in AsciiDoctor table cell

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

|===
like image 629
flyx Avatar asked Jun 30 '16 12:06

flyx


People also ask

What is AsciiDoc format?

AsciiDoc is a text document format that was explicitly designed with the needs of publishing in mind, both print and web. It supports all the structural elements necessary for writing notes, documentation, articles, books, ebooks, slideshows, web pages, technical manuals and blogs.

How do I add a hyperlink in AsciiDoc?

To define a link in Asciidoc markup we only have to type the URL followed by an optional text for the link in square brackets ( [text link] ).


2 Answers

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

like image 150
Jmini Avatar answered Oct 05 '22 21:10

Jmini


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:

  • Rendered HTML: https://asciidoctor.org/docs/asciidoc-syntax-quick-reference/#text-replacement

  • It's source:

    • https://github.com/asciidoctor/asciidoctor.org/blob/master/docs/asciidoc-syntax-quick-reference.adoc#text-replacement

    • https://github.com/asciidoctor/asciidoctor.org/blob/master/docs/_includes/subs-symbol-repl.adoc - here it is!

The same, if one prefer multiline syntax in header:

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

| Foo
| Bar

Baz

| Aaa

Bbb

| Ccc
|===
like image 41
john c. j. Avatar answered Oct 05 '22 21:10

john c. j.