ifyun / markdown-it-android

Android Markdown View

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

markdown-it-android

License JitPack

Markdown View for Android, based on markdown-it and WebView.

Preview

Features

Usage

Setup

Add it in your root build.gradle at the end of repositories(for older gradle version):

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

Or add following to settings.gradle(for newer gradle version):

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

Add the dependency:

dependencies {
	implementation 'com.github.imcloudfloating:markdown-it-android:1.0.4'
}

Use in project

Required SDK Version >= 22.

Data Binding:

<com.github.imcloudfloating.markdown.MarkdownIt
    android:id="@+id/markdown_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:markdownString="@{viewModel.content}" />

No Data Binding:

val md = "# Hello, Markdown!"

findViewById<MarkdownIt>(R.id.markdown_view).markdownString = md

If the HTTP image link cannot be displayed, add android:usesCleartextTraffic="true" to AndroidManifest.xml of your project.

Fields and methods

Field/Method Note
fitSystemTheme Default is true, auto fit system theme.
darkTheme Use dark theme when fitSystemTheme = false
markdownString The markdown content you want to show.
urlClickListener Click listener for link.

About

Android Markdown View

License:MIT License


Languages

Language:JavaScript 44.8%Language:Kotlin 39.3%Language:CSS 12.1%Language:HTML 3.9%