Skip to content

Commit

Permalink
Add comment to describe camelcase line break
Browse files Browse the repository at this point in the history
  • Loading branch information
notriddle committed Oct 7, 2024
1 parent e23419f commit f7eced3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/librustdoc/html/escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ impl<'a> fmt::Display for EscapeBodyTextWithWbr<'a> {
|| pk.map_or(true, |(_, t)| t.chars().any(|c| c.is_uppercase()));
let next_is_underscore = || pk.map_or(true, |(_, t)| t.contains('_'));
let next_is_colon = || pk.map_or(true, |(_, t)| t.contains(':'));
// Check for CamelCase.
//
// `i - last > 3` avoids turning FmRadio into Fm<wbr>Radio, which is technically
// correct, but needlessly bloated.
//
// is_uppercase && !next_is_uppercase checks for camelCase. HTTPSProxy,
// for example, should become HTTPS<wbr>Proxy.
//
// !next_is_underscore avoids turning TEST_RUN into TEST<wbr>_<wbr>RUN, which is also
// needlessly bloated.
if i - last > 3 && is_uppercase() && !next_is_uppercase() && !next_is_underscore() {
EscapeBodyText(&text[last..i]).fmt(fmt)?;
fmt.write_str("<wbr>")?;
Expand Down

0 comments on commit f7eced3

Please sign in to comment.