|
238 | 238 | tag: unit |
239 | 239 | match: "$Verbosity != 'Terse' and contains(@data-intent-property, ':unit')" |
240 | 240 | variables: |
241 | | - # we need to look at preceding-sibling::*[2] because invisible times should have been added |
242 | | - # if in a fraction, only count if we are in the numerator |
243 | | - - IsSingular: "(parent::m:mrow and preceding-sibling::*[2][self::m:mn and . = 1]) or |
244 | | - (ancestor::*[2][self::m:mrow] and parent::m:fraction and |
245 | | - (preceding-sibling::* or parent::*[preceding-sibling::*[2][self::m:mn and . = 1]]) |
246 | | - )" |
| 241 | + # If the coefficient is singular, we don't add the plural ending. Finding the coefficient is tricky |
| 242 | + # Normal case (A) "3m" (parents is mrow), but could also be (B) "3 m^2" (etc.) (parent is power/mrow) |
| 243 | + # But it might be in a fraction as (C) "3 m/s" (parent is fraction/mrow) or (D) "3 m^2/s^2" (parent is power/fraction/mrow) |
| 244 | + # or even (E) {3 m^2}/s (parent is power/mrow) |
| 245 | + # If in a fraction, only look in the numerator to find the coefficient |
| 246 | + # Note: we have a special case for pseudo-scripts like "°" (degrees) which are not powers -- they are essentially "1^°" |
| 247 | + # The following "IfThenElse" logic returns the mrow that potentially contains the coefficient, if it exists |
| 248 | + # The tests are in the order A, B & E, C, D |
| 249 | + - MRowForCoefficient: "IfThenElse(parent::m:mrow, parent::m:mrow, |
| 250 | + IfThenElse(parent::m:power, ancestor::*[2][self::m:mrow], |
| 251 | + IfThenElse(parent::m:fraction and not(preceding-sibling::*), ancestor::*[2][self::m:mrow], |
| 252 | + IfThenElse(parent::m:power[parent::m:fraction and not(preceding-sibling::*)], ancestor::*[3][self::m:mrow], false()) ) ) )" |
| 253 | + - IsSingular: "(not(DEBUG($MRowForCoefficient)) and parent::*[name(.)!='skip-super' or *[1][.=1]]) or |
| 254 | + ($MRowForCoefficient and $MRowForCoefficient[(count(*) = 3 and *[1][self::m:mn and .=1] and *[2]='\u2062')])" |
247 | 255 | - Prefix: "''" |
248 | 256 | - Word: "''" |
249 | 257 | replace: |
|
0 commit comments