Skip to content
This repository was archived by the owner on Oct 17, 2024. It is now read-only.

Commit f0937ce

Browse files
authored
Do not remove space before .ext (#61)
1 parent 6ecfe8b commit f0937ce

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

rust/src/project.rs

+17-14
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub fn fix(
2626
return;
2727
}
2828
let table = &mut table_element.unwrap().first().unwrap().borrow_mut();
29+
let re = Regex::new(r" \.(\W)").unwrap();
2930
expand_entry_points_inline_tables(table);
3031
for_entries(table, &mut |key, entry| match key.split('.').next().unwrap() {
3132
"name" => {
@@ -36,18 +37,20 @@ pub fn fix(
3637
}
3738
"description" => {
3839
update_content(entry, |s| {
39-
s.trim()
40-
.lines()
41-
.map(|part| {
42-
part.trim()
43-
.split(char::is_whitespace)
44-
.filter(|part| !part.trim().is_empty())
45-
.collect::<Vec<&str>>()
46-
.join(" ")
47-
.replace(" .", ".")
48-
})
49-
.collect::<Vec<String>>()
50-
.join(" ")
40+
re.replace_all(
41+
&s.trim()
42+
.lines()
43+
.map(|part| {
44+
part.split_whitespace()
45+
.filter(|part| !part.trim().is_empty())
46+
.collect::<Vec<&str>>()
47+
.join(" ")
48+
})
49+
.collect::<Vec<String>>()
50+
.join(" "),
51+
".$1",
52+
)
53+
.to_string()
5154
});
5255
}
5356
"requires-python" => {
@@ -659,10 +662,10 @@ mod tests {
659662
(3, 13),
660663
)]
661664
#[case::project_description_whitespace(
662-
"[project]\ndescription = ' A magic stuff \t is great\t\t.\r\n Like really .\t\'\nrequires-python = '==3.12'",
665+
"[project]\ndescription = ' A magic stuff \t is great\t\t.\r\n Like really . Works on .rst and .NET :)\t\'\nrequires-python = '==3.12'",
663666
indoc ! {r#"
664667
[project]
665-
description = "A magic stuff is great. Like really."
668+
description = "A magic stuff is great. Like really. Works on .rst and .NET :)"
666669
requires-python = "==3.12"
667670
classifiers = [
668671
"Programming Language :: Python :: 3 :: Only",

0 commit comments

Comments
 (0)