交叉引用(命名锚点)在降价 [英] Cross-reference (named anchor) in markdown

查看:108
本文介绍了交叉引用(命名锚点)在降价的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在相当于下列标记的语法:

 带我去< a href =#pookie> pookie< / A> 

...

< a name =pookie>这是pookie< / a>


解决方案



 带我去[pookie](#pookie)

应该是正确的markdown语法,以便跳转到名为pookie的锚点。



要插入该名称的锚点,请使用HTML:

 < a name =pookie>< / a> 

Markdown似乎并不介意放置锚点的位置。一个有用的地方放在它的标题。例如:
$ b

  ###< a name =tith>< / a>这是标题

效果很好。 (我会在这里演示,但是SO的渲染器会去掉锚点。)



关于自闭标签和 id = vs name =



这篇文章的早期版本建议使用< a id ='tith'/> ,使用XHTML的自动关闭语法,并使用 id 属性而不是 name



XHTML允许任何标记为'空'和'自关闭'。也就是说,对于< tag>< / tag> < tag /> 是简短的。与空身体匹配的一对标签。大多数浏览器都会接受XHTML,但有些则不会。为避免出现跨浏览器问题,请按照上面的建议,使用< tag>< / tag> 明确关闭标记。



最后,XHTML中不推荐使用属性 name = ,所以我最初使用 id = ,其中每个人识别。但是,当使用 id = 时,HTML5现在会在JavaScript中创建一个全局变量,这可能不一定是您想要的。因此,使用 name = 现在可能更友好。

(感谢 Slipp Douglas 向我解释XHTML,以及美甲师指出HTML5的副作用 - 请参阅评论和打钉器回答 a>以获取更多细节。 name = 似乎可以在任何地方使用,但它在XHTML中已被弃用。)


Is there markdown syntax for the equivalent of:

Take me to <a href="#pookie">pookie</a>

... 

<a name="pookie">this is pookie</a>

解决方案

Take me to [pookie](#pookie)

should be the correct markdown syntax to jump to the anchor point named pookie.

To insert an anchor point of that name use HTML:

<a name="pookie"></a>

Markdown doesn't seem to mind where you put the anchor point. A useful place to put it is in a header. For example:

### <a name="tith"></a>This is the Heading

works very well. (I'd demonstrate here but SO's renderer strips out the anchor.)

Note on self-closing tags and id= versus name=

An earlier version of this post suggested using <a id='tith' />, using the self-closing syntax for XHTML, and using the id attribute instead of name.

XHTML allows for any tag to be 'empty' and 'self-closed'. That is, <tag /> is short-hand for <tag></tag>, a matched pair of tags with an empty body. Most browsers will accept XHTML, but some do not. To avoid cross-browser problems, close the tag explicitly using <tag></tag>, as recommended above.

Finally, the attribute name= was deprecated in XHTML, so I originally used id=, which everyone recognises. However, HTML5 now creates a global variable in JavaScript when using id=, and this may not necessarily be what you want. So, using name= is now likely to be more friendly.

(Thanks to Slipp Douglas for explaining XHTML to me, and nailer for pointing out the HTML5 side-effect — see the comments and nailer's answer for more detail. name= appears to work everywhere, though it is deprecated in XHTML.)

这篇关于交叉引用(命名锚点)在降价的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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