如何在不创建任意标签的情况下在 sphinx 重组文本中创建指向标题的内部链接? [英] How to make an internal link to a heading in sphinx restructuredtext without creating arbitrary labels?

查看:45
本文介绍了如何在不创建任意标签的情况下在 sphinx 重组文本中创建指向标题的内部链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含许多标题和副标题的文档.进一步进入文本,我想链接回标题之一.如果没有 :ref: 标签的冗余,我该如何做到这一点?内容似乎可以很好地接收标题.我希望有这样的东西:`#polled-data-retrieval`_.

I have a document with many headings and sub-headings. Further into the text I want to link back to one of the headings. How can I do this without the redundancy of :ref: labels? The contents seems to pick up headers just fine. I was hoping for something like this: `#polled-data-retrieval`_.

推荐答案

reStructuredText 支持 隐式超链接目标.来自 reStructuredText 快速参考:

reStructuredText supports implicit hyperlink targets. From the reStructuredText quick reference:

章节标题、脚注和引文会自动生成超链接目标(标题文本或脚注/引文标签用作超链接名称).

Section titles, footnotes, and citations automatically generate hyperlink targets (the title text or footnote/citation label is used as the hyperlink name).

所以以下文本(摘自 reStructuredText 快速参考、拼写错误和所有内容):

So the following text (lifted from the reStructuredText quick reference, spelling mistakes and all):

Titles are targets, too
=======================
Implict references, like `Titles are targets, too`_.

生成类似于以下内容的 HTML:

produces HTML similar to the following:

<strong><a name="title">Titles are targets, too</a></strong>

<p>Implict references, like <a href="#title">Titles are targets, too</a>.</p>

这篇关于如何在不创建任意标签的情况下在 sphinx 重组文本中创建指向标题的内部链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆