* Returns a string with the correct number of nesting chars (could be an empty string) * @param(node) -- current node * @param(char) -- char (string) that should be repeated * Note: as a side effect, an attribute with the value so repeated calls to this or a child will be fast */
(&self,
_context: &context::Evaluation<'_, 'd>,
args: Vec<Value<'d>>)
| 1657 | * Note: as a side effect, an attribute with the value so repeated calls to this or a child will be fast |
| 1658 | */ |
| 1659 | fn evaluate<'d>(&self, |
| 1660 | _context: &context::Evaluation<'_, 'd>, |
| 1661 | args: Vec<Value<'d>>) |
| 1662 | -> StdResult<Value<'d>, XPathError> |
| 1663 | { |
| 1664 | let mut args = Args(args); |
| 1665 | args.exactly(2)?; |
| 1666 | let repeat_char = args.pop_string()?; |
| 1667 | let node = crate::xpath_functions::validate_one_node(args.pop_nodeset()?, "NestingChars")?; |
| 1668 | if let Node::Element(el) = node { |
| 1669 | let name = name(&el); |
| 1670 | // it is likely a bug to call this one a non mfrac |
| 1671 | if name == "mfrac" { |
| 1672 | // because it is called on itself, the fraction is counted one too many times -- chop one off |
| 1673 | // this is slightly messy because we are chopping off a char, not a byte |
| 1674 | const BRAILLE_BYTE_LEN: usize = "⠹".len(); // all Unicode braille symbols have the same number of bytes |
| 1675 | return Ok( Value::String( NemethNestingChars::nemeth_frac_value(&el, &repeat_char)[BRAILLE_BYTE_LEN..].to_string() ) ); |
| 1676 | } else if name == "msqrt" || name == "mroot" { |
| 1677 | return Ok( Value::String( NemethNestingChars::nemeth_root_value(&el, &repeat_char)? ) ); |
| 1678 | } else { |
| 1679 | panic!("NestingChars chars should be used only on 'mfrac'. '{}' was passed in", name); |
| 1680 | } |
| 1681 | } else { |
| 1682 | // not an element, so nothing to do |
| 1683 | return Ok( Value::String("".to_string()) ); |
| 1684 | } |
| 1685 | } |
| 1686 | } |
| 1687 | |
| 1688 | pub struct BrailleChars; |
nothing calls this directly
no test coverage detected