【问题标题】:Creating custom HTML with asciidoctor使用 asciidoctor 创建自定义 HTML
【发布时间】:2015-09-09 00:29:08
【问题描述】:

我正在使用 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>

如您所见,我使用了一些自定义来包装代码(预类等)。用 Asciidoctor 可以轻松完成吗?我是 Asciidoctor 的新手,我只是想知道是否值得为此花时间学习它。
谢谢!

【问题讨论】:

标签: asciidoc asciidoctor


【解决方案1】:

要回答这个问题,是的,这是可能的。但是,对于像这样微不足道的事情,asciidoctor ootb 的输出以及选择的荧光笔可能适用于您正在做的事情。

如果您需要自定义创建自定义后端所需的内容。由于创建自定义后端的文档尚未完成,this mailing list post 应该会有所帮助。

【讨论】:

  • 感谢您的澄清!
【解决方案2】:

除了 LightGuard 的高级答案,值得一提的是,您可以使用 ++++ 将自定义 HTML 添加到输出中。

++++<h1>hello</h1>++++

只会生成

<h1>hello</h1>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-22
    • 1970-01-01
    • 1970-01-01
    • 2022-11-11
    相关资源
    最近更新 更多