Flexmark embedded Youtube videos plugin released


November 27, 2017

As I wrote recently, I have written a plugin to embed Youtube videos into Markdown text rendered by Flexmark.

So, this is the continue.

The mainteiner and owner of Flexmark library approved my pull request, and now Flexmark (Java) supports embedded youtube videos natively since 0.28.8 version.

Here is the example of embedding youtube videos using Flexmark Markdown processor.

1. Add Flexmark v0.28.8 or later into your project.

For example, using Maven:


or Gradle:

dependencies {
    //markdown processor
    compile 'com.vladsch.flexmark:flexmark-all:0.28.8'

If you don't use any project development management tool which are Maven and Gradle, it's better to prefer do this.

2. Initializate the plugin:

public String renderToHtml(String content) {

    MutableDataSet options = new MutableDataSet();

        // uncomment to set optional extensions
    options.set(Parser.EXTENSIONS, Arrays.asList(
            YouTubeLinkExtension.create() //DON'T FORGET TO ENABLE PLUGIN

    // 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();

    // You can re-use parser and renderer instances
    Node document = parser.parse(content);
    String html = renderer.render(document);  // "<p>This is <em>Sparta</em></p>\n"

    return html;

3. Put any youtube video in your text using common link:


That's all you need.

on November 27, 2017