使用asciidoctor创建自定义HTML

5

我正在使用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还不熟悉,只是想知道是否值得花时间学习它以实现此目的。
谢谢!


2个回答

2
回答这个问题,是的,这是可能的。然而,对于像这样琐碎的事情,asciidoctor自带的输出加上所选择的突出显示工具可能对你正在做的事情很好用。
如果您需要自定义内容,您需要创建一个自定义后端。由于创建自定义后端的文档尚未完成,因此this mailing list post应该会有所帮助。

感谢澄清! - user2824073

2
除了LightGuard的高级解答之外,值得一提的是您可以使用++++来添加自定义HTML到输出中。
++++<h1>hello</h1>++++

将会直接生成。
<h1>hello</h1>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接