Skip to content

Commit f7eced3

Browse files
committed
Add comment to describe camelcase line break
1 parent e23419f commit f7eced3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/librustdoc/html/escape.rs

+10
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,16 @@ 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+
// Check for CamelCase.
112+
//
113+
// `i - last > 3` avoids turning FmRadio into Fm<wbr>Radio, which is technically
114+
// correct, but needlessly bloated.
115+
//
116+
// is_uppercase && !next_is_uppercase checks for camelCase. HTTPSProxy,
117+
// for example, should become HTTPS<wbr>Proxy.
118+
//
119+
// !next_is_underscore avoids turning TEST_RUN into TEST<wbr>_<wbr>RUN, which is also
120+
// needlessly bloated.
111121
if i - last > 3 && is_uppercase() && !next_is_uppercase() && !next_is_underscore() {
112122
EscapeBodyText(&text[last..i]).fmt(fmt)?;
113123
fmt.write_str("<wbr>")?;

0 commit comments

Comments
 (0)