2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ 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
- if i - last > 3 && is_uppercase ( ) && !next_is_uppercase ( ) {
111
+ if i - last > 3 && is_uppercase ( ) && !next_is_uppercase ( ) && ! next_is_underscore ( ) {
112
112
EscapeBodyText ( & text[ last..i] ) . fmt ( fmt) ?;
113
113
fmt. write_str ( "<wbr>" ) ?;
114
114
last = i;
Original file line number Diff line number Diff line change @@ -24,6 +24,10 @@ fn escape_body_text_with_wbr() {
24
24
assert_eq ! ( & E ( "first:second" ) . to_string( ) , "first:<wbr>second" ) ;
25
25
assert_eq ! ( & E ( "first::second" ) . to_string( ) , "first::<wbr>second" ) ;
26
26
assert_eq ! ( & E ( "MY_CONSTANT" ) . to_string( ) , "MY_<wbr>CONSTANT" ) ;
27
+ assert_eq ! (
28
+ & E ( "_SIDD_MASKED_NEGATIVE_POLARITY" ) . to_string( ) ,
29
+ "_SIDD_<wbr>MASKED_<wbr>NEGATIVE_<wbr>POLARITY"
30
+ ) ;
27
31
// a string won't get wrapped if it's less than 8 bytes
28
32
assert_eq ! ( & E ( "HashSet" ) . to_string( ) , "HashSet" ) ;
29
33
// an individual word won't get wrapped if it's less than 4 bytes
0 commit comments