From 286fbae40348adf59159b32672a5cf39cfcf736b Mon Sep 17 00:00:00 2001 From: Dimitry Ivanov Date: Fri, 16 Feb 2018 18:14:50 +0300 Subject: [PATCH] Added README to module --- sample-custom-extension/README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 sample-custom-extension/README.md diff --git a/sample-custom-extension/README.md b/sample-custom-extension/README.md new file mode 100644 index 00000000..194557ab --- /dev/null +++ b/sample-custom-extension/README.md @@ -0,0 +1,26 @@ +# 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_. + +```markdown +# 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](https://github.com/atlassian/commonmark-java) library that Markwon uses underneath. There is an ongoing [issue](https://github.com/atlassian/commonmark-java/issues/113) 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