You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法通过Include文件定义Asciidoctor公共属性的问题求助

解决Asciidoctor include属性文件不生效的问题

你遇到的问题核心是include指令的语法错误,结合解析顺序要求,具体解决步骤如下:

1. 修正include指令的语法

Asciidoctor的include指令必须以[]结尾,哪怕不需要传递任何参数。你当前的include::attributes.adoc缺少了[],导致解析器无法正确识别这是一个include操作,属性文件里的内容自然不会被加载。

修正后的主文档test.adoc内容:

= Test
Amy de Buitléir
include::attributes.adoc[]
:local-attribute: This works
Testing a locally defined attribute: {local-attribute}
Testing an attribute defined in the include file: {my-custom-attribute}

2. 确认include的位置

确保include语句放在文档标题、作者之后,所有本地属性定义之前。Asciidoctor按顺序解析属性,这样能保证外部属性文件的内容在文档处理初期就被加载,后续内容可以正常引用这些属性。

你的attributes.adoc内容无需修改:

:my-custom-attribute: It works!

重新执行asciidoctor test.adoc命令生成HTML,就能看到{my-custom-attribute}被正确替换为It works!了。

内容的提问来源于stack exchange,提问作者mhwombat

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.11 18:42:01