I am creating paragraph indentation using the following code:
show heading: it => {
block(inset: (left: content-indent * it.level), it) // 根据标题级别缩进 / Indent based on heading level
}
// 显示段落和列表时根据对应的标题层级缩进
// Indent paragraphs based on corresponding heading level
show selector.or(par, enum, list, table, raw): it => context { // 查找标题和段落并传递给it变量
let h = query(selector(heading).before(here())).at(-1, default: none) // 获取前一个标题 / Get previous heading
if h == none {
return it // 如果没有标题,返回原段落 / Return original paragraph if no heading
}
block(inset: (left: content-indent * (h.level + 1)), it) // 根据标题级别缩进,额外再缩进一级与标题区分 / Indent based on heading level + 1
}
// 显示一级标题时根据设置分页
// Possibly page break when displaying level 1 headings
show heading.where(level: 1): it => {
if chapter-pagebreak { // 在新页开始章节 / Start chapters on new page
pagebreak(weak: true) // 弱分页 / Weak page break
}
it // 返回标题内容 / Return heading content
}
// 显示正文内容
// Display main body content
setup-content(
body, // 正文内容 / Main body content
)
Now I want to modify it to create nested indentation based on the heading levels to achieve more formatting options.
The goal is to achieve the following effect:


