blob: d7bd6244abdae375de595cf17a728ae5ae2b19be (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
//! Path display helpers.
use std::path::Path;
/// Converts a path to a Markdown-friendly display string.
///
/// This uses Rust's debug path formatting, then strips surrounding quotes when present. That keeps
/// escaped characters such as newlines and invalid UTF-8 markers visible in generated Markdown
/// headings.
pub fn display_path(path: &Path) -> String {
let s = format!("{:?}", path);
s.strip_prefix('"')
.and_then(|s| s.strip_suffix('"'))
.unwrap_or(&s)
.to_string()
}
|