Working on documentation

This commit is contained in:
Dimitry Ivanov 2019-01-30 13:46:39 +03:00
parent 18fd56a97c
commit 8064070233
5 changed files with 68 additions and 58 deletions

View File

@ -41,6 +41,7 @@ module.exports = {
'', '',
{ {
title: 'Core', title: 'Core',
collapsable: false,
children: [ children: [
'/docs/core/getting-started.md', '/docs/core/getting-started.md',
'/docs/core/plugins.md', '/docs/core/plugins.md',
@ -60,19 +61,15 @@ module.exports = {
'/docs/ext-tasklist/', '/docs/ext-tasklist/',
{ {
title: 'HTML', title: 'HTML',
collapsable: false,
children: [ children: [
'/docs/html/', '/docs/html/',
'/docs/html/custom-tag-handler.md' '/docs/html/custom-tag-handler.md'
] ]
}, },
{ '/docs/image/gif.md',
title: 'Image', '/docs/image/okhttp.md',
children: [ '/docs/image/svg.md',
'/docs/image/gif.md',
'/docs/image/okhttp.md',
'/docs/image/svg.md'
]
},
'/docs/recycler/', '/docs/recycler/',
'/docs/syntax-highlight/', '/docs/syntax-highlight/',
'/docs/migration-2-3.md' '/docs/migration-2-3.md'

View File

@ -1,6 +1,19 @@
# Changelog # 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 `html-parser-api` and `html-parser-impl` modules
* Add `HtmlEmptyTagReplacement` * Add `HtmlEmptyTagReplacement`
* Implement Appendable and CharSequence in SpannableBuilder * Implement Appendable and CharSequence in SpannableBuilder

View File

@ -59,50 +59,7 @@ Toast.makeText(context, markdown, Toast.LENGTH_LONG).show();
## No magic one ## No magic one
So, what happens _internally_ when there is a `markwon#setMarkdown(TextView,String)` call? This section is kept due to historical reasons. Starting with version <Badge text="3.0.0" />
Please note that this is mere representaion of what happens underneath and a caller the amount of magic is reduced. To leverage your `Markwon` usage a concept of `Plugin`
would likely never has to deal with these method calls directly. It still valuable is introduced which helps to extend default behavior in a simple and _no-breaking-the-flow_ manner.
to understand how things are working: Head to the [next section](/docs/core/plugins.md) to know more.
```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.

View File

@ -421,4 +421,47 @@ final Markwon markwon = Markwon.builder(context)
Please note that unlike `#beforeSetText`, `#afterSetText` won't receive Please note that unlike `#beforeSetText`, `#afterSetText` won't receive
`Spanned` markdown. This happens because at this point spans must be `Spanned` markdown. This happens because at this point spans must be
queried directly from a TextView. 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));
```

View File

@ -3,7 +3,7 @@
# Theme # Theme
Here is the list of properties that can be configured via `SpannableTheme#builder` factory 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. abstraction which lets you to gather full control of Spans that are used to display markdown.
* factory methods * factory methods