文档
依赖
Java 8
<dependency>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>flexmark-all</artifactId>
<version>0.62.2</version>
</dependency>
Java 9+
<dependency>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>flexmark-all</artifactId>
<version>0.64.8</version>
</dependency>
示例
package com.example.demo;
import com.vladsch.flexmark.html.HtmlRenderer;
import com.vladsch.flexmark.parser.Parser;
import com.vladsch.flexmark.util.ast.Node;
import com.vladsch.flexmark.util.data.MutableDataSet;
public class FlexMarkDemo {
public static void main(String[] args) {
MutableDataSet options = new MutableDataSet();
Parser parser = Parser.builder(options).build();
HtmlRenderer renderer = HtmlRenderer.builder(options).build();
// You can re-use parser and renderer instances
Node document = parser.parse("# 标题");
String html = renderer.render(document); // 标题
System.out.println(html);
}
}
以上示例实现了markdown转为html
输入
# 标题
输出
标题
参考文章
标签:java,vladsch,parser,CommonMark,html,flexmark,com From: https://blog.51cto.com/mouday/7125724