使用 asciidoctor 创建自定义 HTML
Creating custom HTML with asciidoctor
我正在使用 CMS 发布我的博客文章。我正在寻找一种从简单文本文件离线创建 HTML 文章的方法。
这是我通常用于文章的 HTML 的一部分:
<p> We want to show how you can gather information such as the author name:</p>
<pre class="brush:java">package com.sample;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.main.Main;
public class XMLCamel {
public static void main(String[] args) throws Exception {
Main main = new Main();
}
}
class Sample extends RouteBuilder {
@Override
public void config() throws Exception {
from("file:/usr/data/files?noop=true")
.split(xpath("//catalog/book/author/text()")).to("stream:out");
}
}</pre>
<p>The above route will print the author names according to the <strong>XPath</strong> query: //catalog/book/author/text()</p>
<p>The authors will be sent to the Stream.out so you will see them on the console once you run the code.</p>
<p><strong>Result:</strong></p>
<p><strong>John Smith Sally Joy</strong></p>
如您所见,我使用了一些自定义来包装代码(pre class 等)。使用 Asciidoctor 可以轻松完成吗?我是 Asciidoctor 的新手,只是想知道为此目的是否值得花时间学习它。
谢谢!
回答这个问题,是的,这是可能的。然而,对于像这样微不足道的事情,asciidoctor ootb 的输出以及选择的荧光笔可能对你正在做的事情很好。
如果您需要自定义内容,则需要创建自定义后端。由于创建自定义后端的文档尚未完成 this mailing list post 应该有所帮助。
除了 LightGuard 的高级答案之外,值得一提的是,您可以使用 ++++
将自定义 HTML 添加到输出中。
++++<h1>hello</h1>++++
只会生成
<h1>hello</h1>
我正在使用 CMS 发布我的博客文章。我正在寻找一种从简单文本文件离线创建 HTML 文章的方法。 这是我通常用于文章的 HTML 的一部分:
<p> We want to show how you can gather information such as the author name:</p>
<pre class="brush:java">package com.sample;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.main.Main;
public class XMLCamel {
public static void main(String[] args) throws Exception {
Main main = new Main();
}
}
class Sample extends RouteBuilder {
@Override
public void config() throws Exception {
from("file:/usr/data/files?noop=true")
.split(xpath("//catalog/book/author/text()")).to("stream:out");
}
}</pre>
<p>The above route will print the author names according to the <strong>XPath</strong> query: //catalog/book/author/text()</p>
<p>The authors will be sent to the Stream.out so you will see them on the console once you run the code.</p>
<p><strong>Result:</strong></p>
<p><strong>John Smith Sally Joy</strong></p>
如您所见,我使用了一些自定义来包装代码(pre class 等)。使用 Asciidoctor 可以轻松完成吗?我是 Asciidoctor 的新手,只是想知道为此目的是否值得花时间学习它。
谢谢!
回答这个问题,是的,这是可能的。然而,对于像这样微不足道的事情,asciidoctor ootb 的输出以及选择的荧光笔可能对你正在做的事情很好。
如果您需要自定义内容,则需要创建自定义后端。由于创建自定义后端的文档尚未完成 this mailing list post 应该有所帮助。
除了 LightGuard 的高级答案之外,值得一提的是,您可以使用 ++++
将自定义 HTML 添加到输出中。
++++<h1>hello</h1>++++
只会生成
<h1>hello</h1>