GithubHelp home page GithubHelp logo

sidvenu / mathjaxview Goto Github PK

View Code? Open in Web Editor NEW
21.0 4.0 9.0 2.16 MB

A library to render MathJax offline in Android devices

License: Other

Java 100.00%
mathjax mathjax-support android-library android-ui

mathjaxview's Introduction

MathJaxView

API Download

MathJaxView is a custom view extending WebView and offers offline support for MathJax for Android Apps.

Setup

You can add MathJaxView to your Android Studio project in two ways:

  1. Using a remote Maven repository (jCenter)
  2. Using AAR file downloaded from bintray

1. Setup from a remote Maven repository (jcenter)

Add implementation 'io.github.sidvenu.mathjaxview:mathjaxview:1.0.7' into dependencies section of your module build.gradle file.

2. Setup from local .aar file

You can download the latest version of MathView from Bintray.

  1. Import the module from local .aar file

Click File - New - New Module (yes, not Import Module) -> Import .JAR/.AAR Package, and find out where the file located.

  1. Add dependency

Click File -> Project Structure -> Dependencies, and then click the plus icon, select 3. Module Dependency.

Usage

The usage of MathJaxView is similar to that of TextView. Refer to the sample app (MathJaxTest) for usage.

MathJax configuration

The default config is set to use single dollar symbols ($) for inline formula and double dollar symbols ($$) for displayed formula. You can use the view.setConfig(String) method to change the configuration to anything of your choice. The default config is set as follows:

config = "MathJax.Hub.Config({" +
                "    extensions: ['fast-preview.js']," +
                "    messageStyle: 'none'," +
                "    \"fast-preview\": {" +
                "      disabled: false" +
                "    }," +
                "    CommonHTML: {" +
                "      linebreaks: { automatic: true, width: \"container\" }" +
                "    }," +
                "    tex2jax: {" +
                "      inlineMath: [ ['$','$'] ]," +
                "      displayMath: [ ['$$','$$'] ]," +
                "      processEscapes: true" +
                "    }," +
                "    TeX: {" +
                "      extensions: [\"file:///android_asset/MathJax/extensions/TeX/mhchem.js\"]," +
                "      mhchem: {legacy: false}"+
                "    }" +
                "});";
Asset management

Make sure you add the extra MathJax assets that accompanies the change in config to your app (other than the one provided by the library).

You can do this by creating a MathJax folder in your assets folder that has the extra MathJax assets. The path to MathJax that you can use in your config can be: file:///android_asset/MathJax/extensions/TeX/mhchem.js.

Thanks

Sincere thanks to jianzhongli for their MathView project that served as an inspiration for this project.

How is it different from MathView?

  1. It features the latest MathJax version (v2.7.5).
  2. It does not have KaTeX, reducing the size of library. If you want KaTeX,there is a separate library for that: KaTeXView.
  3. Supports API level 15, targeting 100% of the Android devices as per documentation.
  4. Very small size - 1.36MB that was stripped down from 67.59MB of MathJax assets.

Documentation

The code of MathJaxView (a single small file) is well documented and anyone can easily understand it. Please view the code and try to understand it yourself. If you don't, please raise a issue with the help wanted label. Furthermore, I've created a module that tests out the features of this library, called mathjaxtest. You can check it out for the library usage.

Issues

Please report any issues that you encountered, not limited to performance improvements and updating the MathJax assets.

Pull Requests

PRs are an all-time welcome provided you follow the coding style similar to that already existing in the project.

License

This software is licensed under the Apache License, Version 2.0. Refer the license for more details.

mathjaxview's People

Contributors

sidvenu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mathjaxview's Issues

Extra padding at bottom of WebView

I have the MathJaxView inside a LinearLayout, which is inside a NestedScrollView.
When the MathJaxView is large enough that I need to scroll to get to the bottom of it, there is extra padding at the bottom. There seems to be the correct amount of padding everywhere else, though.

Could you look into this? I suspect it has to do with your mathjax config -- this issue isn't present in kexanies mathview.

v3

Hey, please update to the latest Mathjax Version and possibly kotlin? :)

Error java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android.util.AttributeSet]

It seemed like some constructor not defined according to stackoverflow but I cant fix it myself.
I'm using it in kotlin environment if its matter.

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ff.mathview/com.ff.mathview.MainActivity}: android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class io.github.sidvenu.mathjaxview.MathJaxView at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) Caused by: android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class io.github.sidvenu.mathjaxview.MathJaxView Caused by: android.view.InflateException: Binary XML file line #20: Error inflating class io.github.sidvenu.mathjaxview.MathJaxView Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android.util.AttributeSet] at java.lang.Class.getConstructor0(Class.java:2327) at java.lang.Class.getConstructor(Class.java:1725) at android.view.LayoutInflater.createView(LayoutInflater.java:615) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) at android.view.LayoutInflater.rInflate(LayoutInflater.java:863) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at android.view.LayoutInflater.inflate(LayoutInflater.java:374) at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) at com.ff.mathview.MainActivity.onCreate(MainActivity.kt:17) at android.app.Activity.performCreate(Activity.java:7136) at android.app.Activity.performCreate(Activity.java:7127) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Add support for android:text

The current version of the library (1.0.4) does not support adding text to MathJaxView through XML. This lack of the feature will be addressed in 1.0.5

setup with remote Maven repository

hey
first of all thanks for you great work.
i have tried to set up you project using maven repository and the files has been downloaded / synced successfully but i couldn't import the project into my java files or see the tags in my xml files any tips about how i could fix that
thanks in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.