Skip to content

Commit

Permalink
Added support for IndentedCodeBlock (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
dlew authored and noties committed Mar 17, 2018
1 parent e7f6f72 commit 92ad5a0
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -22,6 +23,7 @@
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;
Expand Down Expand Up @@ -142,7 +144,15 @@ public void visit(Code code) {

@Override
public void visit(FencedCodeBlock fencedCodeBlock) {
visitCodeBlock(fencedCodeBlock.getInfo(), fencedCodeBlock.getLiteral());
}

@Override
public void visit(IndentedCodeBlock indentedCodeBlock) {
visitCodeBlock(null, indentedCodeBlock.getLiteral());
}

private void visitCodeBlock(@Nullable String info, @NonNull String code) {
newLine();

final int length = builder.length();
Expand All @@ -151,7 +161,7 @@ public void visit(FencedCodeBlock fencedCodeBlock) {
builder.append('\u00a0').append('\n');
builder.append(
configuration.syntaxHighlight()
.highlight(fencedCodeBlock.getInfo(), fencedCodeBlock.getLiteral())
.highlight(info, code)
);
builder.append('\u00a0').append('\n');

Expand Down

0 comments on commit 92ad5a0

Please sign in to comment.