Skip to content

Commit 879aff3

Browse files
committed
Auto merge of #96187 - GuillaumeGomez:potential-intra-doc-links-filtering, r=notriddle
Prevent `<>` links to be interpreted for intra-doc links As discussed in [this thread](#96135 (comment)). As mentioned, the intra-doc RFC states that `<>` links shouldn't be potential intra-doc links: https://rust-lang.github.io/rfcs/1946-intra-rustdoc-links.html#no-autolinks-style. I renamed `markdown_links` into `potential_intra_doc_markdown_links` to make it more obvious what it's doing. cc `@petrochenkov` r? `@notriddle`
2 parents 51ea9bb + f988f86 commit 879aff3

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/librustdoc/html/markdown.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,19 @@ crate fn markdown_links<R>(md: &str, filter_map: impl Fn(MarkdownLink) -> Option
13121312
let iter = Footnotes::new(HeadingLinks::new(p, None, &mut ids, HeadingOffset::H1));
13131313

13141314
for ev in iter {
1315-
if let Event::Start(Tag::Link(kind, dest, _)) = ev.0 {
1315+
if let Event::Start(Tag::Link(
1316+
// `<>` links cannot be intra-doc links so we skip them.
1317+
kind @ (LinkType::Inline
1318+
| LinkType::Reference
1319+
| LinkType::ReferenceUnknown
1320+
| LinkType::Collapsed
1321+
| LinkType::CollapsedUnknown
1322+
| LinkType::Shortcut
1323+
| LinkType::ShortcutUnknown),
1324+
dest,
1325+
_,
1326+
)) = ev.0
1327+
{
13161328
debug!("found link: {dest}");
13171329
let span = span_for_link(&dest, ev.1);
13181330
filter_map(MarkdownLink { kind, link: dest.into_string(), range: span })

0 commit comments

Comments
 (0)