Skip to content

Commit 18146d1

Browse files
committed
fix(ids): fix fixing ids
1 parent cd17a95 commit 18146d1

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Diff for: crates/rari-doc/src/html/modifier.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub fn add_missing_ids(html: &mut Html) -> Result<(), DocError> {
5555
} else {
5656
el.text().collect::<String>()
5757
};
58-
let id = anchorize(&text);
58+
let mut id = anchorize(&text);
5959
if ids.contains(id.as_str()) {
6060
let (prefix, mut count) = if let Some((prefix, counter)) = id.rsplit_once('_') {
6161
if counter.chars().all(|c| c.is_ascii_digit()) {
@@ -67,11 +67,12 @@ pub fn add_missing_ids(html: &mut Html) -> Result<(), DocError> {
6767
} else {
6868
(id.as_str(), 2)
6969
};
70-
let mut id = format!("{prefix}_{count}");
71-
while ids.contains(id.as_str()) && count < 666 {
70+
let mut new_id = format!("{prefix}_{count}");
71+
while ids.contains(new_id.as_str()) && count < 666 {
7272
count += 1;
73-
id = format!("{prefix}_{count}");
73+
new_id = format!("{prefix}_{count}");
7474
}
75+
id = new_id;
7576
}
7677

7778
ids.insert(Cow::Owned(id.clone()));

Diff for: crates/rari-md/src/anchor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ pub fn anchorize(content: &str) -> String {
1818
if !id.is_empty() {
1919
id
2020
} else {
21-
"sect1".to_string()
21+
"sect".to_string()
2222
}
2323
}

0 commit comments

Comments
 (0)