Markwon/sample-custom-extension
Dimitry e0563dca43
V2.0.0 (#66)
* Add `html-parser-api` and `html-parser-impl` modules
* Add `HtmlEmptyTagReplacement`
* Implement Appendable and CharSequence in SpannableBuilder
* Renamed library modules to reflect maven artifact names
* Rename `markwon-syntax` to `markwon-syntax-highlight`
* Add HtmlRenderer asbtraction
* Add CssInlineStyleParser
* Fix Theme#listItemColor and OL
* Fix task list block parser to revert parsing state when line is not matching
* Defined test format files
* image-loader add datauri parser
* image-loader add support for inline data uri image references
* Add travis configuration
* Fix image with width greater than canvas scaled
* Fix blockquote span
* Dealing with white spaces at the end of a document
* image-loader add SchemeHandler abstraction
* Add sample-latex-math module
2018-09-17 13:15:58 +03:00
..
2018-07-30 15:19:42 +02:00
2018-09-17 13:15:58 +03:00
2018-02-16 18:19:38 +03:00

Custom extension

This module provides a simple implementation for icons that are bundled in your application resources using custom DelimiterProcessor. It can be used as a reference when dealing with new functionality based on delimiters.

# Hello @ic-android-black-24

**Please** click @ic-home-green-24 (home icon) if you want to go home.

Here we will substitute elements starting with @ic- for icons that we have in our resources:

  • @ic-android-black-24 -> R.drawable.ic_android_black_24dp
  • @ic-home-green-24 -> R.drawable.ic_home_green_24dp

In order to provide reliable parsing we need to have delimiters around desired content. So, @ic-home-green-24 would become @ic-home-green-24@. This is current limitation of commonmark-java library that Markwon uses underneath. There is an ongoing issue that might change this in future thought.

But as we known the pattern beforehand it's pretty easy to pre-process raw markdown and make it the way we want it. Please refer to IconProcessor#process method for the reference.

So, the our steps would be:

  • prepare raw markdown (wrap icons with @ if it's not already)
  • construct a Parser with our registered delimiter processor
  • parse markdown and obtain a Node
  • create a node visitor that will additionally visit custom node (IconNode)
  • use markdown