Skip to content

Commit

Permalink
Auto merge of #96187 - GuillaumeGomez:potential-intra-doc-links-filte…
Browse files Browse the repository at this point in the history
…ring, 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`
  • Loading branch information
bors committed Apr 20, 2022
2 parents 51ea9bb + f988f86 commit 879aff3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,19 @@ crate fn markdown_links<R>(md: &str, filter_map: impl Fn(MarkdownLink) -> Option
let iter = Footnotes::new(HeadingLinks::new(p, None, &mut ids, HeadingOffset::H1));

for ev in iter {
if let Event::Start(Tag::Link(kind, dest, _)) = ev.0 {
if let Event::Start(Tag::Link(
// `<>` links cannot be intra-doc links so we skip them.
kind @ (LinkType::Inline
| LinkType::Reference
| LinkType::ReferenceUnknown
| LinkType::Collapsed
| LinkType::CollapsedUnknown
| LinkType::Shortcut
| LinkType::ShortcutUnknown),
dest,
_,
)) = ev.0
{
debug!("found link: {dest}");
let span = span_for_link(&dest, ev.1);
filter_map(MarkdownLink { kind, link: dest.into_string(), range: span })
Expand Down

0 comments on commit 879aff3

Please sign in to comment.