com.vladsch.flexmark.profiles.pegdown.PegdownOptionsAdapter Java Examples
The following examples show how to use
com.vladsch.flexmark.profiles.pegdown.PegdownOptionsAdapter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MarkdownEditerController.java From MyBox with Apache License 2.0 | 6 votes |
public String convert2text() { try { // https://github.com/vsch/flexmark-java/blob/master/flexmark-java-samples/src/com/vladsch/flexmark/samples/MarkdownToText.java DataHolder OPTIONS = PegdownOptionsAdapter.flexmarkOptions(Extensions.ALL); MutableDataSet FORMAT_OPTIONS = new MutableDataSet(); FORMAT_OPTIONS.set(Parser.EXTENSIONS, OPTIONS.get(Parser.EXTENSIONS)); Parser PARSER = Parser.builder(OPTIONS).build(); Node document = PARSER.parse(mainArea.getText()); TextCollectingVisitor textCollectingVisitor = new TextCollectingVisitor(); String text = textCollectingVisitor.collectAndGetText(document); return text; } catch (Exception e) { return e.toString(); } }
Example #2
Source File: HelpActivity.java From mhzs with MIT License | 5 votes |
/** * 展示网页 */ private void showHtml(String md) { DataHolder OPTIONS = PegdownOptionsAdapter.flexmarkOptions(true, Extensions.NONE); Parser parser = Parser.builder(OPTIONS).build(); HtmlRenderer renderer = HtmlRenderer.builder(OPTIONS).build(); Node document = parser.parse(md); String html = renderer.render(document); // LogUtil.e(html); mWebView.getSettings().setDefaultTextEncodingName("UTF-8"); mWebView.loadData(html, "text/html; charset=UTF-8", null); }