about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume.gomez@huawei.com>2022-02-25 15:35:10 +0100
committerGuillaume Gomez <guillaume.gomez@huawei.com>2023-12-05 15:59:40 +0100
commitd1dd589a1df3d0e2b392a1bd4034efa43326a4c9 (patch)
treea59eef1b75e94adb6785c4d58be924764a0d15d7 /src
parent8bc123e321b82359c80ce50dae62e13db39c96cc (diff)
downloadrust-d1dd589a1df3d0e2b392a1bd4034efa43326a4c9.tar.gz
rust-d1dd589a1df3d0e2b392a1bd4034efa43326a4c9.zip
Allow links in doc blocks headings
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/html/markdown.rs1
-rw-r--r--src/librustdoc/html/markdown/tests.rs7
2 files changed, 7 insertions, 1 deletions
diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs
index 6a48b9367b8..71ad9fc243c 100644
--- a/src/librustdoc/html/markdown.rs
+++ b/src/librustdoc/html/markdown.rs
@@ -539,7 +539,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);
diff --git a/src/librustdoc/html/markdown/tests.rs b/src/librustdoc/html/markdown/tests.rs
index fcf77783024..4dd176b3a69 100644
--- a/src/librustdoc/html/markdown/tests.rs
+++ b/src/librustdoc/html/markdown/tests.rs
@@ -336,6 +336,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]