21 个稳定版本
2.4.3 | 2024年5月13日 |
---|---|
2.4.2 | 2023年12月13日 |
2.4.1 | 2023年8月5日 |
2.3.3 | 2023年2月14日 |
1.0.1 | 2020年1月30日 |
#250 在 文本处理
269 每月下载量
用于 mdbook-dtmo
25KB
206 行
mdbook-open-on-gh
mdbook 预处理器,用于在每个页面上添加打开 GitHub 链接。
它在每个页面的底部添加一个“在 GitHub 上编辑此文件”的链接,直接链接到源文件。它使用配置的 git-repository-url
作为基础。
安装
如果您只想使用此预处理器,请安装此工具
cargo install mdbook-open-on-gh
将其添加到您的 book.toml
中的预处理器
[preprocessor.open-on-gh]
command = "mdbook-open-on-gh"
renderer = ["html"]
配置
mdbook-open-on-gh
使用 [output.html]
下的附加选项进行配置
[output.html]
# Required: Your repository URL used in the link.
git-repository-url = "https://github.com/$user/$project"
# Your git branch. Defaults to `main`
git-branch = "main"
# The text to use in the footer.
# The link text is marked by `[]`
open-on-text = "Found a bug? [Edit this page on GitHub.]"
要样式化页脚,请为您的 HTML 输出添加自定义 CSS 文件
[output.html]
additional-css = ["open-in.css"]
并在 open-in.css
中样式化 <footer>
元素或直接样式化 CSS 元素 id open-on-gh
footer {
font-size: 0.8em;
text-align: center;
border-top: 1px solid black;
padding: 5px 0;
}
此代码块缩小文本大小,在内容下方居中对齐,并在文本上方添加一条小水平线以将其与页面内容分开。
最后,按正常方式构建您的书籍
mdbook path/to/book
许可证
MPL。见 LICENSE。
版权 (c) 2020-2022 Jan-Erik Rediger [email protected]
依赖项
~11–23MB
~322K SLoC