mathPres package
Framework for presentation of math. Three types of presentation are supported: speech, braille and interaction. All of these accept MathML markup. Plugins can register their own implementation for any or all of these using L{registerProvider}.
- class mathPres.MathPresentationProvider
Bases:
object
Implements presentation of math content. A single provider does not need to implement all presentation types.
- getSpeechForMathMl(mathMl: str) List[str | SpeechCommand]
Get speech output for specified MathML markup. @param mathMl: The MathML markup. @return: A speech sequence.
- getBrailleForMathMl(mathMl: str) str
Get braille output for specified MathML markup. @param mathMl: The MathML markup. @return: A string of Unicode braille.
- interactWithMathMl(mathMl: str) None
Begin interaction with specified MathML markup. @param mathMl: The MathML markup.
- mathPres.registerProvider(provider: MathPresentationProvider, speech: bool = False, braille: bool = False, interaction: bool = False)
Register a math presentation provider. @param provider: The provider to register. @param speech: Whether this provider supports speech output. @param braille: Whether this provider supports braille output. @param interaction: Whether this provider supports interaction.
- mathPres.initialize() None
- class mathPres.MathInteractionNVDAObject(chooseBestAPI=True, **kwargs)
Bases:
Window
Base class for a fake NVDAObject which can be focused while interacting with math. Subclasses can bind commands to interact with the content and produce speech and braille output as they wish. To begin interaction, call L{setFocus}. Pressing escape exits interaction.
- role: controlTypes.Role = 104
Type definition for auto prop ‘_get_role’
- name: str = None
Type definition for auto prop ‘_get_name’
- treeInterceptor: Optional[TreeInterceptor] = None
Type definition for auto prop ‘_get_treeInterceptor’
- setFocus()
Tries to force this object to take the focus.
- script_exit(gesture)
Exit math interaction
- __gestures = {'kb:escape': 'exit'}
- _abc_impl = <_abc._abc_data object>
- mathPres.stripExtraneousXml(xml)
Strip extraneous XML from MathML. This is needed where retrieving MathML produces more than just the math tag. Currently, this strips anything before the opening of the math tag.
- mathPres.getMathMlFromTextInfo(pos: TextInfo) str | None
Get MathML (if any) at the start of a TextInfo. @param pos: The TextInfo in question. @return: The MathML or C{None} if there is no math.
- mathPres.interactWithMathMl(mathMl: str) None
Begin interaction with specified MathML markup, reporting any errors to the user. This is intended to be called from scripts. If interaction isn’t supported, this will be reported to the user. The script should return after calling this function. @param mathMl: The MathML markup.
- mathPres.getLanguageFromMath(mathMl)
Get the language specified in a math tag. @return: The language or C{None} if unspeicifed. @rtype: str
- mathPres.insertLanguageIntoMath(mathMl, language)
Insert the specified language into a math tag.
Submodules
mathPres.mathPlayer module
Support for math presentation using MathPlayer 4.
- mathPres.mathPlayer._processMpSpeech(text, language)
- class mathPres.mathPlayer.MathPlayerInteraction(chooseBestAPI=True, **kwargs)
Bases:
MathInteractionNVDAObject
- reportFocus()
Announces this object in a way suitable such that it gained focus.
- getScript(gesture)
Retrieve the script bound to a given gesture. @param gesture: The input gesture in question. @type gesture: L{inputCore.InputGesture} @return: The script function or C{None} if none was found. @rtype: script function
- _abc_impl = <_abc._abc_data object>
- class mathPres.mathPlayer.MathPlayer
Bases:
MathPresentationProvider
- _setSpeechLanguage(mathMl)
- getSpeechForMathMl(mathMl)
Get speech output for specified MathML markup. @param mathMl: The MathML markup. @return: A speech sequence.
- getBrailleForMathMl(mathMl)
Get braille output for specified MathML markup. @param mathMl: The MathML markup. @return: A string of Unicode braille.
- interactWithMathMl(mathMl)
Begin interaction with specified MathML markup. @param mathMl: The MathML markup.