1 个不稳定版本
0.1.0 | 2024 年 3 月 30 日 |
---|
#632 在 文本处理
37KB
880 行
mdbook-shiftinclude
mdbook 的预处理器,用于包含文件的部分内容,但内容会发生位移。
{{#shiftinclude }}
命令扩展了正常 {{#include }}
命令的语法,以包含位移指示符。其后跟一个冒号,然后是正常的 include
语法。
- 一个数字,表示位移量。
- 正数通过在每个行首添加相应数量的空格来向右位移。
- 负数通过从每行的开头删除相应数量的字符来向左位移(无论这些字符是否为空格)!
auto
,表示将删除所有(非空)行中共同的任何空白块。
因此,对于输入文件 somefile.txt
Indent
More Indent
Back
以下是一些可能的输出
{{#shiftinclude auto:somefile.txt}
会得到Indent More Indent Back
{{#shiftinclude 2:somefile.txt}
会得到Indent More Indent Back
{{#shiftinclude -2:somefile.txt}
会得到Indent More Indent Back
{{#shiftinclude -4:somefile.txt}
会得到dent More Indent ck
安装
要使用,请安装此工具
cargo install mdbook-shiftinclude
并在 book.toml
中将其添加为预处理器
[preprocessor.shiftinclude]
依赖项
~12–23MB
~323K SLoC