Skip to content

Commit 04dc4a6

Browse files
authored
chore: Use title as name for non-ascii titles (#50)
1 parent f455ebd commit 04dc4a6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

docs/src/html.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,17 @@ impl<'a> Handler<'a> {
307307

308308
*id_slot = (!id.is_empty()).then_some(id);
309309

310-
// Special case for things like "v0.3.0".
310+
let title = self.peeked.as_ref().map(|text| text.to_string());
311311
let name = if id.starts_with('v') && id.contains('.') {
312+
// Special case for things like "v0.3.0".
312313
id.into()
313-
} else {
314+
} else if title.iter().all(|c| c.is_ascii()) {
314315
id.to_title_case().into()
316+
} else {
317+
self.ids
318+
.alloc(title.expect("heading should always have a title"))
319+
.as_str()
320+
.into()
315321
};
316322

317323
let mut children = &mut self.outline;

0 commit comments

Comments
 (0)