Module interface

Source
Expand description

The interface module provides functionality both for calling from an API and also running the code from main.

Constants§

MATHML_INSTANCE
The current node being navigated (also spoken and brailled) is stored in MATHML_INSTANCE.

Functions§

copy_mathml
Copy (recursively) the (MathML) element and return the new one. The Element type does not copy and modifying the structure of an element’s child will modify the element, so we need a copy Convert the returned error from set_mathml, etc., to a useful string for display
do_navigate_command
Given a navigation command, the current node is moved accordingly. This is a higher level interface than do_navigate_keypress for applications that want to interpret the keys themselves. The valid commands are:
do_navigate_keypress
Given a key code along with the modifier keys, the current node is moved accordingly (or value reported in some cases). key is the keycode for the key (in JavaScript, ev.key_code) The spoken text for the new current node is returned.
errors_to_string
get_braille
Get the braille associated with the MathML that was set by set_mathml. The braille returned depends upon the preference for the code preference (default Nemeth). If ‘nav_node_id’ is given, it is highlighted based on the value of BrailleNavHighlight (default: EndPoints)
get_braille_position
Return the start and end braille character positions associated with the current (navigation) node.
get_element
get_intent
Get the intent after setting the MathML Used in testing
get_navigation_braille
Get the braille associated with the current navigation focus of the MathML that was set by set_mathml. The braille returned depends upon the preference for the code preference (default Nemeth). The returned braille is brailled as if the current navigation focus is the entire expression to be brailled.
get_navigation_mathml
Return the MathML associated with the current (navigation) node and the offset (0-based) from that mathml (not yet implemented) The offset is needed for token elements that have multiple characters.
get_navigation_mathml_id
Return the id and offset (0-based) associated with the current (navigation) node. offset (not yet implemented) The offset is needed for token elements that have multiple characters.
get_navigation_node_from_braille_position
Given a 0-based braille position, return the smallest MathML node enclosing it. This node might be a leaf with an offset.
get_overview_text
Get the spoken text for an overview of the MathML that was set. The speech takes into account any AT or user preferences. Note: this implementation for is currently minimal and should not be used.
get_preference
Get the value of the named preference. None is returned if name is not a known preference.
get_spoken_text
Get the spoken text of the MathML that was set. The speech takes into account any AT or user preferences.
get_supported_braille_codes
get_supported_languages
get_supported_speech_styles
get_version
Returns the version number (from Cargo.toml) of the build
is_same_element
returns Ok() if two Documents are equal or some info where they differ in the Err
set_mathml
This will override any previous MathML that was set. This returns canonical MathML with ’id’s set on any node that doesn’t have an id. The ids can be used for sync highlighting if the Bookmark API preference is true.
set_navigation_node
Given an ‘id’ and an offset (for tokens), set the navigation node to that id. An error is returned if the ‘id’ doesn’t exist
set_preference
Set a MathCAT preference. The preference name should be a known preference name. The value should either be a string or a number (depending upon the preference being set) The list of known user preferences is in the MathCAT user documentation. Here are common preferences set by programs (not settable by the user):
set_rules_dir
Set the Rules directory IMPORTANT: this should be the very first call to MathCAT. If ‘dir’ is an empty string, the environment var ‘MathCATRulesDir’ is tried.
trim_element
Not really meant to be public – used by tests in some packages