Working on documentation
This commit is contained in:
parent
18fd56a97c
commit
8064070233
@ -41,6 +41,7 @@ module.exports = {
|
||||
'',
|
||||
{
|
||||
title: 'Core',
|
||||
collapsable: false,
|
||||
children: [
|
||||
'/docs/core/getting-started.md',
|
||||
'/docs/core/plugins.md',
|
||||
@ -60,19 +61,15 @@ module.exports = {
|
||||
'/docs/ext-tasklist/',
|
||||
{
|
||||
title: 'HTML',
|
||||
collapsable: false,
|
||||
children: [
|
||||
'/docs/html/',
|
||||
'/docs/html/custom-tag-handler.md'
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'Image',
|
||||
children: [
|
||||
'/docs/image/gif.md',
|
||||
'/docs/image/okhttp.md',
|
||||
'/docs/image/svg.md'
|
||||
]
|
||||
},
|
||||
'/docs/image/gif.md',
|
||||
'/docs/image/okhttp.md',
|
||||
'/docs/image/svg.md',
|
||||
'/docs/recycler/',
|
||||
'/docs/syntax-highlight/',
|
||||
'/docs/migration-2-3.md'
|
||||
|
@ -1,6 +1,19 @@
|
||||
# Changelog
|
||||
|
||||
# 2.0.0
|
||||
# 2.0.1
|
||||
* `SpannableMarkdownVisitor` Rename blockQuoteIndent to blockIndent
|
||||
* Fixed block new lines logic for block quote and paragraph (<GithubIssue id="82" />)
|
||||
* AsyncDrawable fix no dimensions bug (<GithubIssue id="81" />)
|
||||
* Update SpannableTheme to use Px instead of Dimension annotation
|
||||
* Allow TaskListSpan isDone mutation
|
||||
* Updated commonmark-java to 0.12.1
|
||||
* Add OrderedListItemSpan measure utility method (<GithubIssue id="78" />)
|
||||
* Add SpannableBuilder#getSpans method
|
||||
* Fix DataUri scheme handler in image-loader (<GithubIssue id="74" />)
|
||||
* Introduced a "copy" builder for SpannableThem <br>Thanks <GithubUser name="c-b-h" />
|
||||
|
||||
|
||||
## 2.0.0
|
||||
* Add `html-parser-api` and `html-parser-impl` modules
|
||||
* Add `HtmlEmptyTagReplacement`
|
||||
* Implement Appendable and CharSequence in SpannableBuilder
|
||||
|
@ -59,50 +59,7 @@ Toast.makeText(context, markdown, Toast.LENGTH_LONG).show();
|
||||
|
||||
## No magic one
|
||||
|
||||
So, what happens _internally_ when there is a `markwon#setMarkdown(TextView,String)` call?
|
||||
Please note that this is mere representaion of what happens underneath and a caller
|
||||
would likely never has to deal with these method calls directly. It still valuable
|
||||
to understand how things are working:
|
||||
|
||||
```java
|
||||
// `Markwon#create` implicitly uses CorePlugin
|
||||
final Markwon markwon = Markwon.builder(context)
|
||||
.usePlugin(CorePlugin.create())
|
||||
.build();
|
||||
|
||||
// each plugin will configure resulting Markwon instance
|
||||
// we will cover it in plugins section of documentation
|
||||
|
||||
// warning: pseudo-code
|
||||
|
||||
// 0. each plugin will be called to _pre-process_ raw input markdown
|
||||
rawInput = plugins.reduce(rawInput, (input, plugin) -> plugin.processMarkdown(input));
|
||||
|
||||
// 1. after input is processed it's being parsed to a Node
|
||||
node = parser.parse(rawInput);
|
||||
|
||||
// 2. each plugin will be able to inspect or manipulate resulting Node
|
||||
// before rendering
|
||||
plugins.forEach(plugin -> plugin.beforeRender(node));
|
||||
|
||||
// 3. node is being visited by a visitor
|
||||
node.accept(visitor);
|
||||
|
||||
// 4. each plugin will be called after node is being visited (aka rendered)
|
||||
plugins.forEach(plugin -> plugin.afterRender(node, visitor));
|
||||
|
||||
// 5. styled markdown ready at this point
|
||||
final Spanned markdown = visitor.markdown();
|
||||
|
||||
// 6. each plugin will be called before styled markdown is applied to a TextView
|
||||
plugins.forEach(plugin -> plugin.beforeSetText(textView, markdown));
|
||||
|
||||
// 7. markdown is applied to a TextView
|
||||
textView.setText(markdown);
|
||||
|
||||
// 8. each plugin will be called after markdown is applied to a TextView
|
||||
plugins.forEach(plugin -> plugin.afterSetText(textView));
|
||||
```
|
||||
|
||||
As you can see a `plugin` is what lifts the most weight. We will cover
|
||||
plugins next.
|
||||
This section is kept due to historical reasons. Starting with version <Badge text="3.0.0" />
|
||||
the amount of magic is reduced. To leverage your `Markwon` usage a concept of `Plugin`
|
||||
is introduced which helps to extend default behavior in a simple and _no-breaking-the-flow_ manner.
|
||||
Head to the [next section](/docs/core/plugins.md) to know more.
|
||||
|
@ -421,4 +421,47 @@ final Markwon markwon = Markwon.builder(context)
|
||||
Please note that unlike `#beforeSetText`, `#afterSetText` won't receive
|
||||
`Spanned` markdown. This happens because at this point spans must be
|
||||
queried directly from a TextView.
|
||||
:::
|
||||
:::
|
||||
|
||||
## What happens underneath
|
||||
|
||||
Here is an approximation of how a `Markwon` instance will handle plugins:
|
||||
|
||||
```java
|
||||
// `Markwon#create` implicitly uses CorePlugin
|
||||
final Markwon markwon = Markwon.builder(context)
|
||||
.usePlugin(CorePlugin.create())
|
||||
.build();
|
||||
|
||||
// warning: pseudo-code
|
||||
|
||||
// 0. each plugin will be called to _pre-process_ raw input markdown
|
||||
rawInput = plugins.reduce(rawInput, (input, plugin) -> plugin.processMarkdown(input));
|
||||
|
||||
// 1. after input is processed it's being parsed to a Node
|
||||
node = parser.parse(rawInput);
|
||||
|
||||
// 2. each plugin will be able to inspect or manipulate resulting Node
|
||||
// before rendering
|
||||
plugins.forEach(plugin -> plugin.beforeRender(node));
|
||||
|
||||
// 3. node is being visited by a visitor
|
||||
node.accept(visitor);
|
||||
|
||||
// 4. each plugin will be called after node is being visited (aka rendered)
|
||||
plugins.forEach(plugin -> plugin.afterRender(node, visitor));
|
||||
|
||||
// 5. styled markdown ready at this point
|
||||
final Spanned markdown = visitor.markdown();
|
||||
|
||||
// NB, points 6-8 are applied **only** if markdown is set to a TextView
|
||||
|
||||
// 6. each plugin will be called before styled markdown is applied to a TextView
|
||||
plugins.forEach(plugin -> plugin.beforeSetText(textView, markdown));
|
||||
|
||||
// 7. markdown is applied to a TextView
|
||||
textView.setText(markdown);
|
||||
|
||||
// 8. each plugin will be called after markdown is applied to a TextView
|
||||
plugins.forEach(plugin -> plugin.afterSetText(textView));
|
||||
```
|
@ -3,7 +3,7 @@
|
||||
# Theme
|
||||
|
||||
Here is the list of properties that can be configured via `SpannableTheme#builder` factory
|
||||
method. If you wish to control what is out of this list, you can use [SpannableFactory](/docs/factory.md)
|
||||
method. If you wish to control what is out of this list, you can use [SpannableFactory](/docs/v2/factory.md)
|
||||
abstraction which lets you to gather full control of Spans that are used to display markdown.
|
||||
|
||||
* factory methods
|
||||
|
Loading…
x
Reference in New Issue
Block a user