File tree 1 file changed +10
-0
lines changed
1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,16 @@ impl<'a> fmt::Display for EscapeBodyTextWithWbr<'a> {
108
108
|| pk. map_or ( true , |( _, t) | t. chars ( ) . any ( |c| c. is_uppercase ( ) ) ) ;
109
109
let next_is_underscore = || pk. map_or ( true , |( _, t) | t. contains ( '_' ) ) ;
110
110
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.
111
121
if i - last > 3 && is_uppercase ( ) && !next_is_uppercase ( ) && !next_is_underscore ( ) {
112
122
EscapeBodyText ( & text[ last..i] ) . fmt ( fmt) ?;
113
123
fmt. write_str ( "<wbr>" ) ?;
You can’t perform that action at this time.
0 commit comments