rinohtype/spinx-如何在样式表中使用python变量

发布于 2025-01-25 02:48:25 字数 589 浏览 1 评论 0原文

我使用sphinx生成HTML和PDF文档,并直到现在使用乳胶来生成PDF,但现在正在寻找Rinohtype的交换。

我正在考虑设置一些自定义的标题和页脚,但想在其中包含可变文本,例如版本号,该版本来自Sphinx Python插件。我有第一个替换,例如|版本|,我在文档中的各个位置使用,但是如果我通过样式表将其添加到标题中,则不会被替换。我在conf.py中也有Python变量,例如版本,因此我还尝试在我的StylesHeet中使用{version> {version},但是构建器抱怨该变量不存在。

仅供参考,这是我尝试定义头球的方式:

[contents_page]
header_text = '|document_id| |version| |shortdate|' (header)
[contents_page]
header_text = '{document_id} {version} {shortdate}' (header)

有什么想法解决这个问题吗?

谢谢

I use sphinx to generate HTML and PDF documentation, and was using latex until now to generate PDF, but now looking at swapping for rinohtype.

I'm looking at setting up some custom headers and footers, but would like to include variable text into them, for the version number for example, which comes from a sphinx python plugin. I have rst substitutions, for example |version|, that I use in various places in the document, but if I add it to the header via a stylesheet it doesn't get substituted. I also have python variables, for example version, in my conf.py so I also tried to use {version} in my stylesheet, but the builder complains that the variable doesn't exists.

FYI, here is how I tried to define my header :

[contents_page]
header_text = '|document_id| |version| |shortdate|' (header)
[contents_page]
header_text = '{document_id} {version} {shortdate}' (header)

Any idea how to get around that issue ?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

◇流星雨 2025-02-01 02:48:26

Rinohtype确实支持文档模板中的重组文本替换(|替代|),但这是尚未记录的功能之一。

以下方式包括它们:

[contents_page]
header_text = '{UserStrings.document_id} {UserStrings.version} {UserStrings.shortdate}' (header)

要在页面标头或页脚中使用替换,您需要按照 如果没有,将来可能不需要该前缀。)

rinohtype does support including reStructuredText substitutions (|subst|) in document templates, but this is one of the features that isn't documented yet.

To use substitutions in a page header or footer, you need to include them as follows:

[contents_page]
header_text = '{UserStrings.document_id} {UserStrings.version} {UserStrings.shortdate}' (header)

(Actually, I don't remember why I require the UserStrings. prefix. Perhaps there is a good reason for that. If not, that prefix might not be needed in the future.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文