diff --git a/README.md b/README.md index 876af5e9..e8a929cc 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ ## Installation ```groovy -compile 'ru.noties:markwon:1.0.3' -compile 'ru.noties:markwon-image-loader:1.0.3' // optional -compile 'ru.noties:markwon-view:1.0.3' // optional +compile 'ru.noties:markwon:1.0.4' +compile 'ru.noties:markwon-image-loader:1.0.4' // optional +compile 'ru.noties:markwon-view:1.0.4' // optional ``` ## Supported markdown features: diff --git a/gradle.properties b/gradle.properties index da766e33..9c6b3003 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ org.gradle.configureondemand=true android.enableBuildCache=true android.buildCacheDir=build/pre-dex-cache -VERSION_NAME=1.0.3 +VERSION_NAME=1.0.4 GROUP=ru.noties POM_DESCRIPTION=Markwon diff --git a/library/src/main/java/ru/noties/markwon/Markwon.java b/library/src/main/java/ru/noties/markwon/Markwon.java index aa0f566b..77b397d3 100644 --- a/library/src/main/java/ru/noties/markwon/Markwon.java +++ b/library/src/main/java/ru/noties/markwon/Markwon.java @@ -66,7 +66,7 @@ public abstract class Markwon { } /** - * Helper method to apply parsed markdown. Please note, that if images or tables are used + * Helper method to apply parsed markdown. * * @param view {@link TextView} to set markdown into * @param text parsed markdown diff --git a/library/src/main/java/ru/noties/markwon/renderer/SpannableMarkdownVisitor.java b/library/src/main/java/ru/noties/markwon/renderer/SpannableMarkdownVisitor.java index 75c70c32..31195a4c 100644 --- a/library/src/main/java/ru/noties/markwon/renderer/SpannableMarkdownVisitor.java +++ b/library/src/main/java/ru/noties/markwon/renderer/SpannableMarkdownVisitor.java @@ -1,6 +1,7 @@ package ru.noties.markwon.renderer; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.text.Spanned; import android.text.TextUtils; import android.text.style.StrikethroughSpan; @@ -22,6 +23,7 @@ import org.commonmark.node.Heading; import org.commonmark.node.HtmlBlock; import org.commonmark.node.HtmlInline; import org.commonmark.node.Image; +import org.commonmark.node.IndentedCodeBlock; import org.commonmark.node.Link; import org.commonmark.node.ListBlock; import org.commonmark.node.ListItem; @@ -142,7 +144,24 @@ public class SpannableMarkdownVisitor extends AbstractVisitor { @Override public void visit(FencedCodeBlock fencedCodeBlock) { + // @since 1.0.4 + visitCodeBlock(fencedCodeBlock.getInfo(), fencedCodeBlock.getLiteral()); + } + /** + * @since 1.0.4 + */ + @Override + public void visit(IndentedCodeBlock indentedCodeBlock) { + visitCodeBlock(null, indentedCodeBlock.getLiteral()); + } + + /** + * @param info tag of a code block + * @param code content of a code block + * @since 1.0.4 + */ + private void visitCodeBlock(@Nullable String info, @NonNull String code) { newLine(); final int length = builder.length(); @@ -151,7 +170,7 @@ public class SpannableMarkdownVisitor extends AbstractVisitor { builder.append('\u00a0').append('\n'); builder.append( configuration.syntaxHighlight() - .highlight(fencedCodeBlock.getInfo(), fencedCodeBlock.getLiteral()) + .highlight(info, code) ); builder.append('\u00a0').append('\n'); @@ -331,7 +350,11 @@ public class SpannableMarkdownVisitor extends AbstractVisitor { visitChildren(node); if (pendingTableRow != null) { - builder.append(' '); + + // @since 1.0.4 Replace table char with non-breakable space + // we need this because if table is at the end of the text, then it will be + // trimmed from the final result + builder.append('\u00a0'); final TableRowSpan span = new TableRowSpan( configuration.theme(),