Skip to content

Commit

Permalink
Allow links in doc blocks headings
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Feb 25, 2022
1 parent 9b97045 commit 79da81e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,6 @@ impl<'a, 'b, 'ids, I: Iterator<Item = SpannedEvent<'a>>> Iterator
for event in &mut self.inner {
match &event.0 {
Event::End(Tag::Heading(..)) => break,
Event::Start(Tag::Link(_, _, _)) | Event::End(Tag::Link(..)) => {}
Event::Text(text) | Event::Code(text) => {
id.extend(text.chars().filter_map(slugify));
self.buf.push_back(event);
Expand Down
7 changes: 7 additions & 0 deletions src/librustdoc/html/markdown/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ fn test_header() {
<strong>Foo?</strong> &amp; *bar?!* <em><code>baz</code></em> ❤ #qux\
</h5>",
);
t(
"# Foo [bar](https://hello.yo)",
"<h2 id=\"foo-bar\">\
<a class=\"doc-anchor\" href=\"#foo-bar\">§</a>\
Foo <a href=\"https://hello.yo\">bar</a>\
</h2>",
);
}

#[test]
Expand Down

0 comments on commit 79da81e

Please sign in to comment.