Skip to content

Commit 128fa5d

Browse files
mueller-maJuancaG05
authored andcommitted
Add a few plugins
1 parent d73266f commit 128fa5d

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ buildscript {
2121
// Koin
2222
ioInsertKoin = "3.3.3"
2323

24+
// Markwon
25+
markwon = "4.6.2"
26+
2427
// Moshi
2528
comSquareupMoshi = '1.14.0'
2629

owncloudApp/build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,13 @@ dependencies {
5555
implementation "com.google.android.exoplayer:exoplayer:2.16.1"
5656
implementation "com.google.android.material:material:1.8.0"
5757
implementation "com.jakewharton:disklrucache:2.0.2"
58-
implementation "io.noties.markwon:core:4.6.2"
58+
59+
// Markdown Preview
60+
implementation "io.noties.markwon:core:$markwon"
61+
implementation "io.noties.markwon:ext-tables:$markwon"
62+
implementation "io.noties.markwon:ext-strikethrough:$markwon"
63+
implementation "io.noties.markwon:ext-tasklist:$markwon"
64+
implementation "io.noties.markwon:html:$markwon"
5965

6066
// Tests
6167
testImplementation project(":owncloudTestUtil")

owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
package com.owncloud.android.ui.preview;
2222

2323
import android.accounts.Account;
24+
import android.content.Context;
2425
import android.os.AsyncTask;
2526
import android.os.Bundle;
2627
import android.view.LayoutInflater;
@@ -49,6 +50,10 @@
4950
import com.owncloud.android.ui.fragment.FileFragment;
5051
import com.owncloud.android.utils.PreferenceUtils;
5152
import io.noties.markwon.Markwon;
53+
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
54+
import io.noties.markwon.ext.tables.TablePlugin;
55+
import io.noties.markwon.ext.tasklist.TaskListPlugin;
56+
import io.noties.markwon.html.HtmlPlugin;
5257
import timber.log.Timber;
5358

5459
import java.io.BufferedWriter;
@@ -253,7 +258,14 @@ protected void onPostExecute(final StringWriter stringWriter) {
253258
if (textView != null) {
254259
String text = new String(stringWriter.getBuffer());
255260
if (mimeType.equals("text/markdown")) {
256-
Markwon markwon = Markwon.create(textView.getContext());
261+
Context context = textView.getContext();
262+
Markwon markwon = Markwon
263+
.builder(context)
264+
.usePlugin(TablePlugin.create(context))
265+
.usePlugin(StrikethroughPlugin.create())
266+
.usePlugin(TaskListPlugin.create(context))
267+
.usePlugin(HtmlPlugin.create())
268+
.build();
257269
markwon.setMarkdown(textView, text);
258270
} else {
259271
textView.setText(text);

0 commit comments

Comments
 (0)