Skip to content

Commit 24cbbf9

Browse files
committed
rustdoc: improve <wbr>-insertion for SCREAMING_CAMEL_CASE
1 parent 7caad69 commit 24cbbf9

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/librustdoc/html/escape.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl<'a> fmt::Display for EscapeBodyTextWithWbr<'a> {
108108
|| pk.map_or(true, |(_, t)| t.chars().any(|c| c.is_uppercase()));
109109
let next_is_underscore = || pk.map_or(true, |(_, t)| t.contains('_'));
110110
let next_is_colon = || pk.map_or(true, |(_, t)| t.contains(':'));
111-
if i - last > 3 && is_uppercase() && !next_is_uppercase() {
111+
if i - last > 3 && is_uppercase() && !next_is_uppercase() && !next_is_underscore() {
112112
EscapeBodyText(&text[last..i]).fmt(fmt)?;
113113
fmt.write_str("<wbr>")?;
114114
last = i;

src/librustdoc/html/escape/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ fn escape_body_text_with_wbr() {
2424
assert_eq!(&E("first:second").to_string(), "first:<wbr>second");
2525
assert_eq!(&E("first::second").to_string(), "first::<wbr>second");
2626
assert_eq!(&E("MY_CONSTANT").to_string(), "MY_<wbr>CONSTANT");
27+
assert_eq!(&E("_SIDD_MASKED_NEGATIVE_POLARITY").to_string(), "_SIDD_<wbr>MASKED_<wbr>NEGATIVE_<wbr>POLARITY");
2728
// a string won't get wrapped if it's less than 8 bytes
2829
assert_eq!(&E("HashSet").to_string(), "HashSet");
2930
// an individual word won't get wrapped if it's less than 4 bytes

0 commit comments

Comments
 (0)