How to make an internal link to a heading in sphinx restructuredtext without creating arbitrary labels?

后端 未结 4 663
臣服心动
臣服心动 2020-12-29 03:01

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 :r

4条回答
  •  余生分开走
    2020-12-29 03:37

    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).

    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`_.
    

    produces HTML similar to the following:

    Titles are targets, too
    
    

    Implict references, like Titles are targets, too.

提交回复
热议问题