MathKeyboardEngine provides the logic for a highly customizable virtual math keyboard. It is intended for use together with any LaTeX typesetting library.
Project description
MathKeyboardEngine for Python
MathKeyboardEngine for Python provides the logic for a highly customizable virtual math keyboard. It is intended for use together with any LaTeX typesetting library (for example matplotlib.mathtext).
Also available:
An execution timeline
todo. For now, see the JavaScript repo.
Let me test it now!
Live examples can be tested at MathKeyboardEngine.GitHub.io.
Pros and cons?
Unique about MathKeyboardEngine:
- it supports (almost?) all math mode LaTeX, including matrices. (Please share if you know anything that is not supported.)
- its syntax tree consists of very few different parts: the
StandardLeafNode
,StandardBranchingNode
,AscendingBranchingNode
andDescendingBranchingNode
can be used for almost all LaTeX, including fractions, powers, combinations, subscript, etc. with ready-to-use up/down/left/right navigation. - it can be used with any LaTeX math typesetting library you like.
A con:
- this library will never be able to handle setting the cursor with the touch of a finger on a typeset formula. (But it DOES support up/down/left/right navigation and has a selection mode via arrow keys.)
More pros:
- you have full control over what you display on the virtual keyboard keys and what a virtual key press actually does.
- customize the editor output at runtime: dot or comma as decimal separator, cross or dot for multiplication, cursor style, colors, etc.
- this library also supports handling input from a physical keyboard, where - for example - the forward slash "/" key can be programmed to result in encapsulating a previously typed number as the numerator of a fraction. (See the examples.)
- almost forgotten: it's open source, free to use, free to modify (please fork this repo)!
How to use this library
This library has been distributed via PyPi.
For installing a specific version of mathkeyboardengine - for example 0.1.0-alpha.12
- run the following command in the VS Code
Terminal:
py -m pip install mathkeyboardengine==0.1.0a12
Then create a new folder 'MathKeyboardEngineTest' and open it in VS Code
. Add a file main.py
with the following content:
from mathkeyboardengine import *
k = KeyboardMemory()
latexconfiguration = LatexConfiguration()
insert(k, DigitNode('2'))
insert_with_encapsulate_current(k, AscendingBranchingNode('', '^{', '}'))
insert(k, StandardLeafNode('x'))
print(get_edit_mode_latex(k, latexconfiguration))
Press the play button in the upper-right corner of VS Code
. The result that is displayed in the Terminal:
2^{x\blacksquare}
Documentation
todo. For now, see the JavaScript repo.
How to use this repo
Follow these steps to set up (and verify) a development environment for this repository:
- Install the latest version of Python via https://www.python.org/downloads. The download includes
pip
. - Open the Terminal in VS Code and run
py -m pip install -U pytest
. - Run all tests via
py -m pytest tests/
. - See code coverage:
py -m pip install pytest-cov
py -m pytest tests/ --cov=src --cov-report term-missing
. - This repository has been developed in a folder structure that helps understanding it. The released package however has a "flat" structure, so that all imports can be done from a single namespace. This is done via _disthelper/flatpack.py (developed especially for this repository). Files from the src folder are recursively copied to a new folder 'mathkeyboardengine' and import statements are automatically updated. It also produces a new version of the tests folder. It is called in setup.py and noxfile.py.
- Run all tests for the flatpacked mathkeyboardengine for multiple versions of python :
py -m pip install --upgrade nox
py -m nox
(this usesnoxfile.py
from the root of the repository). - If you're interested the release steps, see
_disthelper/release_steps.txt
.
Ask or contribute
- ask questions about anything that is not clear or when you'd like help.
- share ideas or what you've made.
- report a bug.
- request an enhancement.
- open a pull request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for mathkeyboardengine-0.1.0a24.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a29fce242bb0d664c032adccc69c51ad3869741c8619954fe69426e54d99d46 |
|
MD5 | b9afb79cab5c3503264dc5b5e8289758 |
|
BLAKE2b-256 | d8bef0c60ab1920dce3d55740dcaaa88dc7decd7b2227c715d442063faffdac1 |
Hashes for mathkeyboardengine-0.1.0a24-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85377aee0380dc98334fbf4da6d10c319e8423e03bc931e81f2b9b49bcb961de |
|
MD5 | 3daf70bca69c3959a28ec25d67741fb7 |
|
BLAKE2b-256 | 5bd4871f7249514e6aa5a5e9cf399054d978629a4edcb0f68c3ad5a1e62299ba |