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"> -