@@ -11,7 +11,7 @@ use std::rc::Rc;
1111use std:: cell:: RefCell ;
1212use sxd_document:: dom:: { Element , Document , ChildOfElement , Attribute } ;
1313use sxd_document:: QName ;
14- use sxd_document:: { as_str, as_opt_str , as_qname} ;
14+ use sxd_document:: { as_str, as_qname} ;
1515
1616#[ cfg( not( feature = "no-unsafe" ) ) ]
1717pub type NameStr < ' a > = & ' a str ;
@@ -298,7 +298,7 @@ impl<'a, 'op:'a> StackInfo<'a, 'op> {
298298 let children = self . mrow . children ( ) ;
299299 for & child in children. iter ( ) . rev ( ) {
300300 let child = as_element ( child) ;
301- if let Some ( value) = as_opt_str ! ( child. attribute_value( CHANGED_ATTR ) )
301+ if let Some ( value) = child. attribute_value ( CHANGED_ATTR ) . as_deref ( )
302302 && value == "empty_content" {
303303 continue ;
304304 }
@@ -398,7 +398,7 @@ pub fn get_presentation_element(element: Element) -> (usize, Element) {
398398 assert_eq ! ( name( element) , "semantics" ) ;
399399 let children = element. children ( ) ;
400400 if let Some ( ( i, child) ) = children. iter ( ) . enumerate ( ) . find ( |& ( _, & child) |
401- if let Some ( encoding) = as_opt_str ! ( as_element( child) . attribute_value( "encoding" ) ) {
401+ if let Some ( encoding) = as_element ( child) . attribute_value ( "encoding" ) . as_deref ( ) {
402402 encoding == "MathML-Presentation"
403403 } else {
404404 false
@@ -866,7 +866,7 @@ impl CanonicalizeContext {
866866 }
867867 return Some ( mathml) ;
868868 } else if OPERATORS . get ( as_str ! ( text) ) . is_some ( ) {
869- if let Some ( intent_value) = as_opt_str ! ( mathml. attribute_value( INTENT_ATTR ) ) {
869+ if let Some ( intent_value) = mathml. attribute_value ( INTENT_ATTR ) . as_deref ( ) {
870870 // if it is a unit, it might be seconds, minutes, feet, ... not an operator
871871 if intent_value. contains ( ":unit" ) {
872872 return Some ( mathml) ;
@@ -1059,7 +1059,7 @@ impl CanonicalizeContext {
10591059
10601060 // normalize width ems
10611061 let width_raw = mathml. attribute_value ( "width" ) ;
1062- let width = as_opt_str ! ( width_raw) . unwrap_or ( "0em" ) ;
1062+ let width = width_raw. as_deref ( ) . unwrap_or ( "0em" ) ;
10631063 let normalized_width = crate :: xpath_functions:: FontSizeGuess :: em_from_value ( width) ;
10641064 mathml. set_attribute_value ( "data-width" , & normalized_width. to_string ( ) ) ;
10651065 return Some ( mathml) ;
@@ -1243,7 +1243,7 @@ impl CanonicalizeContext {
12431243 if child == new_presentation {
12441244 continue ;
12451245 }
1246- let attr_name = match as_opt_str ! ( child. attribute_value( "encoding" ) ) {
1246+ let attr_name = match child. attribute_value ( "encoding" ) . as_deref ( ) {
12471247 Some ( encoding_name) => format ! ( "data-{}-{}" , child_name, encoding_name. replace( '/' , "_slash_" ) ) ,
12481248 None => format ! ( "data-{child_name}" ) , // probably shouldn't happen
12491249 } ;
@@ -1272,12 +1272,12 @@ impl CanonicalizeContext {
12721272 return false ;
12731273 }
12741274
1275- if let Some ( intent_value) = as_opt_str ! ( mathml. attribute_value( INTENT_ATTR ) )
1275+ if let Some ( intent_value) = mathml. attribute_value ( INTENT_ATTR ) . as_deref ( )
12761276 && ( intent_value != "ratio" || !intent_value. starts_with ( '_' ) ) {
12771277 return false ;
12781278 }
12791279
1280- if let Some ( value) = as_opt_str ! ( mathml. attribute_value( "data-mjx-texclass" ) )
1280+ if let Some ( value) = mathml. attribute_value ( "data-mjx-texclass" ) . as_deref ( )
12811281 && value == "PUNCT" {
12821282 mathml. remove_attribute ( "data-mjx-texclass" ) ;
12831283 mathml. set_attribute_value ( SPACE_AFTER , "true" ) ; // signal to at least Nemeth rules that this is punctuation
@@ -1359,7 +1359,7 @@ impl CanonicalizeContext {
13591359 } else {
13601360 mathml
13611361 } ;
1362- if let Some ( width) = as_opt_str ! ( mpadded. attribute_value( "width" ) ) {
1362+ if let Some ( width) = mpadded. attribute_value ( "width" ) . as_deref ( ) {
13631363 if width != "0" {
13641364 return false ;
13651365 }
@@ -1801,12 +1801,12 @@ impl CanonicalizeContext {
18011801 fn convert_mfenced_to_mrow ( mfenced : Element ) -> Element {
18021802 // The '<'/'>' replacements are because WIRIS uses them out instead of the correct chars in its template
18031803 let open_raw = mfenced. attribute_value ( "open" ) ;
1804- let open = as_opt_str ! ( open_raw) . unwrap_or ( "(" ) . replace ( '<' , "⟨" ) ;
1804+ let open = open_raw. as_deref ( ) . unwrap_or ( "(" ) . replace ( '<' , "⟨" ) ;
18051805 let close_raw = mfenced. attribute_value ( "close" ) ;
1806- let close = as_opt_str ! ( close_raw) . unwrap_or ( ")" ) . replace ( '>' , "⟩" ) ;
1806+ let close = close_raw. as_deref ( ) . unwrap_or ( ")" ) . replace ( '>' , "⟩" ) ;
18071807 // debug!("open={}, close={}", open, close);
18081808 let separators_raw = mfenced. attribute_value ( "separators" ) ;
1809- let mut separators = as_opt_str ! ( separators_raw) . unwrap_or ( "," ) . chars ( ) ;
1809+ let mut separators = separators_raw. as_deref ( ) . unwrap_or ( "," ) . chars ( ) ;
18101810 set_mathml_name ( mfenced, "mrow" ) ;
18111811 mfenced. remove_attribute ( "open" ) ;
18121812 mfenced. remove_attribute ( "close" ) ;
@@ -1956,7 +1956,7 @@ impl CanonicalizeContext {
19561956 // i, whitespace, previous_mtext_with_width.is_some(), mml_to_string(child));
19571957 if is_child_whitespace {
19581958 // update the running total of whitespace
1959- let child_width = as_opt_str ! ( child. attribute_value( "data-width" ) ) . unwrap_or ( "0" )
1959+ let child_width = child. attribute_value ( "data-width" ) . as_deref ( ) . unwrap_or ( "0" )
19601960 . parse :: < f64 > ( ) . unwrap_or ( 0.0 ) ;
19611961 whitespace = match whitespace {
19621962 None => Some ( child_width) ,
@@ -1993,7 +1993,7 @@ impl CanonicalizeContext {
19931993 if children. len ( ) == 1 {
19941994 // only child -- check to see if we need to set the space-width
19951995 let child = as_element ( children[ 0 ] ) ;
1996- let child_width = as_opt_str ! ( child. attribute_value( "data-width" ) ) . unwrap_or ( "0" ) . parse :: < f64 > ( ) . unwrap_or ( 0.0 ) ;
1996+ let child_width = child. attribute_value ( "data-width" ) . as_deref ( ) . unwrap_or ( "0" ) . parse :: < f64 > ( ) . unwrap_or ( 0.0 ) ;
19971997 if ( child_width - ws) . abs ( ) > 0.001 {
19981998 ws += child_width;
19991999 child. set_attribute_value ( "data-following-space-width" , ws. to_string ( ) . as_str ( ) ) ;
@@ -3156,7 +3156,7 @@ impl CanonicalizeContext {
31563156
31573157 let mi_text = as_str ! ( as_text( mi) ) ;
31583158 let variant_raw = mi. attribute_value ( "mathvariant" ) ;
3159- let variant = as_opt_str ! ( variant_raw) ;
3159+ let variant = variant_raw. as_deref ( ) ;
31603160
31613161 if names. contains ( mi_text) {
31623162 return mi; // avoid mapping mathvariant for function names
@@ -3490,7 +3490,7 @@ impl CanonicalizeContext {
34903490
34913491 // if a form has been given, that takes precedence
34923492 let form_raw = mo_node. attribute_value ( "form" ) ;
3493- let form = as_opt_str ! ( form_raw) ;
3493+ let form = form_raw. as_deref ( ) ;
34943494 let op_type = match form {
34953495 None => match context {
34963496 None => OperatorTypes :: POSTFIX , // what compute_type_from_position returns when the other args to this are all None
@@ -3694,7 +3694,7 @@ impl CanonicalizeContext {
36943694
36953695 // debug!(" in is_likely_chemical_state: '{}'?",element_summary(node));
36963696 let node_chem_raw = node. attribute_value ( MAYBE_CHEMISTRY ) ;
3697- let node_chem_likelihood = as_opt_str ! ( node_chem_raw) ;
3697+ let node_chem_likelihood = node_chem_raw. as_deref ( ) ;
36983698 if node. attribute ( MAYBE_CHEMISTRY ) . is_none ( ) {
36993699 return FunctionNameCertainty :: True ;
37003700 }
@@ -4401,7 +4401,7 @@ impl CanonicalizeContext {
44014401 } else {
44024402 OperatorPair { ch : op_ch ( "\u{2062} " ) , op : * IMPLIED_TIMES , _phantom : PhantomData }
44034403 } ;
4404- if let Some ( attr_val) = as_opt_str ! ( base_of_child. attribute_value( CHANGED_ATTR ) )
4404+ if let Some ( attr_val) = base_of_child. attribute_value ( CHANGED_ATTR ) . as_deref ( )
44054405 && attr_val == "data-was-mo" {
44064406 // it really should be an operator
44074407 base_of_child. remove_attribute ( CHANGED_ATTR ) ;
0 commit comments