com.vladsch.flexmark.ext.gfm.strikethrough.StrikethroughExtension Java Examples

The following examples show how to use com.vladsch.flexmark.ext.gfm.strikethrough.StrikethroughExtension. 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: MarkDownUtil.java    From smart-doc with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #2
Source File: FlexmarkParser.java    From zeppelin with Apache License 2.0 5 votes vote down vote up
public FlexmarkParser() {
  MutableDataSet options = new MutableDataSet();
  options.set(Parser.EXTENSIONS, Arrays.asList(StrikethroughExtension.create(),
      TablesExtension.create(),
      UMLExtension.create(),
      AutolinkExtension.create(),
      WikiLinkExtension.create(),
      TypographicExtension.create()));
  options.set(HtmlRenderer.SOFT_BREAK, "<br />\n");
  parser = Parser.builder(options).build();
  renderer = HtmlRenderer.builder(options).build();
}
 
Example #3
Source File: Utils.java    From para with Apache License 2.0 5 votes vote down vote up
private static MutableDataHolder getMarkdownOptions() {
	return new MutableDataSet()
			.set(HtmlRenderer.ESCAPE_HTML, true)
			.set(EmojiExtension.USE_IMAGE_TYPE, EmojiImageType.UNICODE_FALLBACK_TO_IMAGE)
			// for full GFM table compatibility add the following table extension options:
			.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, Arrays.asList(TablesExtension.create(), EmojiExtension.create(),
					StrikethroughExtension.create(), TaskListExtension.create()));
}
 
Example #4
Source File: MarkDownModel.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
private List<Extension> createExtensions() {
    List<Extension> extensions = new LinkedList<>();
    extensions.add(TablesExtension.create());
    extensions.add(StrikethroughExtension.create());
    extensions.add(EmojiExtension.create());
    return extensions;
}
 
Example #5
Source File: DataRequirementsProvider.java    From cqf-ruler with Apache License 2.0 4 votes vote down vote up
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;
    }