KotliTeX is KaTeX's Android port, written in Kotlin.
This library provides
We believe that keeping the original structure makes future updates easier.
How to port new function
We basically have two part in our library. Expression tree building and rendering it.
Expression tree building is essentially the porting of KaTeX, while rendering is similar to canavs-latex (though this is sometime not the direct porting because of difference between HTML5 canvas and Android).
- Add functions/FunctionXXX.kt, which is port of KaTeX/src/functions/XX.js and call defineAll() from Parser.kt (Expression tree part)
- Add rendering logic under renderer/ someway
mathcal PR is typical and good starting point for investigate.
./gradlew format format all .kt files with ktlint.
Current status (2019/04/09)
MathExpression Span now render inside TextView.
We provide MarkdownView class, which parse math expression of jekyll style asynchronously. (Though other markup is not yet supported).
- Sum, Prod
Include kotlitex to other project
- Make kotlitex-kotlitex of release flavor to create kotlitex-release.aar and place to your project as kotlitex.aar
- Import kotlitex.aar as official document says. https://developer.android.com/studio/projects/android-library
- Add build.gralde as following (We use kotlin version 1.3.20)
// kotlitex implementation project(":kotlitex") implementation 'com.android.support:appcompat-v7:28.0.0' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1' implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1"
io.github.karino2.kotlitex.view.MarkdownView and call setMarkdown(text) to render math expression.
MainActivity.kt under sample directory show basic usage.
kotlitex itself is under MIT license. Also, our library contains other libraries.