本文整理了Java中com.vladsch.flexmark.parser.Parser.builder()
方法的一些代码示例,展示了Parser.builder()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.builder()
方法的具体详情如下:
包路径:com.vladsch.flexmark.parser.Parser
类名称:Parser
方法名:builder
[英]Create a new builder for configuring a Parser.
[中]创建用于配置解析器的新生成器。
代码示例来源:origin: jphp-group/jphp
@Signature
public void __construct() {
renderer = HtmlRenderer.builder().build();
parser = Parser.builder().build();
}
代码示例来源:origin: allure-framework/allure2
@Override
public Function<String, String> getValue() {
final Parser parser = Parser.builder().build();
final HtmlRenderer renderer = HtmlRenderer.builder().build();
return s -> renderer.render(parser.parse(s));
}
}
代码示例来源:origin: jphp-group/jphp
@Signature
public void __construct(PMarkdownOptions options) {
renderer = HtmlRenderer.builder(options.getNativeOptions()).build();
parser = Parser.builder(options.getNativeOptions()).build();
}
代码示例来源:origin: Raysmond/SpringBlog
@Override
public String renderToHtml(String content) {
MutableDataSet options = new MutableDataSet();
options.set(Parser.EXTENSIONS,
Arrays.asList(TablesExtension.create(),
AutolinkExtension.create(),
StrikethroughExtension.create()));
// 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);
return renderer.render(document);
}
}
代码示例来源:origin: RaiMan/SikuliX2
if (isMarkUp) {
MutableDataSet options = new MutableDataSet();
Parser parser = Parser.builder(options).build();
options.set(HtmlRenderer.SOFT_BREAK, "<br>\n");
HtmlRenderer renderer = HtmlRenderer.builder(options).build();
代码示例来源:origin: jbake-org/jbake
@Override
public void processBody(final ParserContext context) {
List<String> mdExts = context.getConfig().getMarkdownExtensions();
int extensions = Extensions.NONE;
for (String ext : mdExts) {
if (ext.startsWith("-")) {
ext = ext.substring(1);
extensions = removeExtension(extensions, extensionFor(ext));
} else {
if (ext.startsWith("+")) {
ext = ext.substring(1);
}
extensions = addExtension(extensions, extensionFor(ext));
}
}
DataHolder options = PegdownOptionsAdapter.flexmarkOptions(extensions);
Parser parser = Parser.builder(options).build();
HtmlRenderer renderer = HtmlRenderer.builder(options).build();
Document document = parser.parse(context.getBody());
context.setBody(renderer.render(document));
}
代码示例来源:origin: com.centurylink.mdw/mdw-common
public static Parser getParser(MutableDataSet renderOptions) {
if (renderOptions == null)
return parser;
return Parser.builder(renderOptions).build();
}
代码示例来源:origin: com.github.macgregor/alexandria-core
/**
* Retrieve the {@link Parser}, creating it if it doesnt exist
*
* @return flexmark parser
*/
public static Parser parser(){
if(parser == null){
parser = Parser.builder(options()).build();
}
return parser;
}
代码示例来源:origin: io.qameta.allure/allure-plugin-api
@Override
public Function<String, String> getValue() {
final Parser parser = Parser.builder().build();
final HtmlRenderer renderer = HtmlRenderer.builder().build();
return s -> renderer.render(parser.parse(s));
}
}
代码示例来源:origin: com.simiacryptus/literate-reporting
private synchronized File writeHtml(MutableDataSet options) throws IOException {
List<Extension> extensions = Arrays.asList(
TablesExtension.create(),
SubscriptExtension.create(),
EscapedCharacterExtension.create()
);
Parser parser = Parser.builder(options).extensions(extensions).build();
HtmlRenderer renderer = HtmlRenderer.builder(options).extensions(extensions).escapeHtml(false).indentSize(2).softBreak("\n").build();
String txt = toString(toc) + "\n\n" + toString(markdownData);
FileUtils.write(new File(getRoot(), getName() + ".md"), txt, "UTF-8");
File htmlFile = new File(getRoot(), getName() + ".html");
String html = renderer.render(parser.parse(txt));
html = "<html><body>" + html + "</body></html>";
try (FileOutputStream out = new FileOutputStream(htmlFile)) {
IOUtils.write(html, out, Charset.forName("UTF-8"));
}
log.info("Wrote " + htmlFile); // log.info("Wrote " + htmlFile); //
return htmlFile;
}
代码示例来源:origin: io.github.javaeden.orchid/OrchidCore
@Inject
public MarkdownCompiler(Set<Extension> extensionSet, Set<MutableDataSet> injectedOptions) {
super(900);
MutableDataSet options = new MutableDataSet();
options.set(HtmlRenderer.GENERATE_HEADER_ID, true);
options.set(HtmlRenderer.RENDER_HEADER_ID, true);
options.set(Parser.EXTENSIONS, extensionSet);
for(MutableDataSet injectedOption : injectedOptions) {
options.setAll(injectedOption);
}
parser = Parser.builder(options).build();
renderer = HtmlRenderer.builder(options).build();
}
代码示例来源:origin: com.simiacryptus/java-util
private synchronized File writeHtml(MutableDataSet options) throws IOException {
List<Extension> extensions = Arrays.asList(
TablesExtension.create(),
SubscriptExtension.create(),
EscapedCharacterExtension.create()
);
Parser parser = Parser.builder(options).extensions(extensions).build();
HtmlRenderer renderer = HtmlRenderer.builder(options).extensions(extensions).escapeHtml(false).indentSize(2).softBreak("\n").build();
String txt = toString(toc) + "\n\n" + toString(markdownData);
FileUtils.write(new File(getRoot(), getName() + ".md"), txt, "UTF-8");
File htmlFile = new File(getRoot(), getName() + ".html");
String html = renderer.render(parser.parse(txt));
html = "<html><body>" + html + "</body></html>";
try (FileOutputStream out = new FileOutputStream(htmlFile)) {
IOUtils.write(html, out, Charset.forName("UTF-8"));
}
log.info("Wrote " + htmlFile); // log.info("Wrote " + htmlFile); //
return htmlFile;
}
代码示例来源:origin: theotherp/nzbhydra2
public static String renderMarkdownAsHtml(String markdown) {
MutableDataSet options = new MutableDataSet();
Parser parser = Parser.builder(options).build();
HtmlRenderer renderer = HtmlRenderer.builder(options).build();
Node document = parser.parse(markdown);
return renderer.render(document);
}
代码示例来源:origin: danfickle/openhtmltopdf
private static String markdown(String md) {
MutableDataSet options = new MutableDataSet();
options.set(Parser.EXTENSIONS, Arrays.asList(
TocExtension.create(),
AnchorLinkExtension.create()
));
options.set(AnchorLinkExtension.ANCHORLINKS_WRAP_TEXT, false);
Parser parser = Parser.builder(options).build();
HtmlRenderer renderer = HtmlRenderer.builder(options).build();
Node document = parser.parse(md);
return renderer.render(document);
}
代码示例来源:origin: com.wuyushuo/vplus-data
/**
* markdown to html
* @param content markdown contents
* @return parse html contents
*/
public static String parse(String content) {
MutableDataSet options = new MutableDataSet();
options.setFrom(ParserEmulationProfile.MARKDOWN);
// enable table parse!
options.set(Parser.EXTENSIONS, Arrays.asList(TablesExtension.create()));
Parser parser = Parser.builder(options).build();
HtmlRenderer renderer = HtmlRenderer.builder(options).build();
Node document = parser.parse(content);
return renderer.render(document);
}
代码示例来源:origin: org.jbake/jbake-core
@Override
public void processBody(final ParserContext context) {
List<String> mdExts = context.getConfig().getMarkdownExtensions();
int extensions = Extensions.NONE;
for (String ext : mdExts) {
if (ext.startsWith("-")) {
ext = ext.substring(1);
extensions = removeExtension(extensions, extensionFor(ext));
} else {
if (ext.startsWith("+")) {
ext = ext.substring(1);
}
extensions = addExtension(extensions, extensionFor(ext));
}
}
DataHolder options = PegdownOptionsAdapter.flexmarkOptions(extensions);
Parser parser = Parser.builder(options).build();
HtmlRenderer renderer = HtmlRenderer.builder(options).build();
Document document = parser.parse(context.getBody());
context.setBody(renderer.render(document));
}
代码示例来源:origin: liuyueyi/quick-media
/**
* markdown to html
*
* @param content markdown contents
* @return parse html contents
*/
public static String parse(String content) {
MutableDataSet options = new MutableDataSet();
options.setFrom(ParserEmulationProfile.MARKDOWN);
// enable table parse!
options.set(Parser.EXTENSIONS, Arrays.asList(TablesExtension.create()));
Parser parser = Parser.builder(options).build();
HtmlRenderer renderer = HtmlRenderer.builder(options).build();
Node document = parser.parse(content);
return renderer.render(document);
}
代码示例来源:origin: cn-cerc/summer-mis
/**
* @param inputText
* 传入的md字符串
* @return 返回经转化后的html
*/
public String mdToHtml(String inputText) {
MutableDataSet options = new MutableDataSet();
// 使用github的markdown扩展语法
options.setFrom(ParserEmulationProfile.GITHUB_DOC);
Parser parser = Parser.builder(options).build();
HtmlRenderer renderer = HtmlRenderer.builder(options).build();
Node document = parser.parse(inputText);
return renderer.render(document);
}
代码示例来源:origin: io.teecube.t3/t3-site-enhancer
private HtmlCanvas addMergeRequest(HtmlCanvas html, MergeRequest mergeRequest) throws IOException {
MutableDataSet options = new MutableDataSet();
Parser parser = Parser.builder(options).build();
HtmlRenderer renderer = HtmlRenderer.builder(options).build();
String description = mergeRequest.getDescription();
description = renderer.render(parser.parse(description));
return html.li().h5().write(mergeRequest.getTitle() + " ").a(href(gitlabRepository + "/merge_requests/"+mergeRequest.getIid()).class_("external")).write("#"+mergeRequest.getIid())._a()._h5().write(description, false)._li();
}
代码示例来源:origin: io.teecube.t3/t3-site-enhancer
private HtmlCanvas addIssue(HtmlCanvas html, Issue issue) throws IOException {
MutableDataSet options = new MutableDataSet();
Parser parser = Parser.builder(options).build();
HtmlRenderer renderer = HtmlRenderer.builder(options).build();
String description = issue.getDescription();
description = renderer.render(parser.parse(description));
return html.li().h5().write(issue.getTitle() + " ").a(href(gitlabRepository + "/issues/"+issue.getIid()).class_("external")).write("#"+issue.getIid())._a()._h5().write(description, false)._li();
}
内容来源于网络,如有侵权,请联系作者删除!