Add blockquote tag handler

This commit is contained in:
Dimitry Ivanov 2018-08-19 15:26:08 +03:00
parent 2d9c80d519
commit 9246a53891
2 changed files with 31 additions and 1 deletions

View File

@ -11,6 +11,7 @@ import java.util.Map;
import ru.noties.markwon.SpannableBuilder;
import ru.noties.markwon.SpannableConfiguration;
import ru.noties.markwon.html.api.MarkwonHtmlParser;
import ru.noties.markwon.renderer.html2.tag.BlockquoteHandler;
import ru.noties.markwon.renderer.html2.tag.EmphasisHandler;
import ru.noties.markwon.renderer.html2.tag.ImageHandler;
import ru.noties.markwon.renderer.html2.tag.LinkHandler;
@ -67,7 +68,8 @@ public abstract class MarkwonHtmlRenderer {
.handler("a", new LinkHandler())
.handler("ul", listHandler)
.handler("ol", listHandler)
.handler("img", ImageHandler.create());
.handler("img", ImageHandler.create())
.handler("blockquote", new BlockquoteHandler());
}
@NonNull

View File

@ -0,0 +1,28 @@
package ru.noties.markwon.renderer.html2.tag;
import android.support.annotation.NonNull;
import ru.noties.markwon.SpannableBuilder;
import ru.noties.markwon.SpannableConfiguration;
import ru.noties.markwon.html.api.HtmlTag;
public class BlockquoteHandler extends TagHandler {
@Override
public void handle(
@NonNull SpannableConfiguration configuration,
@NonNull SpannableBuilder builder,
@NonNull HtmlTag tag) {
if (tag.isBlock()) {
visitChildren(configuration, builder, tag.getAsBlock());
}
SpannableBuilder.setSpans(
builder,
configuration.factory().blockQuote(configuration.theme()),
tag.start(),
tag.end()
);
}
}