{"id":13644420,"url":"https://github.com/fourlastor/dante","last_synced_at":"2025-04-06T06:09:03.345Z","repository":{"id":70645720,"uuid":"82223494","full_name":"fourlastor/dante","owner":"fourlastor","description":"A sane rich text parsing and styling library.","archived":false,"fork":false,"pushed_at":"2021-10-24T11:41:53.000Z","size":2159,"stargazers_count":455,"open_issues_count":1,"forks_count":32,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-30T04:09:20.667Z","etag":null,"topics":["android","html","parser-library","rich-text","spannable"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fourlastor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-02-16T20:33:35.000Z","updated_at":"2024-12-10T11:33:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"875328c1-0234-440c-a48a-bf6c4341db4b","html_url":"https://github.com/fourlastor/dante","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fourlastor%2Fdante","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fourlastor%2Fdante/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fourlastor%2Fdante/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fourlastor%2Fdante/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fourlastor","download_url":"https://codeload.github.com/fourlastor/dante/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247441052,"owners_count":20939239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","html","parser-library","rich-text","spannable"],"created_at":"2024-08-02T01:02:03.690Z","updated_at":"2025-04-06T06:09:03.329Z","avatar_url":"https://github.com/fourlastor.png","language":"Java","readme":"# Dante\n\nDante 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).\n\nOriginally I authored Dante in [Pause](http://pause.fm), the project is now dead and I decided to open source it.\n\nThis is the very first release of Dante, the api will (most likely) change for the better with successive iterations.\n\n\u003cimg src=\"images/screencast.gif\" width=\"300\" /\u003e\n\n## Installation\n\nSimply add the following to your `build.gradle`:\n\n```\nrepositories {\n  jcenter()\n}\n\ndependencies {\n  compile 'com.fourlastor:dante:1.0.1'\n}\n```\n\n## Usage with HTML\n\n```java\nFlavoredHtml flavoredHtml = new FlavoredHtml.Builder(context)\n  .newLine(\"p\", \"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\", \"li\")\n  .textAppearance(R.style.headline, \"h1\")\n  .textAppearance(R.style.title, \"h2\")\n  .textAppearance(R.style.subhead, \"h3\")\n  .textAppearance(R.style.body, \"p\", \"li\")\n  .style(Typeface.BOLD, \"b\", \"strong\")\n  .style(Typeface.ITALIC, \"i\", \"em\")\n  .bullet(15, \"li\")\n  .build();\n\nSpanned styledHtml = flavoredHtml.parse(htmlString);\n```\n\nKeep 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.\n\n## Loading images\n\nYou'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`:\n\n```java\nFlavoredHtml flavoredHtml = new FlavoredHtml.Builder(context)\n  .img(new ImgListener.BitmapImgGetter(getResources()) {\n                      @Override\n                      protected Bitmap getBitmap(String src) {\n                          try {\n                              return Picasso.with(MainActivity.this)\n                                      .load(src)\n                                      .get();\n                          } catch (IOException e) {\n                              throw new RuntimeException(\"Whoops!\");\n                          }\n                      }\n                  });\n```\n\nKeep 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.\n\n## Different input types\n\nAs long as you implement `Parser`, it shouldn't be hard to support a different text style, see `HtmlParser`'s implementation as a reference.\n\n\n","funding_links":[],"categories":["TextView"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffourlastor%2Fdante","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffourlastor%2Fdante","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffourlastor%2Fdante/lists"}