Java Code Examples for com.vladsch.flexmark.util.data.MutableDataSet#setFrom()
The following examples show how to use
com.vladsch.flexmark.util.data.MutableDataSet#setFrom() .
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 |
protected void makeConverter() { try { parserOptions = new MutableDataSet(); parserOptions.setFrom(ParserEmulationProfile.valueOf(emulationSelector.getValue())); parserOptions.set(Parser.EXTENSIONS, Arrays.asList( // AbbreviationExtension.create(), // DefinitionExtension.create(), // FootnoteExtension.create(), // TypographicExtension.create(), TablesExtension.create() )); parserOptions.set(HtmlRenderer.INDENT_SIZE, indentSize) // .set(HtmlRenderer.PERCENT_ENCODE_URLS, true) // .set(TablesExtension.COLUMN_SPANS, false) .set(TablesExtension.TRIM_CELL_WHITESPACE, trimCheck.isSelected()) .set(TablesExtension.APPEND_MISSING_COLUMNS, appendCheck.isSelected()) .set(TablesExtension.DISCARD_EXTRA_COLUMNS, discardCheck.isSelected()) .set(TablesExtension.APPEND_MISSING_COLUMNS, appendCheck.isSelected()); parser = Parser.builder(parserOptions).build(); renderer = HtmlRenderer.builder(parserOptions).build(); } catch (Exception e) { logger.error(e.toString()); } }
Example 2
Source File: MarkDownUtil.java From smart-doc with Apache License 2.0 | 5 votes |
/** * Convert markdown to html. * * @param content markdown contents * @return html contents */ public static String toHtml(String content) { MutableDataSet options = new MutableDataSet(); options.setFrom(ParserEmulationProfile.MARKDOWN); // enable table parse! options.set(Parser.EXTENSIONS, Arrays.asList(TablesExtension.create(), StrikethroughExtension.create())); Parser parser = Parser.builder(options).build(); HtmlRenderer renderer = HtmlRenderer.builder(options).build(); Node document = parser.parse(content); return renderer.render(document); }
Example 3
Source File: MarkdownToHtmlController.java From MyBox with Apache License 2.0 | 5 votes |
@Override public boolean makeMoreParameters() { try { parserOptions = new MutableDataSet(); parserOptions.setFrom(ParserEmulationProfile.valueOf(emulationSelector.getValue())); parserOptions.set(Parser.EXTENSIONS, Arrays.asList( // AbbreviationExtension.create(), // DefinitionExtension.create(), // FootnoteExtension.create(), // TypographicExtension.create(), TablesExtension.create() )); parserOptions.set(HtmlRenderer.INDENT_SIZE, indentSize) // .set(HtmlRenderer.PERCENT_ENCODE_URLS, true) // .set(TablesExtension.COLUMN_SPANS, false) .set(TablesExtension.TRIM_CELL_WHITESPACE, trimCheck.isSelected()) .set(TablesExtension.APPEND_MISSING_COLUMNS, appendCheck.isSelected()) .set(TablesExtension.DISCARD_EXTRA_COLUMNS, discardCheck.isSelected()) .set(TablesExtension.APPEND_MISSING_COLUMNS, appendCheck.isSelected()); parser = Parser.builder(parserOptions).build(); renderer = HtmlRenderer.builder(parserOptions).build(); } catch (Exception e) { logger.error(e.toString()); return false; } return super.makeMoreParameters(); }
Example 4
Source File: DataRequirementsProvider.java From cqf-ruler with Apache License 2.0 | 4 votes |
private CqfMeasure processMarkDown(CqfMeasure measure) { MutableDataSet options = new MutableDataSet(); options.setFrom(ParserEmulationProfile.GITHUB_DOC); options.set(Parser.EXTENSIONS, Arrays.asList( AutolinkExtension.create(), //AnchorLinkExtension.create(), //EmojiExtension.create(), StrikethroughExtension.create(), TablesExtension.create(), TaskListExtension.create() )); // uncomment and define location of emoji images from https://github.com/arvida/emoji-cheat-sheet.com // options.set(EmojiExtension.ROOT_IMAGE_PATH, ""); // Uncomment if GFM anchor links are desired in headings // options.set(AnchorLinkExtension.ANCHORLINKS_SET_ID, false); // options.set(AnchorLinkExtension.ANCHORLINKS_ANCHOR_CLASS, "anchor"); // options.set(AnchorLinkExtension.ANCHORLINKS_SET_NAME, true); // options.set(AnchorLinkExtension.ANCHORLINKS_TEXT_PREFIX, "<span class=\"octicon octicon-link\"></span>"); // References compatibility options.set(Parser.REFERENCES_KEEP, KeepType.LAST); // Set GFM table parsing options options.set(TablesExtension.COLUMN_SPANS, false) .set(TablesExtension.MIN_HEADER_ROWS, 1) .set(TablesExtension.MAX_HEADER_ROWS, 1) .set(TablesExtension.APPEND_MISSING_COLUMNS, true) .set(TablesExtension.DISCARD_EXTRA_COLUMNS, true) .set(TablesExtension.WITH_CAPTION, false) .set(TablesExtension.HEADER_SEPARATOR_COLUMN_MATCH, true); // Setup List Options for GitHub profile which is kramdown for documents options.setFrom(ParserEmulationProfile.GITHUB_DOC); options.set(HtmlRenderer.SOFT_BREAK, "<br />\n"); Parser parser = Parser.builder(options).build(); HtmlRenderer renderer = HtmlRenderer.builder(options).build(); measure.setDescription(markdownToHtml(parser, renderer, measure.getDescription())); measure.setPurpose(markdownToHtml(parser, renderer, measure.getPurpose())); // measure.setCopyright(markdownToHtml(parser, renderer, measure.getCopyright())); measure.setRationale(markdownToHtml(parser, renderer, measure.getRationale())); measure.setClinicalRecommendationStatement(markdownToHtml(parser, renderer, measure.getClinicalRecommendationStatement())); measure.setGuidance(markdownToHtml(parser, renderer, measure.getGuidance())); measure.setDefinition(measure.getDefinition().stream() .map(x -> markdownToHtml(parser, renderer, x.getValueAsString())) .map(x -> new MarkdownType(x)) .collect(Collectors.toList())); return measure; }
Example 5
Source File: DataRequirementsProvider.java From cqf-ruler with Apache License 2.0 | 4 votes |
private CqfMeasure processMarkDown(CqfMeasure measure) { MutableDataSet options = new MutableDataSet(); options.setFrom(ParserEmulationProfile.GITHUB_DOC); options.set(Parser.EXTENSIONS, Arrays.asList( AutolinkExtension.create(), //AnchorLinkExtension.create(), //EmojiExtension.create(), StrikethroughExtension.create(), TablesExtension.create(), TaskListExtension.create() )); // uncomment and define location of emoji images from https://github.com/arvida/emoji-cheat-sheet.com // options.set(EmojiExtension.ROOT_IMAGE_PATH, ""); // Uncomment if GFM anchor links are desired in headings // options.set(AnchorLinkExtension.ANCHORLINKS_SET_ID, false); // options.set(AnchorLinkExtension.ANCHORLINKS_ANCHOR_CLASS, "anchor"); // options.set(AnchorLinkExtension.ANCHORLINKS_SET_NAME, true); // options.set(AnchorLinkExtension.ANCHORLINKS_TEXT_PREFIX, "<span class=\"octicon octicon-link\"></span>"); // References compatibility options.set(Parser.REFERENCES_KEEP, KeepType.LAST); // Set GFM table parsing options options.set(TablesExtension.COLUMN_SPANS, false) .set(TablesExtension.MIN_HEADER_ROWS, 1) .set(TablesExtension.MAX_HEADER_ROWS, 1) .set(TablesExtension.APPEND_MISSING_COLUMNS, true) .set(TablesExtension.DISCARD_EXTRA_COLUMNS, true) .set(TablesExtension.WITH_CAPTION, false) .set(TablesExtension.HEADER_SEPARATOR_COLUMN_MATCH, true); // Setup List Options for GitHub profile which is kramdown for documents options.setFrom(ParserEmulationProfile.GITHUB_DOC); options.set(HtmlRenderer.SOFT_BREAK, "<br />\n"); Parser parser = Parser.builder(options).build(); HtmlRenderer renderer = HtmlRenderer.builder(options).build(); measure.setDescription(markdownToHtml(parser, renderer, measure.getDescription())); measure.setPurpose(markdownToHtml(parser, renderer, measure.getPurpose())); // measure.setCopyright(markdownToHtml(parser, renderer, measure.getCopyright())); measure.setRationale(markdownToHtml(parser, renderer, measure.getRationale())); measure.setClinicalRecommendationStatement(markdownToHtml(parser, renderer, measure.getClinicalRecommendationStatement())); measure.setGuidance(markdownToHtml(parser, renderer, measure.getGuidance())); measure.setDefinition(measure.getDefinition().stream() .map(x -> markdownToHtml(parser, renderer, x.getValueAsString())) .map(MarkdownType::new) .collect(Collectors.toList())); return measure; }