#mdbook #preprocessor #trace #document #target #footnotes #traceable

app mdbook-trace

为mdbook提供的可追踪文档预处理器

2个版本

0.1.1 2022年8月18日
0.1.0 2022年8月18日

#1786 in 文本处理

MIT 协议

19KB
386 代码行

mdbook-trace

为mdbook提供的可追踪文档预处理器。

mdbook-trace 提供了一个Markdown扩展,用于从当前文档到外部文档中的记录定义一个 追踪。每个追踪将在当前页面生成一个脚注,并添加到目标文档的 追踪表 中。

安装

cargo install mdbook-trace

使用方法

为要追踪的每个目标文档添加一个条目到 book.toml

[preprocessor.trace.targets.mydoc]
name = "My Document"

然后,在你的Markdown中添加一个新的追踪

Some traceable text {{#trace mydoc:ID-1.2 }}

这将呈现为

一些可追踪的文本[^1]


[^1]: 我的文档ID-1.2

最后,更新你的Markdown以生成目标文档的追踪表

# My Document
{{#tracematrix mydoc }}

这将呈现为

记录 追踪
ID-1.2 1.1

配置

以下是完整的预处理器配置选项及其默认值

[preprocessor.trace]
# Use fully-qualified trace number as in-page footnote number
# e.g. "Some text^1" becomes "Some text^1.2.1"
qualified-footnotes = false
# Add chapter numbers to page titles
# e.g. "My Chapter" becomes "1.1 My Chapter"
chapter-numbers = false
# Insert a horizontal rule between the body of a page and the list of generated footnotes.
footnote-divider = false
# Heading used for the first column of generated trace tables.
record-heading = "Record"
# Heading used for the second column of generated trace tables.
trace-heading = "Traces"
# The trace numbering strategy for a page with subchapters.
# If "allow-duplicates", number traces as normal.
# This will result in traces with the same number as subchapters.
# (e.g. the first trace and first subchapter of chapter 1 will both be numbered 1.1)
# If "offset", offset trace numbers from the last subchapter.
# (e.g. if chapter 1 has 2 subchapters, the first trace will be numbered 1.3)
# If "zero", insert a ".0" qualifier before traces in a page with subchapters.
# (e.g. if chapter 1 has 1 subchapter, the first trace will be 1.0.1).
parent-numbering = "zero"

依赖

~13–25MB
~375K SLoC