Add comment to describe camelcase line break
This commit is contained in:
parent
e23419fc97
commit
f7eced3a21
1 changed files with 10 additions and 0 deletions
|
@ -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>")?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue