MathKeyboardEngine for Swift provides the logic for a highly customizable virtual math keyboard. It is intended for use together with any LaTeX typesetting library (for example KaTeX or MathJax in a WebView).
Also available:
insert(someMatrixNode)
or moveUp()
, deleteLeft()
, etc.getEditModeLatex()
outputs the total of LaTeX you typed, for example \frac{3}{4}\blacksquare
(if \blacksquare
is your cursor), which you then feed to KaTeX or MathJax for display.getViewModeLatex()
outputs the LaTeX without a cursor.Live (JavaScript) examples can be tested at mathkeyboardengine.github.io.
Unique about MathKeyboardEngine:
StandardLeafNode
, StandardBranchingNode
, AscendingBranchingNode
and DescendingBranchingNode
can be used for almost all LaTeX, including fractions, powers, combinations, subscript, etc. with ready-to-use up/down/left/right navigation.A con:
More pros:
To use the MathKeyboardEngine
library in a SwiftPM project,
add it to the dependencies for your package and - for example - your command-line executable target:
// swift-tools-version: 5.7
import PackageDescription
let package = Package(
name: "MyExecutable",
dependencies: [
.package(url: "https://github.com/MathKeyboardEngine/MathKeyboardEngine.Swift", from: "0.1.0"),
],
targets: [
.executableTarget(
name: "MyExecutable",
dependencies: [
.product(name: "MathKeyboardEngine", package: "MathKeyboardEngine.Swift"),
]),
// ...
]
)
Then add
import MathKeyboardEngine
and
let k = KeyboardMemory()
let latexConfiguration = LatexConfiguration()
// Subscribe to onclick events of virtual key presses, etc.
Note: the use of Swift.fatalError
can be very helpful - especially during development and maybe even in production - for fixing wrong implementation of this libary. However, if you want MathKeyboardEngine not to use Swift.fatalError
, then use the following line at startup of your app:
MathKeyboardEngineError.shouldBeFatal = false
Visit the documentation and the (latest version of the)* Examples folder for more implementation details.
* If you use a version tag in the url like this: https://github.com/MathKeyboardEngine/MathKeyboardEngine.Swift/tree/0.1.0-alpha.2, you can see the git repository as it was for that version. That may not be needed if the changelog doesn't note any important changes.
Follow these steps to set up (and verify) a development environment for this repository on Windows:
swift test
.Note: checking code coverage and testing for macOS and Linux is done via GitHub Actions - see .github/workflows.
The MathKeyboardEngine repositories use the most permissive licensing available. The "BSD Zero Clause License" (0BSD) allows for
commercial + non-commercial use, closed + open source, with + without modifications, etc. and is equivalent to licenses like:
The "BSD Zero Clause License" (0BSD) does not have the condition
(...), provided that the above copyright notice and this permission notice appear in all copies.
which is part of the "MIT License" (MIT) and its shorter equivalent "ISC License" (ISC). Apart from that they are all equivalent.
link |
Stars: 2 |
Last commit: 3 weeks ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics