com.vladsch.flexmark.util.options.MutableDataSet Java Examples
The following examples show how to use
com.vladsch.flexmark.util.options.MutableDataSet.
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: MarkdownHandler.java From 1Rramp-Android with MIT License | 6 votes |
public static String getHtmlFromMarkdown(String md){ MutableDataSet options = new MutableDataSet(); // uncomment to set optional extensions //options.set(Parser.EXTENSIONS, Arrays.asList(TablesExtension.create(), StrikethroughExtension.create())); // uncomment to convert soft-breaks to hard breaks //options.set(HtmlRenderer.SOFT_BREAK, "<br />\n"); Parser parser = Parser.builder(options).build(); HtmlRenderer renderer = HtmlRenderer.builder(options).build(); Node document = parser.parse(md); String html = renderer.render(document); //do some more formatting html = RegexUtils.replaceMarkdownImage(html); html = RegexUtils.replacePlainImageLinks(html); return html; }
Example #2
Source File: DocumentationGenerator.java From TestingApp with Apache License 2.0 | 6 votes |
public String getInstructionsAsHTML() { MutableDataSet options = new MutableDataSet(); // uncomment to set optional extensions //options.set(Parser.EXTENSIONS, Arrays.asList(TablesExtension.create(), StrikethroughExtension.create())); // uncomment to convert soft-breaks to hard breaks options.set(HtmlRenderer.SOFT_BREAK, "<br />\n"); Parser parser = Parser.builder(options).build(); HtmlRenderer renderer = HtmlRenderer.builder(options).build(); String markdown = getInstructionsAsMarkdown(); // You can re-use parser and renderer instances Node document = parser.parse(markdown); return renderer.render(document); }
Example #3
Source File: MarkDownModel.java From Orienteer with Apache License 2.0 | 6 votes |
@Override protected String load() { String markDownValue = markDawnModel.getObject(); if (Strings.isEmpty(markDownValue)) { return ""; } try { MutableDataSet options = new MutableDataSet(); options.set(Parser.EXTENSIONS, createExtensions()); Parser parser = Parser.builder(options).build(); HtmlRenderer renderer = HtmlRenderer.builder(options).build(); Node node = parser.parse(markDawnModel.getObject()); markDownValue = renderer.render(node); } catch (Exception e) { throw new WicketRuntimeException("Can't use flexmark-java for markups", e); } return markDownValue; }
Example #4
Source File: Markdown2HtmlUtil.java From plumemo with Apache License 2.0 | 5 votes |
/** * Markdownz转为Html * @param content * @return */ public static String html(String content){ MutableDataSet options = new MutableDataSet(); options.setFrom(ParserEmulationProfile.MARKDOWN); options.set(Parser.EXTENSIONS, Arrays.asList(new Extension[]{TablesExtension.create()})); Parser parser = Parser.builder(options).build(); HtmlRenderer renderer = HtmlRenderer.builder(options).build(); Node document = parser.parse(content); return renderer.render(document); }
Example #5
Source File: DefaultMarkdownManager.java From onedev with MIT License | 5 votes |
@Override public String render(String markdown) { List<Extension> extensions = new ArrayList<>(); extensions.add(AnchorLinkExtension.create()); extensions.add(TablesExtension.create()); extensions.add(TaskListExtension.create()); extensions.add(DefinitionExtension.create()); extensions.add(TocExtension.create()); extensions.add(AutolinkExtension.create()); extensions.addAll(contributedExtensions); MutableDataHolder options = new MutableDataSet() .set(HtmlRenderer.GENERATE_HEADER_ID, true) .set(AnchorLinkExtension.ANCHORLINKS_SET_NAME, true) .set(AnchorLinkExtension.ANCHORLINKS_WRAP_TEXT, false) .set(AnchorLinkExtension.ANCHORLINKS_TEXT_PREFIX, "<span class='header-anchor'></span>") .set(Parser.SPACE_IN_LINK_URLS, true) .setFrom(ParserEmulationProfile.GITHUB_DOC) .set(TablesExtension.COLUMN_SPANS, false) .set(TablesExtension.APPEND_MISSING_COLUMNS, true) .set(TablesExtension.DISCARD_EXTRA_COLUMNS, true) .set(TablesExtension.HEADER_SEPARATOR_COLUMN_MATCH, true) .set(Parser.EXTENSIONS, extensions); Parser parser = Parser.builder(options).build(); HtmlRenderer htmlRenderer = HtmlRenderer.builder(options).build(); Node document = parser.parse(markdown); return htmlRenderer.render(document); }
Example #6
Source File: PMarkdownOptions.java From jphp with Apache License 2.0 | 5 votes |
public MutableDataSet getNativeOptions() { MutableDataSet dataSet = new MutableDataSet(); dataSet.set(Parser.EXTENSIONS, parserExtensions); for (Entry<DataKey, Object> entry : options.getAll().entrySet()) { dataSet.set(entry.getKey(), entry.getValue()); } return dataSet; }
Example #7
Source File: DocumentParser.java From camunda-bpm-swagger with Apache License 2.0 | 4 votes |
public DocumentParser() { final MutableDataSet options = new MutableDataSet(); parser = Parser.builder(options).build(); }
Example #8
Source File: FlexmarkInstances.java From mdw with Apache License 2.0 | 4 votes |
public static Parser getParser(MutableDataSet renderOptions) { if (renderOptions == null) return parser; return Parser.builder(renderOptions).build(); }
Example #9
Source File: FlexmarkInstances.java From mdw with Apache License 2.0 | 4 votes |
public static HtmlRenderer getRenderer(MutableDataSet renderOptions) { if (renderOptions == null) return renderer; return HtmlRenderer.builder(renderOptions).build(); }
Example #10
Source File: PMarkdownOptions.java From jphp with Apache License 2.0 | 4 votes |
public PMarkdownOptions(Environment env, MutableDataSet options) { super(env); this.options = options; }