V1.0.4 (#31)
* Fix for #28 (table is removed when at the end) * Added support for IndentedCodeBlock (#30)
This commit is contained in:
parent
79fceb6f69
commit
9dd05434d9
@ -12,9 +12,9 @@
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
```groovy
|
```groovy
|
||||||
compile 'ru.noties:markwon:1.0.3'
|
compile 'ru.noties:markwon:1.0.4'
|
||||||
compile 'ru.noties:markwon-image-loader:1.0.3' // optional
|
compile 'ru.noties:markwon-image-loader:1.0.4' // optional
|
||||||
compile 'ru.noties:markwon-view:1.0.3' // optional
|
compile 'ru.noties:markwon-view:1.0.4' // optional
|
||||||
```
|
```
|
||||||
|
|
||||||
## Supported markdown features:
|
## Supported markdown features:
|
||||||
|
@ -6,7 +6,7 @@ org.gradle.configureondemand=true
|
|||||||
android.enableBuildCache=true
|
android.enableBuildCache=true
|
||||||
android.buildCacheDir=build/pre-dex-cache
|
android.buildCacheDir=build/pre-dex-cache
|
||||||
|
|
||||||
VERSION_NAME=1.0.3
|
VERSION_NAME=1.0.4
|
||||||
|
|
||||||
GROUP=ru.noties
|
GROUP=ru.noties
|
||||||
POM_DESCRIPTION=Markwon
|
POM_DESCRIPTION=Markwon
|
||||||
|
@ -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 view {@link TextView} to set markdown into
|
||||||
* @param text parsed markdown
|
* @param text parsed markdown
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package ru.noties.markwon.renderer;
|
package ru.noties.markwon.renderer;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.style.StrikethroughSpan;
|
import android.text.style.StrikethroughSpan;
|
||||||
@ -22,6 +23,7 @@ import org.commonmark.node.Heading;
|
|||||||
import org.commonmark.node.HtmlBlock;
|
import org.commonmark.node.HtmlBlock;
|
||||||
import org.commonmark.node.HtmlInline;
|
import org.commonmark.node.HtmlInline;
|
||||||
import org.commonmark.node.Image;
|
import org.commonmark.node.Image;
|
||||||
|
import org.commonmark.node.IndentedCodeBlock;
|
||||||
import org.commonmark.node.Link;
|
import org.commonmark.node.Link;
|
||||||
import org.commonmark.node.ListBlock;
|
import org.commonmark.node.ListBlock;
|
||||||
import org.commonmark.node.ListItem;
|
import org.commonmark.node.ListItem;
|
||||||
@ -142,7 +144,24 @@ public class SpannableMarkdownVisitor extends AbstractVisitor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(FencedCodeBlock fencedCodeBlock) {
|
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();
|
newLine();
|
||||||
|
|
||||||
final int length = builder.length();
|
final int length = builder.length();
|
||||||
@ -151,7 +170,7 @@ public class SpannableMarkdownVisitor extends AbstractVisitor {
|
|||||||
builder.append('\u00a0').append('\n');
|
builder.append('\u00a0').append('\n');
|
||||||
builder.append(
|
builder.append(
|
||||||
configuration.syntaxHighlight()
|
configuration.syntaxHighlight()
|
||||||
.highlight(fencedCodeBlock.getInfo(), fencedCodeBlock.getLiteral())
|
.highlight(info, code)
|
||||||
);
|
);
|
||||||
builder.append('\u00a0').append('\n');
|
builder.append('\u00a0').append('\n');
|
||||||
|
|
||||||
@ -331,7 +350,11 @@ public class SpannableMarkdownVisitor extends AbstractVisitor {
|
|||||||
visitChildren(node);
|
visitChildren(node);
|
||||||
|
|
||||||
if (pendingTableRow != null) {
|
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(
|
final TableRowSpan span = new TableRowSpan(
|
||||||
configuration.theme(),
|
configuration.theme(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user