【问题标题】:How to include a javascript in Asciidoc?如何在 Asciidoc 中包含 javascript?
【发布时间】:2014-10-20 14:11:32
【问题描述】:

我正在使用 asciidoctor-maven-plugin 将 .adoc 文件转换为 html 文件... 想要在生成的 html 文件中包含指向 javascript 的链接... 基本上希望在从 .adoc 文件生成的 html 文件中看到类似下面的内容

<script src="custom.js"></script>

尝试设置属性,如 linkcss scriptsdir 等。但没有运气...

有什么帮助吗?

一种方式就像在 http://mrhaki.blogspot.ie/2014/06/awesome-asciidoc-include-raw-html.html

但是必须在每个 .adoc 文件中添加它...有没有办法像 CSS 一样自动添加它(使用样式表)

【问题讨论】:

标签: javascript asciidoc


【解决方案1】:

使用 docinfo 文件,see the documentation for more detail

您可以通过添加另一个名为 &lt;doc_file_name&gt;-docinfo.html 的文件来生成 docinfo 文件以生成 HTML,或添加名为 &lt;doc_file_name&gt;-docinfo.xml 的文件以生成 docbook。 docinfo 文件的内容被复制到生成的输出中,位于 html 的 head 部分中。如果您想在文档底部添加内容,可以使用页脚 docinfo 文件。它与普通的 docinfo 相同,但文件名为 &lt;doc_file_name&gt;-docinfo-footer.html&lt;doc_file_name&gt;-docinfo-footer.xml

Happy docing :) 让我,或者最好是 the list 知道您发现的任何其他 maven 问题。

【讨论】:

  • 别忘了在你的 adoc 中设置 :docinfo: 属性为相应的值! (也在@LightGuard 链接的文档中解释)
【解决方案2】:

您可以使用 ++++ 的 passthrough 块:

++++
<p>
Content in a passthrough block is passed to the output unprocessed.
That means you can include raw HTML, like this embedded Gist:
</p>

<script src="http://gist.github.com/mojavelinux/5333524.js">
</script>
++++

来源:http://asciidoctor.org/docs/asciidoc-syntax-quick-reference/#more-delimited-blocks

【讨论】:

  • 虽然它有效,但有一个限制,您不能在此块内传递任何值。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-04-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-05
相关资源
最近更新 更多