com.vladsch.flexmark.ext.autolink.AutolinkExtension Java Examples

The following examples show how to use com.vladsch.flexmark.ext.autolink.AutolinkExtension. 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: DefaultMarkdownManager.java    From onedev with MIT License 5 votes vote down vote up
@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 #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: 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;
    }