Skip to content

Commit 85934d5

Browse files
committed
Use url escaping instead of percent encoding
1 parent 255dd0d commit 85934d5

File tree

3 files changed

+7
-19
lines changed

3 files changed

+7
-19
lines changed

Cargo.lock

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ env_logger = "0.11.6"
2121
log = "0.4.26"
2222
mdbook = "0.4.45"
2323
path-slash = "0.2.1"
24-
percent-encoding = "2.3.1"
2524
semver = "1.0.25"
2625
serde = "1.0.218"
2726
serde_derive = "1.0.218"

src/parser.rs

+7-17
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,10 @@ use std::{
88
use anyhow::Error;
99
use log::warn;
1010
use path_slash::PathExt;
11-
use percent_encoding::{NON_ALPHANUMERIC, utf8_percent_encode};
1211
use walkdir::WalkDir;
1312

1413
use crate::Config;
1514

16-
fn url_encode(input: &str) -> String {
17-
utf8_percent_encode(input, NON_ALPHANUMERIC).to_string()
18-
}
19-
2015
/// Representation of an mdbook src directory entry
2116
/// This may be a folder or a .md file
2217
#[derive(Debug, Clone)]
@@ -180,19 +175,14 @@ impl Display for DocFolder {
180175
let index = self.path.join(&self.index);
181176
// If this is the src folder
182177
if self.depth == 0 {
183-
writeln!(
184-
f,
185-
"[{}]({})",
186-
self.title,
187-
url_encode(index.to_slash_lossy().as_ref())
188-
)?;
178+
writeln!(f, "[{}](<{}>)", self.title, index.to_slash_lossy().as_ref())?;
189179
} else {
190180
writeln!(
191181
f,
192-
"{}- [{}]({})",
182+
"{}- [{}](<{}>)",
193183
" ".repeat(((self.depth - 1) as usize) * 2),
194184
self.title,
195-
url_encode(index.to_slash_lossy().as_ref())
185+
index.to_slash_lossy().as_ref()
196186
)?;
197187
}
198188

@@ -292,18 +282,18 @@ impl Display for DocFile {
292282
if self.depth == 0 || self.depth == 1 {
293283
return writeln!(
294284
f,
295-
"[{}]({})",
285+
"[{}](<{}>)",
296286
self.title,
297-
url_encode(self.path.to_slash_lossy().as_ref())
287+
self.path.to_slash_lossy().as_ref()
298288
);
299289
}
300290

301291
writeln!(
302292
f,
303-
"{}- [{}]({})",
293+
"{}- [{}](<{}>)",
304294
" ".repeat(((self.depth - 1) as usize) * 2),
305295
self.title,
306-
url_encode(self.path.to_slash_lossy().as_ref())
296+
self.path.to_slash_lossy().as_ref()
307297
)
308298
}
309299
}

0 commit comments

Comments
 (0)