diff --git a/app/build.gradle b/app/build.gradle index 39bdd9a..14a8b03 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -39,7 +39,7 @@ dependencies { compile 'com.android.support:design:26.+' compile 'com.jakewharton:butterknife:8.7.0' compile 'com.android.support:support-v4:26.+' - compile 'com.vladsch.flexmark:flexmark-all:0.22.16' + compile 'com.commonsware.cwac:anddown:0.3.0' testCompile 'junit:junit:4.12' annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0' } diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/PreviewFragment.java b/app/src/main/java/com/wbrawner/simplemarkdown/PreviewFragment.java index ac2e247..e89c8d9 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/PreviewFragment.java +++ b/app/src/main/java/com/wbrawner/simplemarkdown/PreviewFragment.java @@ -14,22 +14,12 @@ import android.support.v4.app.ActivityCompat; import android.support.v4.app.Fragment; import android.support.v4.content.ContextCompat; import android.support.v4.content.LocalBroadcastManager; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.webkit.WebView; -import com.vladsch.flexmark.ast.Node; -import com.vladsch.flexmark.ext.gfm.strikethrough.StrikethroughExtension; -import com.vladsch.flexmark.ext.tables.TablesExtension; -import com.vladsch.flexmark.html.HtmlRenderer; -import com.vladsch.flexmark.parser.Parser; -import com.vladsch.flexmark.parser.ParserEmulationProfile; -import com.vladsch.flexmark.util.options.MutableDataHolder; -import com.vladsch.flexmark.util.options.MutableDataSet; - -import java.util.Arrays; +import com.commonsware.cwac.anddown.AndDown; import butterknife.BindView; import butterknife.ButterKnife; @@ -100,20 +90,18 @@ public class PreviewFragment extends Fragment { Thread setMarkdown = new Thread() { @Override public void run() { - 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(iText); - HtmlRenderer renderer = HtmlRenderer.builder(options).build(); - String html = renderer.render(document); + AndDown andDown = new AndDown(); + int hoedownFlags = + AndDown.HOEDOWN_EXT_STRIKETHROUGH | AndDown.HOEDOWN_EXT_TABLES | + AndDown.HOEDOWN_EXT_UNDERLINE | AndDown.HOEDOWN_EXT_SUPERSCRIPT; + String html = andDown.markdownToHtml(iText, hoedownFlags, 0); mMarkdownView.loadDataWithBaseURL(null, html, "text/html", "UTF-8", null); timeoutActive = false; } }; if (!timeoutActive) { timeoutActive = true; - handler.postDelayed(setMarkdown, 50); + handler.postDelayed(setMarkdown, 0); } } } diff --git a/build.gradle b/build.gradle index c2eea8e..ac667d0 100644 --- a/build.gradle +++ b/build.gradle @@ -15,6 +15,9 @@ buildscript { allprojects { repositories { jcenter() + maven { + url "https://s3.amazonaws.com/repo.commonsware.com" + } } }