@@ -298,13 +298,13 @@ pub fn get_navigation_node_from_braille_position(mathml: Element, position: usiz
298298 // save the current highlight state, set the state to be the end points so we can find the braille, then restore the state
299299 // FIX: this can fail if there is 8-dot braille
300300 use crate :: interface:: { get_preference, set_preference} ;
301- let saved_highlight_style = get_preference ( "BrailleNavHighlight" . to_string ( ) ) . unwrap ( ) ;
302- set_preference ( "BrailleNavHighlight" . to_string ( ) , "EndPoints" . to_string ( ) ) . unwrap ( ) ;
301+ let saved_highlight_style = get_preference ( "BrailleNavHighlight" ) . unwrap ( ) ;
302+ set_preference ( "BrailleNavHighlight" , "EndPoints" ) . unwrap ( ) ;
303303
304304 N_PROBES . with ( |n| { * n. borrow_mut ( ) = 0 } ) ;
305305 // dive into the child of the <math> element (should only be one)
306306 let search_state = find_navigation_node ( mathml, as_element ( mathml. children ( ) [ 0 ] ) , position) ?;
307- set_preference ( "BrailleNavHighlight" . to_string ( ) , saved_highlight_style. to_string ( ) ) . unwrap ( ) ;
307+ set_preference ( "BrailleNavHighlight" , saved_highlight_style. as_str ( ) ) . unwrap ( ) ;
308308
309309 // we know the attr value exists because it was found internally
310310 // FIX: what should be done if we never did the search?
@@ -2237,13 +2237,13 @@ fn ASCIIMath_cleanup(_pref_manager: Ref<PreferenceManager>, raw_braille: String)
22372237
22382238
22392239/************** Braille xpath functionality ***************/
2240- use crate :: canonicalize:: { name, as_element, as_text} ;
2241- use crate :: xpath_functions:: { is_leaf, IsBracketed , validate_one_node} ;
2240+ use crate :: canonicalize:: { as_element, as_text, name} ;
2241+ use crate :: xpath_functions:: { is_leaf, validate_one_node, IsBracketed } ;
2242+ use std:: result:: Result as StdResult ;
22422243use sxd_document:: dom:: ParentOfChild ;
2243- use sxd_xpath:: { Value , context, nodeset:: * } ;
2244- use sxd_xpath:: function:: { Function , Args } ;
22452244use sxd_xpath:: function:: Error as XPathError ;
2246- use std:: result:: Result as StdResult ;
2245+ use sxd_xpath:: function:: { Args , Function } ;
2246+ use sxd_xpath:: { context, nodeset:: * , Value } ;
22472247
22482248pub struct NemethNestingChars ;
22492249const NEMETH_FRAC_LEVEL : & str = "data-nemeth-frac-level" ; // name of attr where value is cached
@@ -2781,7 +2781,7 @@ impl NeedsToBeGrouped {
27812781 // if the fraction starts with a "-", it is still a numeric fraction that doesn't need parens
27822782 let mut numerator = as_element ( children[ 0 ] ) ;
27832783 let denominator = as_element ( children[ children. len ( ) -1 ] ) ;
2784- let decimal_separator = crate :: interface:: get_preference ( "DecimalSeparators" . to_string ( ) ) . unwrap ( )
2784+ let decimal_separator = crate :: interface:: get_preference ( "DecimalSeparators" ) . unwrap ( )
27852785 . chars ( ) . next ( ) . unwrap_or ( '.' ) ;
27862786 if is_integer ( denominator, decimal_separator) {
27872787 // check numerator being either an integer "- integer"
@@ -3066,7 +3066,7 @@ mod tests {
30663066 #[ allow( unused_imports) ]
30673067 use crate :: init_logger;
30683068 use crate :: interface:: * ;
3069-
3069+
30703070 #[ test]
30713071 fn ueb_highlight_24 ( ) -> Result < ( ) > { // issue 24
30723072 let mathml_str = "<math display='block' id='id-0'>
@@ -3080,16 +3080,16 @@ mod tests {
30803080 </math>" ;
30813081 crate :: interface:: set_rules_dir ( super :: super :: abs_rules_dir_path ( ) ) . unwrap ( ) ;
30823082 set_mathml ( mathml_str. to_string ( ) ) . unwrap ( ) ;
3083- set_preference ( "BrailleCode" . to_string ( ) , "UEB" . to_string ( ) ) . unwrap ( ) ;
3084- set_preference ( "BrailleNavHighlight" . to_string ( ) , "All" . to_string ( ) ) . unwrap ( ) ;
3085- let braille = get_braille ( "id-2" . to_string ( ) ) ?;
3083+ set_preference ( "BrailleCode" , "UEB" ) . unwrap ( ) ;
3084+ set_preference ( "BrailleNavHighlight" , "All" ) . unwrap ( ) ;
3085+ let braille = get_braille ( "id-2" ) ?;
30863086 assert_eq ! ( "⣼⣙⠰⠁⠉" , braille) ;
3087- set_navigation_node ( "id-2" . to_string ( ) , 0 ) ?;
3087+ set_navigation_node ( "id-2" , 0 ) ?;
30883088 assert_eq ! ( get_braille_position( ) ?, ( 0 , 2 ) ) ;
30893089
3090- let braille = get_braille ( "id-4" . to_string ( ) ) ?;
3090+ let braille = get_braille ( "id-4" ) ?;
30913091 assert_eq ! ( "⠼⠙⣰⣁⠉" , braille) ;
3092- set_navigation_node ( "id-4" . to_string ( ) , 0 ) ?;
3092+ set_navigation_node ( "id-4" , 0 ) ?;
30933093 assert_eq ! ( get_braille_position( ) ?, ( 2 , 4 ) ) ;
30943094 return Ok ( ( ) ) ;
30953095 }
@@ -3136,10 +3136,10 @@ mod tests {
31363136 </math>" ;
31373137 crate :: interface:: set_rules_dir ( super :: super :: abs_rules_dir_path ( ) ) . unwrap ( ) ;
31383138 set_mathml ( mathml_str. to_string ( ) ) . unwrap ( ) ;
3139- set_preference ( "BrailleNavHighlight" . to_string ( ) , "Off" . to_string ( ) ) . unwrap ( ) ;
3140-
3141- set_preference ( "BrailleCode" . to_string ( ) , "Nemeth" . to_string ( ) ) . unwrap ( ) ;
3142- let braille = get_braille ( "" . to_string ( ) ) ?;
3139+ set_preference ( "BrailleNavHighlight" , "Off" ) . unwrap ( ) ;
3140+
3141+ set_preference ( "BrailleCode" , "Nemeth" ) . unwrap ( ) ;
3142+ let braille = get_braille ( "" ) ?;
31433143 let answers= & [ 2 , 3 , 3 , 3 , 3 , 4 , 7 , 8 , 9 , 9 , 10 , 13 , 12 , 14 , 12 , 15 , 17 , 19 , 21 , 10 , 4 , 23 , 25 , 4 ] ;
31443144 let answers = answers. map ( |num| format ! ( "id-{}" , num) ) ;
31453145 debug ! ( "\n *** Testing Nemeth ***" ) ;
@@ -3152,8 +3152,8 @@ mod tests {
31523152 assert_eq ! ( answers[ i] , id, "\n Nemeth test ith position={}" , i) ;
31533153 }
31543154
3155- set_preference ( "BrailleCode" . to_string ( ) , "UEB" . to_string ( ) ) . unwrap ( ) ;
3156- let braille = get_braille ( "" . to_string ( ) ) ?;
3155+ set_preference ( "BrailleCode" , "UEB" ) . unwrap ( ) ;
3156+ let braille = get_braille ( "" ) ?;
31573157 let answers= & [ 0 , 0 , 0 , 2 , 3 , 3 , 3 , 3 , 4 , 7 , 7 , 8 , 9 , 9 , 10 , 13 , 12 , 14 , 14 , 15 , 15 , 17 , 17 , 19 , 19 , 21 , 10 , 4 , 4 , 23 , 23 , 25 , 25 , 4 , 0 , 0 ] ;
31583158 let answers = answers. map ( |num| format ! ( "id-{}" , num) ) ;
31593159 debug ! ( "\n \n *** Testing UEB ***" ) ;
@@ -3165,8 +3165,8 @@ mod tests {
31653165 debug ! ( "Time taken: {}ms" , instant. elapsed( ) . as_millis( ) ) ;
31663166 assert_eq ! ( answers[ i] , id, "\n UEB test ith position={}" , i) ;
31673167 }
3168- set_preference ( "BrailleCode" . to_string ( ) , "CMU" . to_string ( ) ) . unwrap ( ) ;
3169- let braille = get_braille ( "" . to_string ( ) ) ?;
3168+ set_preference ( "BrailleCode" , "CMU" ) . unwrap ( ) ;
3169+ let braille = get_braille ( "" ) ?;
31703170 let answers= & [ 2 , 3 , 5 , 7 , 8 , 9 , 9 , 9 , 10 , 10 , 11 , 13 , 12 , 14 , 14 , 15 , 17 , 17 , 19 , 19 , 21 , 11 , 5 , 4 , 22 , 23 , 23 , 25 , 25 , 22 , ] ;
31713171 let answers = answers. map ( |num| format ! ( "id-{}" , num) ) ;
31723172 debug ! ( "\n \n *** Testing CMU ***" ) ;
@@ -3188,12 +3188,12 @@ mod tests {
31883188 let mathml_str = "<math><msup><mi>x</mi><mi>n</mi></msup></math>" ;
31893189 crate :: interface:: set_rules_dir ( super :: super :: abs_rules_dir_path ( ) ) . unwrap ( ) ;
31903190 set_mathml ( mathml_str. to_string ( ) ) . unwrap ( ) ;
3191- set_preference ( "BrailleCode" . to_string ( ) , "UEB" . to_string ( ) ) . unwrap ( ) ;
3192- set_preference ( "UEB_START_MODE" . to_string ( ) , "Grade2" . to_string ( ) ) . unwrap ( ) ;
3193- let braille = get_braille ( "" . to_string ( ) ) ?;
3191+ set_preference ( "BrailleCode" , "UEB" ) . unwrap ( ) ;
3192+ set_preference ( "UEB_START_MODE" , "Grade2" ) . unwrap ( ) ;
3193+ let braille = get_braille ( "" ) ?;
31943194 assert_eq ! ( "⠭⠰⠔⠝" , braille, "Grade2" ) ;
3195- set_preference ( "UEB_START_MODE" . to_string ( ) , "Grade1" . to_string ( ) ) . unwrap ( ) ;
3196- let braille = get_braille ( "" . to_string ( ) ) ?;
3195+ set_preference ( "UEB_START_MODE" , "Grade1" ) . unwrap ( ) ;
3196+ let braille = get_braille ( "" ) ?;
31973197 assert_eq ! ( "⠭⠔⠝" , braille, "Grade1" ) ;
31983198 return Ok ( ( ) ) ;
31993199 }
0 commit comments