Intra-doc links using html `a` tag

I want to have a link inside of an inline code block. As per How to link in markdown from an inline code fragment? - Stack Overflow, it is possible using html code tag for the inline code block, and a tag for the link. However, setting the href of the a tag to an item like you would for intra-doc links does not work, instead it links to the exact text of the href directly. I came across 1946-intra-rustdoc-links - The Rust RFC Book and saw that rust: prefix was suggested for the url scheme, but it does not seem to have made the implementation. Is there any way to do this without having to type the full rustdoc generated path, which would have to be manually updated and could break anytime?

As far as I know, you can't use <a>, but you don't have to; [] links may be used inside HTML elements. This should have two links:

/// For example, use <code>[Foo]&lt;[Bar]&gt;</code>
struct Foo<T>(T);

struct Bar;
2 Likes

That works perfectly! Did you use &lt; and &gt; to avoid having [Bar] treated as a reference link for [Foo]? In any case using \[Foo][Bar]/[Foo\][Bar] works too.

In both HTML and Markdown, you should use &lt; to escape < any time it is not part of a HTML tag. (It is not necessary to do the same for >, but more symmetric.)

Or did you mean why the < and > are present at all? That is because the example was of linking to both parts of a type with a generic parameter.

Yep, I completely skipped over everything besides the comment :sweat_smile: