【问题标题】:Custom role to link PDF file as static content将 PDF 文件链接为静态内容的自定义角色
【发布时间】:2020-10-05 20:20:28
【问题描述】:

我正在尝试为 Sphinx 编写一个自定义角色,以允许链接到随后显示在浏览器中的 PDF 文件(而不是在使用 :download: 角色时下载)。

我的角色可以创建 PDF 文件的链接:

:pdf:`Document Title <pdf/document.pdf>`

产生类似的东西:

<a href="pdf/document.pdf>Document Title</a>

但是,我不知道如何让 Sphinx 将 pdf 目录复制到输出目录。 这可能吗?

【问题讨论】:

    标签: python pdf python-sphinx static-files


    【解决方案1】:

    在您的conf.py 中使用html_static_path

    html_static_path = ['_static', 'pdf']
    

    【讨论】:

    • 谢谢。这就是我想出的解决方案。我希望我的自定义角色代码可以将文件复制到输出中的“pdf”目录。但也许不值得担心
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多