我想将一些AsciiDoc .adoc 文件转换为 HTML 并使用 Gradle 来实现。
我是 Gradle 新手。我找到了https://github.com/asciidoctor/asciidoctor-gradle-plugin
,下面就是build.gradle要做的事情,但以我的 Gradle 水平,我不知道下一步该做什么
// https://github.com/asciidoctor/asciidoctor-gradle-plugin
buildscript {
repositories {
maven {
name 'Bintray Asciidoctor repo'
url 'http://dl.bintray.com/content/aalmiray/asciidoctor'
}
jcenter()
}
dependencies {
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:0.7.0'
}
}
apply plugin: 'asciidoctor'
// append below the line: apply plugin: 'asciidoctor'
asciidoctor {
outputDir = new File("$buildDir/docs")
options = [
eruby: 'erubis',
attributes: [
'source-highlighter': 'coderay',
toc: '',
idprefix: '',
idseparator: '-'
]
]
//+
//sourceDir = new File(".")
}
Run Code Online (Sandbox Code Playgroud) 我插入了一个块图像,如下所示:
[[myimage]]
image::fig1.png[align="center", title="My caption"]
Run Code Online (Sandbox Code Playgroud)
不幸的是,图像居中,但标题左对齐。我也尝试这样做:
[[myimage]]
.My caption
image::fig1.png[align="center"]
Run Code Online (Sandbox Code Playgroud)
但结果没有改变。如何使图像标题也居中对齐?
我使用此命令生成 HTML 输出(使用 xhtml11 作为后端没有区别):
asciidoc -v -a asciimath -d 文章 -b html5 -o file.html file.txt
我正在尝试并排放置两个图像,并且理想情况下将整个块集中在 Asciidoctor 项目中。下面的代码适用于 HTML5 输出,但在渲染为 PDF 时会堆叠图像。
[.clearfix]
--
[.left]
.Title1
image::chapter3/images/foo.png[Foo, 450, scaledwidth="75%"]
[.left]
.Title2
image::chapter3/images/bar.png[Bar, 450, scaledwidth="75%"]
--
Run Code Online (Sandbox Code Playgroud)
是否可以 1) 在 PDF 中渲染并排图像并 2) 将图像块居中?如果可以指定它们之间的空间,那就太好了。
谢谢,
马特
我正在使用 CMS 来发布我的博客文章。我正在寻找一种从简单文本文件离线创建 HTML 文章的方法。\n这是我通常在文章中使用的一段 HTML:
\n\n<p>\xc2\xa0We want to show how you can gather information such as the author name:</p>\n<pre class="brush:java">package com.sample;\n\nimport org.apache.camel.builder.RouteBuilder;\nimport org.apache.camel.main.Main;\n\n\npublic class XMLCamel {\n\n public static void main(String[] args) throws Exception {\n Main main = new Main();\n\n }\n}\n\nclass Sample extends RouteBuilder {\n\n @Override\n public void config() throws Exception {\n\n from("file:/usr/data/files?noop=true")\n .split(xpath("//catalog/book/author/text()")).to("stream:out"); \n\n }\n}</pre>\n<p>The above route will print the author names according to the <strong>XPath</strong> query: //catalog/book/author/text()</p>\n<p>The authors will be sent to the Stream.out so you will …Run Code Online (Sandbox Code Playgroud) 参考样式链接非常有用,因为我可以通过名称来引用链接.例如,在Markdown我习惯做类似的事情:
The [Web site][tag-web-site] references...blah.
[tag-web-site]: https://web-site-url.tld
Run Code Online (Sandbox Code Playgroud)
...它将根据tag-web-site参考创建一个链接.
有什么办法可以在AsciiDoc中模仿这个功能吗?我试过但到目前为止我找不到任何东西.
AsciiDoc source likea * a被转换为 HTML 作为普通文本“a * a”。如果星号是行中的第一个非空格字符,则它开始一个列表(这是正常的)。但是,我需要用文字星号开始一个段落。我尝试了以下方法来逃避它:
`*`
*(内部渲染<code>)\*
+*+
*(内部渲染<code>)pass::[*]
block macro cannot occur here: pass::[*]'*'
<em>- 迄今为止最接近我需要的)如何在 AsciiDoc 源代码的行首指定星号,使其在 HTML 输出中显示为普通文本?
我想将Asciidoc转换为LaTeX,然后使用包含LaTeX模块的现有工具链将生成的文档进一步转换为最终格式。根据他们的文档,Asciidoc的本机LaTeX转换是“实验性的”,对我也不起作用。Asciidoc支持另一个工具链,该工具链首先转换为Docbook,然后使用dblatex对其进行进一步转换。但是,它的LaTeX输出中包含很多格式,这与我的工具链的格式冲突。
有什么方法可以将Asciidoc转换为LaTex,使内容包含在生成的文档中,但没有任何确切的格式规则(请注意文档中明确指定的格式)。我不希望LaTeX结果包含有关字体,页面布局等的任何信息,因为对于那些我已经有了工具链。
我应该如何编写 Asciidoc(tor) 以获得以下输出:
* item 1
* item a
paragraph 1 inside item a
* item a.1 inside paragraph 1 inside item a
paragraph a.1 inside item a.1
* item a.2 inside paragraph 1 inside item a
paragraph a.2 inside item a.1
paragraph 2 inside item a
* item b
paragraph 1 inside item b
* item 2
Run Code Online (Sandbox Code Playgroud)
更新:@TigerTV.ru 提出了一个不错的技巧,但它需要能够在项目符号列表中隐藏项目符号。如何才能做到这一点?
谢谢
我想在 GitHub 的 README.adoc 文件中居中对齐图像。
我知道对于 Markdown 文件,添加 HTML如下所示:
<p align="center">
<img width="460" height="300" src="http://www.fillmurray.com/460/300">
</p>
Run Code Online (Sandbox Code Playgroud)
但是,我想在 AsciiDoc 中编写文件,而不是 Markdown。
假设在与 README 相同的目录中有一个 map.png 图像。
image::map.png[A map, 350, align=center]
Run Code Online (Sandbox Code Playgroud)
这将显示正确的图像,但与左侧对齐。
例如,让某个类中有一个 Java 常量
public class MyClass{
public static final String ENDPOINT="http://example.com"
}
Run Code Online (Sandbox Code Playgroud)
让我们尝试在 AsciiDoctor 中描述该类(公司文档原因)
==== My class
..... some descripton .....
It is exposed trough http://example.com
Run Code Online (Sandbox Code Playgroud)
现在,每次更改端点时,我也必须手动更新文档(IDE 查找和替换显然可以解决问题)。有没有办法将 Java 常量包含到 AsciiDoc 中,这样我就不必将其值复制到文档中?
我很乐意看到类似的东西{import my.package.MyClass#ENDPOINT}。