reStructuredText 中超链接的标准语法是什么:`Foo`_ 或 Foo_?
What is the standard syntax for hyperlink in reStructuredText: `Foo`_ or Foo_?
http://docutils.sourceforge.net/docs/user/rst/quickref.html#external-hyperlink-targets 显示此示例:
External hyperlinks, like Python_.
.. _Python: http://www.python.org/
但是 http://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#external-links 显示了这个例子:
This is a paragraph that contains `a link`_.
.. _a link: https://domain.invalid/
我正在尝试了解这两种语法中哪一种是正确的,并且可以与所有重组文本渲染器一起使用。
我应该使用:
Foo_
要引用超链接?
或者我应该使用:
`Foo`_
要引用超链接?
两者都是正确的。超链接的语法只是一个下划线 _
。当超链接的名称包含空格时需要反引号。否则,两者都可以接受。从技术上讲,反引号被称为“分组语法”。
通常的做法是只包含反引号,即使超链接的名称不包含空格也是如此。这是因为并不总是能立即理解单独的 _
是否是应该包含下划线或超链接的短语的拼写错误。然而,``_
语法在 reST 中被认为是一个超链接。
http://docutils.sourceforge.net/docs/user/rst/quickref.html#external-hyperlink-targets 显示此示例:
External hyperlinks, like Python_.
.. _Python: http://www.python.org/
但是 http://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#external-links 显示了这个例子:
This is a paragraph that contains `a link`_.
.. _a link: https://domain.invalid/
我正在尝试了解这两种语法中哪一种是正确的,并且可以与所有重组文本渲染器一起使用。
我应该使用:
Foo_
要引用超链接?
或者我应该使用:
`Foo`_
要引用超链接?
两者都是正确的。超链接的语法只是一个下划线 _
。当超链接的名称包含空格时需要反引号。否则,两者都可以接受。从技术上讲,反引号被称为“分组语法”。
通常的做法是只包含反引号,即使超链接的名称不包含空格也是如此。这是因为并不总是能立即理解单独的 _
是否是应该包含下划线或超链接的短语的拼写错误。然而,``_
语法在 reST 中被认为是一个超链接。