use of io.noties.markwon.ext.tasklist.TaskListDrawable in project android by nextcloud.
the class PreviewTextFragment method getRenderedMarkdownText.
protected static Spanned getRenderedMarkdownText(Activity activity, String markdown) {
Prism4j prism4j = new Prism4j(new MarkwonGrammarLocator());
Prism4jTheme prism4jTheme = Prism4jThemeDefault.create();
TaskListDrawable drawable = new TaskListDrawable(Color.GRAY, Color.GRAY, Color.WHITE);
drawable.setColorFilter(ThemeColorUtils.primaryColor(activity, true), PorterDuff.Mode.SRC_ATOP);
final Markwon markwon = Markwon.builder(activity).usePlugin(new AbstractMarkwonPlugin() {
@Override
public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
builder.linkColor(ThemeColorUtils.primaryColor(activity, true));
builder.headingBreakHeight(0);
}
@Override
public void configureConfiguration(@NonNull MarkwonConfiguration.Builder builder) {
builder.linkResolver((view, link) -> {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(link));
DisplayUtils.startIntentIfAppAvailable(intent, activity, R.string.no_browser_available);
});
}
}).usePlugin(TablePlugin.create(activity)).usePlugin(TaskListPlugin.create(drawable)).usePlugin(StrikethroughPlugin.create()).usePlugin(HtmlPlugin.create()).usePlugin(SyntaxHighlightPlugin.create(prism4j, prism4jTheme)).build();
return markwon.toMarkdown(markdown);
}
Aggregations