本文整理了Java中com.vladsch.flexmark.parser.Parser.parse()
方法的一些代码示例,展示了Parser.parse()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.parse()
方法的具体详情如下:
包路径:com.vladsch.flexmark.parser.Parser
类名称:Parser
方法名:parse
[英]Parse the specified input text into a tree of nodes.
Note that this method is thread-safe (a new parser state is used for each invocation).
[中]将指定的输入文本解析为节点树。
注意,这个方法是线程安全的(每次调用都使用一个新的解析器状态)。
代码示例来源:origin: jphp-group/jphp
@Signature
public String render(String content) {
Document document = parser.parse(content.toString());
return renderer.render(document);
}
}
代码示例来源: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: 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: neuland/jade4j
@Override
protected String convert(String source, List<Attr> attributes) {
return renderer.render(parser.parse(source));
}
代码示例来源:origin: schemaspy/schemaspy
public static String toHtml(String markdownText, String rootPath) {
String text = markdownText;
if (text != null) {
text = addReferenceLink(text, rootPath);
Node content = PARSER.parse(text);
text = RENDERER.render(content).trim();
}
return text;
}
代码示例来源:origin: RaiMan/SikuliX2
options.set(HtmlRenderer.SOFT_BREAK, "<br>\n");
HtmlRenderer renderer = HtmlRenderer.builder(options).build();
Node document = parser.parse(aText);
int count = 4;
int idx = 0;
代码示例来源: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: Erudika/para
/**
* Converts Markdown to HTML.
* @param markdownString Markdown
* @return HTML
*/
public static String markdownToHtml(String markdownString) {
if (StringUtils.isBlank(markdownString)) {
return "";
}
return HTML_RENDERER.render(MD_PARSER.parse(markdownString));
}
代码示例来源:origin: com.github.terran4j/terran4j-commons-api2doc
public String md2Html(String content) throws Exception {
Node document = parser.parse(content);
String html = renderer.render(document);
return html;
}
代码示例来源:origin: io.github.javaeden.orchid/OrchidCore
@Override
public String compile(String extension, String source, Object... data) {
return renderer.render(parser.parse(source));
}
代码示例来源:origin: com.centurylink.mdw/mdw-common
private void printParagraphsHtml(StringBuilder sb, String content) {
if (content == null || content.length() == 0)
return;
Parser parser = FlexmarkInstances.getParser(null);
HtmlRenderer renderer = FlexmarkInstances.getRenderer(null);
Node document = parser.parse(content);
sb.append(renderer.render(document));
}
代码示例来源:origin: com.centurylink.mdw/mdw-common
public String getHtmlContent (String content) {
Parser parser = FlexmarkInstances.getParser(null);
HtmlRenderer renderer = FlexmarkInstances.getRenderer(null);
Node document = parser.parse(content);
return renderer.render(document);
}
}
代码示例来源: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: 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: 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();
}
内容来源于网络,如有侵权,请联系作者删除!