MakwonReducer filter out LinkReferenceDefinition

This commit is contained in:
Dimitry Ivanov 2020-06-26 17:56:42 +03:00
parent 1a90f1e609
commit bea6d6aeec
3 changed files with 7 additions and 3 deletions

View File

@ -11,6 +11,7 @@
* `inline-parser` - `BangInlineProcessor` properly returns `null` if no image node is found (possible to define other inline parsers that use `!` as special character) * `inline-parser` - `BangInlineProcessor` properly returns `null` if no image node is found (possible to define other inline parsers that use `!` as special character)
* `image` - `AsyncDrawable` won't trigger loading if it has result (aim: `RecyclerView` due to multiple attach/detach events of a View) * `image` - `AsyncDrawable` won't trigger loading if it has result (aim: `RecyclerView` due to multiple attach/detach events of a View)
* `image` - `AsyncDrawable` will resume result if it is `Animatable` and was playing before detach event (aim: `RecyclerView`) ([#241]) * `image` - `AsyncDrawable` will resume result if it is `Animatable` and was playing before detach event (aim: `RecyclerView`) ([#241])
* `core` - `MarkwonReducer` filter out `LinkReferenceDefinition` nodes
#### Fixed #### Fixed
* `image-glide` cache `RequestManager` in `GlideImagesPlugin#create(Context)` factory method ([#259]) * `image-glide` cache `RequestManager` in `GlideImagesPlugin#create(Context)` factory method ([#259])

View File

@ -29,7 +29,6 @@ import io.noties.markwon.recycler.table.TableEntry
import io.noties.markwon.recycler.table.TableEntryPlugin import io.noties.markwon.recycler.table.TableEntryPlugin
import io.noties.markwon.syntax.Prism4jThemeDefault import io.noties.markwon.syntax.Prism4jThemeDefault
import io.noties.markwon.syntax.SyntaxHighlightPlugin import io.noties.markwon.syntax.SyntaxHighlightPlugin
import io.noties.markwon.utils.DumpNodes
import io.noties.prism4j.Prism4j import io.noties.prism4j.Prism4j
import io.noties.prism4j.annotations.PrismBundle import io.noties.prism4j.annotations.PrismBundle
import okhttp3.Call import okhttp3.Call
@ -128,7 +127,6 @@ class ReadMeActivity : Activity() {
is Result.Success -> { is Result.Success -> {
val markwon = markwon val markwon = markwon
val node = markwon.parse(result.markdown) val node = markwon.parse(result.markdown)
Debug.i(DumpNodes.dump(node))
if (window != null) { if (window != null) {
recyclerView.post { recyclerView.post {
adapter.setParsedMarkdown(markwon, node) adapter.setParsedMarkdown(markwon, node)

View File

@ -2,6 +2,7 @@ package io.noties.markwon;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import org.commonmark.node.LinkReferenceDefinition;
import org.commonmark.node.Node; import org.commonmark.node.Node;
import java.util.ArrayList; import java.util.ArrayList;
@ -48,7 +49,11 @@ public abstract class MarkwonReducer {
Node temp; Node temp;
while (node != null) { while (node != null) {
// @since $nap; do not include LinkReferenceDefinition node (would result
// in empty textView if rendered in recycler-view)
if (!(node instanceof LinkReferenceDefinition)) {
list.add(node); list.add(node);
}
temp = node.getNext(); temp = node.getNext();
node.unlink(); node.unlink();
node = temp; node = temp;