MIT License

项目介绍

fourlastor/dante 是一个托管在 GitHub 上的开源项目,主要使用 Java 编写,采用 MIT License 许可证,目前获得 456 个 Star、30 次 Fork。

仓库全名
fourlastor/dante
开源许可证
MIT License
Star 数
456
Fork 数
30
未关闭 Issue
1

README 摘要

Dante Dante is a text parser to easily generate a Spannable from a raw input, right now it supports only HTML but the idea is to be able to support multiple input types (e.g., MarkDown). Originally I authored Dante in Pause, the project is now dead and I decided to open source it. This is the very first release of Dante, the api will (most likely) change for the better with successive iterations. Installation Simply…

完整内容见 GitHub 原始 README 或本页 。

常见问题

dante 用什么语言开发?

主要使用 Java 编写,采用 MIT License 许可证,目前有 456 个 Star。

dante 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 dante 的源码?

可以直接克隆仓库:git clone https://github.com/fourlastor/dante.git,默认分支为 master;安装与运行步骤见仓库 README。

dante 最近还在维护吗?

仓库最近一次更新为 2021年10月24日,当前有 1 个未关闭 Issue;Star 数为 456,可作为社区活跃度的参考。

关于

A sane rich text parsing and styling library.

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
528
价值分
283
活跃状态
活跃

语言占比

Java

Release

README

Dante

Dante is a text parser to easily generate a Spannable from a raw input, right now it supports only HTML but the idea is to be able to support multiple input types (e.g., MarkDown).

Originally I authored Dante in Pause, the project is now dead and I decided to open source it.

This is the very first release of Dante, the api will (most likely) change for the better with successive iterations.

Installation

Simply add the following to your build.gradle:

repositories {
  jcenter()
}

dependencies {
  compile 'com.fourlastor:dante:1.0.1'
}

Usage with HTML

FlavoredHtml flavoredHtml = new FlavoredHtml.Builder(context)
  .newLine("p", "h1", "h2", "h3", "h4", "h5", "h6", "li")
  .textAppearance(R.style.headline, "h1")
  .textAppearance(R.style.title, "h2")
  .textAppearance(R.style.subhead, "h3")
  .textAppearance(R.style.body, "p", "li")
  .style(Typeface.BOLD, "b", "strong")
  .style(Typeface.ITALIC, "i", "em")
  .bullet(15, "li")
  .build();

Spanned styledHtml = flavoredHtml.parse(htmlString);

Keep in mind that this will be executed on the same thread on which flavoredHtml.parse() is executed. Since loading images might entail executing network requests, make sure you invoke flavoredHtml.parse() outside of the main thread if you are also loading images.

Loading images

You’ll have to implement either ImgLoader to load images, if you need to load bitmaps (e.g., from the network) you can use ImgLoader.BitmapLoader:

FlavoredHtml flavoredHtml = new FlavoredHtml.Builder(context)
  .img(new ImgListener.BitmapImgGetter(getResources()) {
                      @Override
                      protected Bitmap getBitmap(String src) {
                          try {
                              return Picasso.with(MainActivity.this)
                                      .load(src)
                                      .get();
                          } catch (IOException e) {
                              throw new RuntimeException("Whoops!");
                          }
                      }
                  });

Keep in mind that this will be executed in the same thread in which flavoredHtml.parse() is executed, if you wish to execute network requests, do so invoking flavoredHtml.parse() outside of the main thread.

Different input types

As long as you implement Parser, it shouldn’t be hard to support a different text style, see HtmlParser’s implementation as a reference.

评论

暂无评论