7

编辑:由于我的问题似乎特定于我的设置,我在这里提供了一个完整的最小工作示例。

这是我的 Maven 设置(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>

这是我的 AsciiDoc 源代码(src/test.adoc):

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

second paragraph

|===

AsciiDoc 文件编译时使用:

mvn generate-resources

这是生成的输出 ( target/generated-docs/test.pdf)

为什么 AsciiDoc 不呈现两个段落?

其他无法按预期工作的事情(每个示例都将整个单元格内容推送到一个段落中):

  • 明确指定a单元格:
|===
a|First paragraph

second paragraph

|===
  • 列表:
[cols="a"]
|===
|First paragraph

 * second paragraph

|===
  • 作为非标题:
[cols="1"]
|===

a|First paragraph

second paragraph

|===
4

2 回答 2

6

从文档: http ://asciidoctor.org/docs/user-manual/#cell

直接的 Asciidoctor PDF 渲染还不支持这个。见#6


这就是我得到的:

带段:

[cols="1"]
|===

a|First paragraph

second paragraph

|===

|==相关的是和之间的空行a|your cell

使用 HTML 渲染器: Asciidoctor HTML 中带有第二段的表格

使用 PDF 渲染器: Asciidoctor PDF 中带有第二段的表格

带清单:

它的工作方式相同:

[cols="1"]
|===

a|First paragraph

* second paragraph

|===

使用 HTML 渲染器: Asciidoctor HTML 中带有列表的表格

使用 PDF 渲染器: Asciidoctor PDF 中带有列表的表格


一个可能的解决方案可能是将 DocBook Pipeline 与 jDocBook 一起使用,如本示例docbook-pipeline-jdocbook-example 中所示。通过这个设置,我得到了预期的输出:

使用 Asciidoctor docbook 管道的复杂表示例

于 2016-07-01T07:37:20.753 回答
3

我对 Maven 一无所知,也不使用 AsciiDoctor 进行 PDF 输出,但建议的答案可能(可能,不确定)已过时。这是另一种解决方案(对我来说适用于 HTML。我在这里发布它是因为我在官方手册中没有找到这种语法):

|===
| Column 1 | Column 2

| Foo
| Bar

Baz

| Aaa

Bbb

| Ccc
|===

在此处输入图像描述

我在官方手册中没有找到这种语法的任何例子。语法取自这里:

同样,如果在标题中更喜欢多行语法:

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

| Foo
| Bar

Baz

| Aaa

Bbb

| Ccc
|===
于 2018-08-29T01:07:56.740 回答