我想找到一种方法来从我的 Asciidoc 文档的目录中隐藏某些标题,我正在使用 Asciidoctor 将其处理为 HTML 和 PDF。
我增加了headerlevel值以包含一些其他子标题,但这样做的副作用是一些不需要的标题现在也出现在输出文档的 ToC 中。
我的文档是使用这种语句从多个源文件动态组成的:
include::deployment/topic.adoc[leveloffset=+3]
Run Code Online (Sandbox Code Playgroud)
其中一些标题不应出现在 ToC 中——包括它们会导致大量重复(它们在每个主要标题下都有相似的内容)。
例如:
每个组件主题都有一个 H1 标头,这些“leveloffset”属性根据需要降级为 h2、h3 等:
= My Topic Title
Run Code Online (Sandbox Code Playgroud)
所以我解析的文件是这样的:
= Main Title (Keep in ToC)
== H2 (Keep in ToC)
=== H3 (Keep in ToC)
== H2 (Keep in ToC)
=== H3 (Remove from ToC)
== H2 (Keep in ToC)
=== H3 (Remove from ToC)
Run Code Online (Sandbox Code Playgroud)
我不能减少headerlevel去除的情况下,=== H3 (Remove from ToC)无需也删除=== H3 (Keep in …
我正在使用asciidoctor生成html。我有以下清单:
. one
. two
. three
image::mypic.png[]
. four
Run Code Online (Sandbox Code Playgroud)
并且当转换为html时,它看起来像这样:
1. one
2. two
3. three
<my picture>
1. four
Run Code Online (Sandbox Code Playgroud)
在html中,我希望看到:
1. one
2. two
3. three
<my picture>
4. four
Run Code Online (Sandbox Code Playgroud)
我不想在插入图像后手动重置计数器,因为我有数百种类似的情况。
编辑:由于我的问题似乎特定于我的设置,我在这里提供了一个完整的最小工作示例。
这是我的 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>
Run Code Online (Sandbox Code Playgroud)
这是我的 AsciiDoc 源代码 ( src/test.adoc):
[cols="a"]
|===
|First paragraph
second …Run Code Online (Sandbox Code Playgroud) 我试图在 Asciidoc 文档的表格单元格中有一个(简单的)无序列表。我用asciidoctor。
我尝试了以下方法:
|===
| One | Two
| Foo
|
- Bar
- Baz
|===
Run Code Online (Sandbox Code Playgroud)
但这会导致最后一个单元格仅将文本- Bar - Baz作为简单字符串,没有列表格式。我希望将其格式化为一个列表,分两行,每行都有一个项目符号。任何想法?
似乎没有办法在Asciidoc中的文字文本中解析变量(属性,替换),否则我会遗漏一些东西.我希望能够设置一个变量,然后在代码块或文字字符串中调用它:
:version: 1.0.1
[code]
----
tar -xzvf mysoftware-{version}.tar.gz
----
Run Code Online (Sandbox Code Playgroud)
并解析:
tar -xzvf mysoftware-1.0.1.tar.gz
Run Code Online (Sandbox Code Playgroud)
这不可能是不可能的,对吗?
我非常喜欢asciidoctor的标注,请参阅http://asciidoctor.org/docs/asciidoc-syntax-quick-reference/,并在"带标注的代码块"页面中搜索,点击"查看结果".但我使用Ipython笔记本进行书写,而Markdown则是选择.(通过"原始NBconvert"在Ipython笔记本中尝试Asciidoctor,结果很混乱.)似乎我只需要来自Asciidoctor的源代码标注.所以我的问题是如何从Markdown获得类似的结果?
如何在asciidoc/asciidoctor中定义宏?
我将在文档的许多部分使用重复模式,因此我想进行参数化替换以避免多次输入相同的内容.
特别是,我有以下asciidoc片段:
{set:cellbgcolor:grey}
[grid=none, frame=none]
|===
| X >| Y
|===
{set:cellbgcolor!}
Run Code Online (Sandbox Code Playgroud)
我需要将它放在文档的几个部分中,用不同的文本替换来代替X和Y.我该如何实现?
我有使用AsciiDoc的用户指南它很漂亮,尽管我没有花太多时间.
AsciiDoc插件很棒.所以我想在用户指南中传递我的Maven最终名称.
问题:怎么做?
<finalName>${project.artifactId}-${project.version}-${version.state}-r${buildNumber}</finalName>
Run Code Online (Sandbox Code Playgroud)
我的asciidoctor-maven-plugin配置是:
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<version>${asciidoctor.maven.plugin.version}</version>
<dependencies>
<dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctorj-pdf</artifactId>
<version>${asciidoctorj.pdf.version}</version>
</dependency>
<!-- Comment this section to use the default jruby artifact provided by the plugin -->
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby-complete</artifactId>
<version>${jruby.version}</version>
</dependency>
<!-- Comment this section to use the default AsciidoctorJ artifact provided by the plugin -->
<dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctorj</artifactId>
<version>${asciidoctorj.version}</version>
</dependency>
</dependencies>
<configuration>
<sourceDirectory>src/docs/asciidoc</sourceDirectory>
<sourceDocumentName>manual.adoc</sourceDocumentName>
<!-- Attributes common to all output formats -->
<attributes>
<sourcedir>${project.build.sourceDirectory}</sourcedir>
</attributes>
</configuration>
<executions>
<execution>
<id>generate-pdf-doc</id>
<phase>generate-resources</phase>
<goals>
<goal>process-asciidoc</goal> …Run Code Online (Sandbox Code Playgroud) 我正在使用 asciidoc 和 asciidoctor 编写文档。所以,我有一个 intro.adoc 文件,然后是一堆节文件。因此,我想要做的是将它们列出到 intro.adoc 并向它们添加超链接,以便于导航。
为此我可以想到两种方法:
首先,我可以使用标头并将相对链接关联到同一目录中的 .adoc 文件。这样,他们就会重定向到他们。但我不知道如何实现它。link: == section1.adoc[Section 1]不管用。
其次,使用include::section1.adoc[]. 它可以工作,但不是超链接。
这有什么问题吗?或者有一个简单的方法可以做到这一点。
如果不清楚,我正在尝试# [Section1](section.md)在 asciidoc 中实现这一点(Markdown 版本)。
在降价我可以写:
[example1][myid]
[example2][myid]
[myid]: http://example.com
Run Code Online (Sandbox Code Playgroud)
所以我不必多次重新输入完整的外部链接。
AsciiDoc 中是否有类似的功能?对 Asciidoctor 实现特别感兴趣。
到目前为止,我只能找到:
<<>>:myid:,但我再也找不到了。但是我没有看到如何为每个链接使用不同的文本。