Skip to content

kniost/EnhancedHtml

Repository files navigation

Enhanced Html

Enhanced library for Android's Html class. Reference to library HtmlCompat.

中文版

What's supported

1. Enhance from origin Html Library

All the latest functionality from the current Html for Android Nougat is included in this library. While this may continue to be improved in the future, currently, the following tags are supported out of the box:

  • <br> <p> <ul> <li> <div> <span> <img>
  • <strong> <b> <em> <i> <u> <s> <strike> <del>
  • <cite> <dfn> <big> <small> <font> <blockquote> <tt>
  • <a> <sup> <sub>
  • <h1> <h2> <h3> <h4> <h5> <h6>

The following CSS inline styles are supported:

  • text-align (left, right, center, start, end)
  • color width height
  • background, background-color
  • text-decoration(line-through, underline)

All CSS color declarations as defined here are supported.

2. Excellent LaTeX formula support

This library support LaTeX formula like this:

<span class="mathquill-embedded-latex" style="width: 170px; height: 50px;">x=\frac{-b\pm\sqrt[2]{b^2-4ac}}{2a}</span>

which can be generated by the UEditor or other editor like this.

It uses JLaTeXMath to support LaTeX.

Features are going to be added if there are needs.

Add to your project

Add it in your root build.gradle at the end of repositories:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Step 2. Add the dependency in your module's build.gradle

dependencies {
        compile 'com.github.kniost:EnhancedHtml:[VERSION_HERE]'
}

The newest version :

Usage

If you need to use LaTeX, you have initialize JLaTeXMath for LaTeX rendering by command:

AjLatexMath.init(context); // init library: load fonts, create paint, etc.

A sample usage:

Spanned spannableString = EnhancedHtml.fromHtml(mContext, 
                TEST_STRING, 
                0, 
                CustomImageGetter, 
                CustomTagHandler);
mTestTv.setText(spannableString);

About

Enhanced version of Android's Html library

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages