Skip to content
katex porting for kotlin.
Branch: master
Clone or download
karino2 Merge pull request #121 from karino2/bar
Implement bar working.
Latest commit cf06757 Apr 21, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea Update AndroidStudio. Apr 20, 2019
gradle/wrapper Update AndroidStudio. Apr 20, 2019
kotlitex Implement bar working. Apr 21, 2019
sample
.gitignore Update AndroidStudio. Apr 20, 2019
.travis.yml Add travis wait. Fix #100 Apr 4, 2019
LICENSE
README.md Fix english. Apr 9, 2019
build.gradle Update AndroidStudio. Apr 20, 2019
build.sh Use Build Matrix to run fast (unit) tests separately Mar 13, 2019
dumpresult.txt
gradle.properties
gradlew
gradlew.bat
screen_shot.jpg Add Font license description (#86). Update readme. Apr 9, 2019
settings.gradle

README.md

KotliTeX

Build Status

KotliTeX is KaTeX's Android port, written in Kotlin.

This library provides com.karino2.kotlitex.view.MathExpressionSpan and com.karino2.kotlitex.view.MarkdownView.

Porting Guidelines

Currently we are porting KaTeX 0.10.0 and canvas-latex (which doesn't have releases) mostly as is, while merging the 2 parts may be technically possible.

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).

  1. Add functions/FunctionXXX.kt, which is port of KaTeX/src/functions/XX.js and call defineAll() from Parser.kt (Expression tree part)
  2. Add rendering logic under renderer/ someway

mathcal PR is typical and good starting point for investigate.

Coding Style

Use ktlint. ./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).

Sccreen Shot

(Partially) supported

  • frac
  • sqrt
  • Sum, Prod
  • mathcal

Include kotlitex to other project

  1. Make kotlitex-kotlitex of release flavor to create kotlitex-release.aar and place to your project as kotlitex.aar
  2. Import kotlitex.aar as official document says. https://developer.android.com/studio/projects/android-library
  3. 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"

Then use io.github.karino2.kotlitex.view.MarkdownView and call setMarkdown(text) to render math expression. MainActivity.kt under sample directory show basic usage.

License

kotlitex itself is under MIT license. Also, our library contains other libraries.

  • This library contain KaTeX font, which is under MIT license.
  • Some data table and comment is from KaTeX, which is under MIT license.
  • For rendering part, though code is from scratch, logic is very similar to Canvas-Latex, which is under MIT license.
You can’t perform that action at this time.