Code Monkey home page Code Monkey logo

markdown's Introduction

MarkDown

Android平台的原生Markdown解析器,已整合进 RichText

  • 由markdown文本直接转换为Spanned,快捷高效
  • 不依赖特定控件,低侵入性
  • 遵循 Github Flavored Markdown 标准

效果展示

效果图

使用

Markdown.fromMarkdown(text,imageGetter,textView);

注意: 此方法需要在textView的Measure完成后调用,因为需要获取textView的宽高

例子:

textView.post(new Runnable() {
     @Override
     public void run() {
     Spanned spanned = MarkDown.fromMarkdown(stream, new Html.ImageGetter() {
           @Override
           public Drawable getDrawable(String source) {
                 Drawable drawable = getResources().getDrawable(R.mipmap.ic_launcher);
                 drawable.setBounds(0, 0, 400, 400);
                 return drawable;
           }
     }, textView);
     textView.setText(spanned);
}

在RichText中使用

RichText 包含了一些对图片和其它东西的处理,使用更简单

RichText.fromMarkdown(markdown).into(textView);

Use in Gradle

compile 'com.zzhoujay.markdown:markdown:0.0.4'

已知问题

  • 引用块内不支持Setext-style的标题(后续会想办法修复 (已修复)
  • 暂不支持使用反斜杠 \ 转义
  • 不支持表格

后续计划

  • 修复一些已知问题

by zzhoujay

markdown's People

Contributors

zzhoujay avatar

Watchers

James Cloos avatar Top John avatar  avatar

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.