如何在adoc文件中渲染删除线(或直线)?
让我们假设我想写"技术是 - 废话 - 不完美".
我在执行命令时出现以下错误gradle build。
Execution failed for task ':asciidoctor'.
> Cannot locate a Guava JAR in the Gradle distribution
Run Code Online (Sandbox Code Playgroud)
我正在使用 macOS Big Sur。
我需要你的帮助。
现在我使用 AsciiDoc 和 AsciiDoctor 来创建一些手册。
我希望某些特定块上的文本更小,例如宽表、宽列表等,但不希望主文本更小。尤其是我需要根据客户的要求将宽表的文本缩小。
有什么办法吗?
我的应用
我有一个Mac应用程序,它使用AsciiDoctor来生成PDF和ePUB文件.我使用Process该类(以前NSTask)来运行AsciiDoctor命令.
我想要的是
我希望人们能够使用我的应用程序,而无需从终端手动安装AsciiDoctor Ruby宝石.
将gems复制到应用程序包
我的第一次尝试是在我的Mac上的自定义文件夹中安装AsciiDoctor gem,并将Copy Files构建阶段添加到我的Xcode项目中,将带有gem的文件夹复制到app bundle中.将宝石添加到应用程序包中可以在我的机器上运行但在其他机器上运行不正常.我不能在使用不同版本Ruby的系统上创建PDF或EPUB文件,而不是我用来安装gem的Mac版本.在macOS 10.13虚拟机上,我能够创建PDF文件但不能创建EPUB文件.
在Application Support文件夹中安装gem
我的第二次尝试是在第一次有人启动应用程序时在我的应用程序的Application Support文件夹中安装gem.但这甚至不适用于我的机器.当我使用usr/bin/ruby命令行进程的启动路径和以下参数列表时:
let argumentList = ["gem", "install", "-i", gemFolder.path, gem, "--pre"]
Run Code Online (Sandbox Code Playgroud)
其中变量gemFolder.path是Application Support文件夹的路径,变量gem是"asciidoctor-pdf"或者"asciidoctor-epub3".
运行命令行进程时,我从标准错误中收到以下错误消息:
/ usr/bin/ruby:没有这样的文件或目录 - gem(LoadError)
当我使用启动路径gem或gem install调用Process方法时run抛出异常.以下是异常抛出的错误消息.
错误域= NSCocoaErrorDomain代码= 4"文件"gem"不存在." 的UserInfo = {NSFilePath =宝石}
错误域= NSCocoaErrorDomain代码= 4"文件"gem install"不存在." UserInfo = {NSFilePath = gem install}
题
如何在我的应用程序中包含AsciiDoctor宝石,以便人们不必手动安装宝石?我是否需要为应用程序创建安装程序?
我从AsciiDoctor开始,我想输出HTML.我一直试图弄清楚如何在分区中创建自定义类,我搜索谷歌,手册等,但找不到解决方案.我想做的只是写下这样的东西:
Type the word [userinput]#asciidoc# into the search bar.
哪个生成HTML
<span class="userinput">asciidoc</span>
但我想要div标签而不是span.有什么方法可以做到或者我应该使用类似的东西
+++<div class="userinput">asciidoc</span>+++吗?
我想找到一种方法来从我的 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 …
首先,我可以使用raw指令轻松包含原始 html 文件,如下所示:
.. raw:: html
:file: some_file.html
Run Code Online (Sandbox Code Playgroud)
有没有一种简单的方法可以用 asciidoctor 来做到这一点?我明白,如果我将 的内容包装some_file.html起来++++,我就可以include::在 asciidoc 中使用,但我想避免手动编辑some_file.html.
我正在使用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) 我正在采用 Spring Rest Docs,并且测试成功创建了 *.adoc 文件。
我在 src/docs/asciidoc 目录中创建了 api-guide.doc 文件来创建 html,但是当我将 asciidoc 作为 gradle 任务运行时,它会产生以下错误。
Some problems were found with the configuration of task ':asciidoctor' (type 'AsciidoctorTask').
- In plugin 'org.asciidoctor.convert' type 'org.asciidoctor.gradle.AsciidoctorTask' method 'asGemPath()' should not be annotated with: @Optional, @InputDirectory.
Run Code Online (Sandbox Code Playgroud)
我用spring初始化器初始化了项目,所以我相信gradle依赖没有问题。
plugins {
id 'org.springframework.boot' version '2.5.3'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'org.asciidoctor.convert' version '1.5.8'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories { …Run Code Online (Sandbox Code Playgroud) asciidoctor ×10
asciidoc ×6
build ×1
cocoa ×1
gradle ×1
maven ×1
nstask ×1
rubygems ×1
spring-boot ×1
text-size ×1