Giter Site home page Giter Site logo

billthefarmer / markdownview Goto Github PK

View Code? Open in Web Editor NEW
12.0 3.0 2.0 434 KB

Android markdown view forked from https://github.com/falnatsheh/MarkdownView

License: Apache License 2.0

Java 99.58% CSS 0.26% JavaScript 0.16%
markdownview android-markdown

markdownview's Introduction

Logo MarkdownView .github/workflows/build.yml

Android markdown view forked from https://github.com/falnatsheh/MarkdownView

Markdown

About

MarkdownView is an Android library that helps you display Markdown text or files (local/remote) as formatted HTML, and style the output using CSS.

The MarkdownView itself extends Android WebView and adds the necessary logic to parse Markdown (using Commonmark) and display the output HTML on the view.

Getting started

To add MarkdownView to your project, add the following to the build.gradle file:

allprojects {
    repositories {
        jcenter()
        google()
        maven { url "https://jitpack.io" }
    }
}

dependencies {
    implementation 'com.github.billthefarmer:MarkdownView:v1.09'
}

Usage

Add MarkdownView to your layout:

  <org.billthefarmer.markdown.MarkdownView
    android:id="@+id/markdown"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

and reference it in your Activity/Fragment:

MarkdownView markdownView = (MarkdownView) findViewById(R.id.markdown);
markdownView.loadMarkdown("## Hello Markdown");

You could also create the view by code. Below an example of how to set the whole activity to be a MarkdownView by adding the following to your onCreate method:

  MarkdownView markdownView = new MarkdownView(this);
  setContentView(markdownView);
  markdownView.loadMarkdown("## Hello Markdown");

To load markdown from the app assets folder, including styles, javascript and base url:

  markdownView.loadMarkdownFile("file:///android_assets/",
                                "file:///android_assets/markdown.md",
                                "file:///android_assets/styles.css",
                                "file:///android_assets/javascript.js");

API

  MarkdownView(Context context)
  MarkdownView(Context context, AttributeSet attrs)

Parameters

  • context - Context
  • attrs - AttributeSet
  void loadMarkdown(String text)
  void loadMarkdown(String text, String cssFileUrl)
  void loadMarkdown(String baseUrl, String text, String cssFileUrl)
  void loadMarkdown(String baseUrl, String text, String cssFileUrl, String jsFileUrl)

Parameters

  • text - markdown text
  • cssFileUrl - url of styles css file
  • baseUrl - base url to allow loading of images
  void loadMarkdownFile(String url)
  void loadMarkdownFile(String url, String cssFileUrl)
  void loadMarkdownFile(String baseUrl, String url, String cssFileUrl)
  void loadMarkdownFile(String baseUrl, String url, String cssFileUrl, String jsFileUrl)

Parameters

  • url - url of markdown text
  • cssFileUrl - url of styles css file
  • jsFileUrl - url of javascript file
  • baseUrl - base url to allow loading of images

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.