Is there markdown syntax for the equivalent of:
Take me to <a href="#pookie">pookie</a> ... <a name="pookie">this is pookie</a>
` In recent versions of RStudio, there is a button labelled 'A' in the top right corner of the editor window to switch to the Visual Markdown Editor. Use Insert/Cross Reference to insert a cross reference.
Add a custom anchor Use lowercase for id values, and put hyphens between words. To add an anchor to a heading in Markdown, add the following code to the end of the line that the heading is on. Replace ID_OF_ANCHOR with the ID for this heading. Use lowercase for id values, and put hyphens between words.
There are two ways to format code in Markdown. You can either use inline code, by putting backticks (`) around parts of a line, or you can use a code block, which some renderers will apply syntax highlighting to.
To create a footnote reference, add a caret and an identifier inside brackets ( [^1] ). Identifiers can be numbers or words, but they can't contain spaces or tabs. Identifiers only correlate the footnote reference with the footnote itself — in the output, footnotes are numbered sequentially.
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.)
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.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With