From 9a493fb5369b9ce3b873cb752c23bbe026f2314c Mon Sep 17 00:00:00 2001 From: Billy Brawner Date: Thu, 27 Jul 2017 12:43:55 -0500 Subject: [PATCH] Switched to flexmark as markdown processor --- app/build.gradle | 9 +++- app/src/main/AndroidManifest.xml | 1 + .../wbrawner/simplemarkdown/MainActivity.java | 10 +++- .../simplemarkdown/PreviewFragment.java | 51 +++++++++++++++++-- app/src/main/res/layout/fragment_preview.xml | 2 +- 5 files changed, 66 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d8d8196..6c1d618 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,6 +1,13 @@ apply plugin: 'com.android.application' android { + packagingOptions { + exclude 'META-INF/LICENSE-LGPL-2.1.txt' + exclude 'META-INF/LICENSE-LGPL-3.txt' + exclude 'META-INF/LICENSE-W3C-TEST' + exclude 'META-INF/LICENSE' + exclude 'META-INF/DEPENDENCIES' + } compileSdkVersion 26 buildToolsVersion "26.0.0" defaultConfig { @@ -27,9 +34,9 @@ dependencies { compile 'com.android.support:appcompat-v7:26.+' compile 'com.android.support.constraint:constraint-layout:1.0.2' compile 'com.android.support:design:26.+' - compile 'us.feras.mdv:markdownview:1.1.0' compile 'com.jakewharton:butterknife:8.7.0' compile 'com.android.support:support-v4:26.+' + compile 'com.vladsch.flexmark:flexmark-all:0.22.16' testCompile 'junit:junit:4.12' annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index adcc9e1..ea8b4e3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,6 +3,7 @@ package="com.wbrawner.simplemarkdown"> + = Build.VERSION_CODES.KITKAT) { + WebView.setWebContentsDebuggingEnabled(true); + } return view; } @@ -55,9 +88,19 @@ public class PreviewFragment extends Fragment { if (intent.hasExtra("markdownData")) { String data = intent.getStringExtra("markdownData"); Log.d(TAG, "Markdown Data: " + data); - markdownView.loadMarkdown(data); + markdown(data); } } } + private void markdown(String text) { + MutableDataHolder options = new MutableDataSet(); + options.setFrom(ParserEmulationProfile.MARKDOWN); + options.set(Parser.EXTENSIONS, Arrays.asList(TablesExtension.create(), StrikethroughExtension.create())); + Parser parser = Parser.builder(options).build(); + Node document = parser.parse(text); + HtmlRenderer renderer = HtmlRenderer.builder(options).build(); + String html = renderer.render(document); + mMarkdownView.loadDataWithBaseURL(null, html, "text/html", "UTF-8", null); + } } diff --git a/app/src/main/res/layout/fragment_preview.xml b/app/src/main/res/layout/fragment_preview.xml index 4196a56..d8779b6 100644 --- a/app/src/main/res/layout/fragment_preview.xml +++ b/app/src/main/res/layout/fragment_preview.xml @@ -4,7 +4,7 @@ android:layout_height="match_parent" tools:context="com.wbrawner.simplemarkdown.PreviewFragment"> -