Skip to content

Commit 579f0c1

Browse files
--tldr added <detail> tag stripping
1 parent b2df171 commit 579f0c1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/bin/cratedocs.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ fn apply_tldr(input: &str) -> String {
210210
let tldr_section_re = Regex::new(r"(?i)^\s*#+\s*license\b|^\s*#+\s*version(s)?\b|^\s*#+license\b|^\s*#+version(s)?\b").unwrap();
211211
// Match any heading (for ending the skip)
212212
let heading_re = Regex::new(r"^\s*#+").unwrap();
213+
// Match <detail> tags including start, end, and inline attributes
214+
let detail_tag_re = Regex::new(r"<[/]?detail.*?>").unwrap();
213215

214216
for line in input.lines() {
215217
// Start skipping if we hit a LICENSE or VERSION(S) heading
@@ -222,10 +224,12 @@ fn apply_tldr(input: &str) -> String {
222224
skip = false;
223225
}
224226
if !skip {
225-
output.push(line);
227+
// Remove <detail> tags from the line
228+
let cleaned_line = detail_tag_re.replace_all(line, "").to_string();
229+
output.push(cleaned_line.to_string());
226230
}
227231
}
228-
output.join("\n")
232+
output.iter().map(|s| s.as_str()).collect::<Vec<_>>().join("\n")
229233
}
230234

231235
/// Configuration for the test tool
@@ -594,3 +598,4 @@ Another version section.
594598
assert!(output.contains("Some real documentation here."));
595599
}
596600
}
601+

0 commit comments

Comments
 (0)