about summary refs log tree commit diff
path: root/src/librustdoc/html/markdown.rs
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2025-02-12 20:10:01 -0500
committerGitHub <noreply@github.com>2025-02-12 20:10:01 -0500
commit9fe0d25fcb7e48937da6c56a083f42f8c457b5a8 (patch)
tree7f5df49e896ddeb1d44452b36b5f2529c716a0ec /src/librustdoc/html/markdown.rs
parentde712f9e0af724f513e3b8da1141878487d22d20 (diff)
parent17cf100f11bc8e952d2d70f0953b83c971cd5873 (diff)
downloadrust-9fe0d25fcb7e48937da6c56a083f42f8c457b5a8.tar.gz
rust-9fe0d25fcb7e48937da6c56a083f42f8c457b5a8.zip
Rollup merge of #136927 - GuillaumeGomez:add-missing-hashtag-escape, r=notriddle
Correctly escape hashtags when running `invalid_rust_codeblocks` lint

Fixes #136899.

We forgot to use `map_line` when we wrote this lint.

r? ``@notriddle``
Diffstat (limited to 'src/librustdoc/html/markdown.rs')
-rw-r--r--src/librustdoc/html/markdown.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs
index 0ce1dad7863..bd8eda2fed6 100644
--- a/src/librustdoc/html/markdown.rs
+++ b/src/librustdoc/html/markdown.rs
@@ -139,7 +139,7 @@ impl ErrorCodes {
 /// Controls whether a line will be hidden or shown in HTML output.
 ///
 /// All lines are used in documentation tests.
-enum Line<'a> {
+pub(crate) enum Line<'a> {
     Hidden(&'a str),
     Shown(Cow<'a, str>),
 }
@@ -152,7 +152,7 @@ impl<'a> Line<'a> {
         }
     }
 
-    fn for_code(self) -> Cow<'a, str> {
+    pub(crate) fn for_code(self) -> Cow<'a, str> {
         match self {
             Line::Shown(l) => l,
             Line::Hidden(l) => Cow::Borrowed(l),
@@ -160,12 +160,14 @@ impl<'a> Line<'a> {
     }
 }
 
+/// This function is used to handle the "hidden lines" (ie starting with `#`) in
+/// doctests. It also transforms `##` back into `#`.
 // FIXME: There is a minor inconsistency here. For lines that start with ##, we
 // have no easy way of removing a potential single space after the hashes, which
 // is done in the single # case. This inconsistency seems okay, if non-ideal. In
 // order to fix it we'd have to iterate to find the first non-# character, and
 // then reallocate to remove it; which would make us return a String.
-fn map_line(s: &str) -> Line<'_> {
+pub(crate) fn map_line(s: &str) -> Line<'_> {
     let trimmed = s.trim();
     if trimmed.starts_with("##") {
         Line::Shown(Cow::Owned(s.replacen("##", "#", 1)))