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

如何在Asciidoc中仅引入.adoc文件的标题?

简化Asciidoc复用经验标题的方法

方法1:属性控制条件渲染

在_includes/experiences.adoc中通过属性定义区分标题和内容:

:show-experience-details: true

== Experience one
ifdef::show-experience-details[]
*Company name, Location* - Dates
具体工作内容描述
endif::show-experience-details[]

== Experience two
ifdef::show-experience-details[]
*Another Company, Location* - Dates
第二份工作内容描述
endif::show-experience-details[]

然后在resume.adoc中引入时覆盖属性,只加载标题:

:show-experience-details: false
include::_includes/experiences.adoc[]

方法2:拆分独立标题文件

把经验标题单独抽取为独立文件,实现多处复用:

  1. 创建_includes/experience-titles.adoc:
== Experience one
== Experience two
  1. 在_includes/experiences.adoc中组合标题与内容:
include::_includes/experience-titles.adoc[]
// 对应Experience one的详情
*Company name, Location* - Dates
具体工作内容描述

// 对应Experience two的详情
*Another Company, Location* - Dates
第二份工作内容描述
  1. 在resume.adoc中直接引入标题文件:
include::_includes/experience-titles.adoc[]

这种方式结构清晰,后续维护标题或内容都更便捷。

方法3:命令行过滤(本地构建场景)

如果使用Asciidoctor本地构建,可以借助命令行过滤器只提取标题行:

include::_includes/experiences.adoc[] | grep "^=="

注意这种方法依赖系统的grep工具,跨平台兼容性稍弱。

内容的提问来源于stack exchange,提问作者Jean-Charles

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.18 05:07:14