Add comment to describe camelcase line break
This commit is contained in:
parent
e23419fc97
commit
f7eced3a21
@ -108,6 +108,16 @@ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|||||||
|| pk.map_or(true, |(_, t)| t.chars().any(|c| c.is_uppercase()));
|
|| 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_underscore = || pk.map_or(true, |(_, t)| t.contains('_'));
|
||||||
let next_is_colon = || 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() {
|
if i - last > 3 && is_uppercase() && !next_is_uppercase() && !next_is_underscore() {
|
||||||
EscapeBodyText(&text[last..i]).fmt(fmt)?;
|
EscapeBodyText(&text[last..i]).fmt(fmt)?;
|
||||||
fmt.write_str("<wbr>")?;
|
fmt.write_str("<wbr>")?;
|
||||||
|
Loading…
Reference in New Issue
Block a user