本文整理了Java中com.vladsch.flexmark.parser.Parser
类的一些代码示例,展示了Parser
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser
类的具体详情如下:
包路径:com.vladsch.flexmark.parser.Parser
类名称:Parser
[英]Parses input text to a tree of nodes.
Start with the #builder method, configure the parser and build it. Example:
Parser parser = Parser.builder().build();
[中]将输入文本解析为节点树。
从#builder方法开始,配置解析器并构建它。例子:
Parser 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 String render(String content) {
Document document = parser.parse(content.toString());
return renderer.render(document);
}
}
代码示例来源:origin: jphp-group/jphp
@Signature
public void __construct() {
renderer = HtmlRenderer.builder().build();
parser = Parser.builder().build();
}
代码示例来源:origin: vsch/flexmark-java
@Override
public boolean transferReferences(final MutableDataHolder document, final DataHolder included) {
// cannot optimize based on macros in this document, repository is not accessed until rendering
if (/*document.contains(MACRO_DEFINITIONS) &&*/ included.contains(MACRO_DEFINITIONS)) {
return Parser.transferReferences(MACRO_DEFINITIONS.getFrom(document), MACRO_DEFINITIONS.getFrom(included), MACRO_DEFINITIONS_KEEP.getFrom(document) == KeepType.FIRST);
}
return false;
}
代码示例来源:origin: neuland/jade4j
@Override
protected String convert(String source, List<Attr> attributes) {
return renderer.render(parser.parse(source));
}
代码示例来源:origin: jphp-group/jphp
@Signature
public void __construct(PMarkdownOptions options) {
renderer = HtmlRenderer.builder(options.getNativeOptions()).build();
parser = Parser.builder(options.getNativeOptions()).build();
}
代码示例来源:origin: vsch/flexmark-java
@Override
public boolean transferReferences(final MutableDataHolder document, final DataHolder included) {
if (document.contains(ENUMERATED_REFERENCES) && included.contains(ENUMERATED_REFERENCES)) {
return Parser.transferReferences(ENUMERATED_REFERENCES.getFrom(document), ENUMERATED_REFERENCES.getFrom(included), ENUMERATED_REFERENCES_KEEP.getFrom(document) == KeepType.FIRST);
}
return false;
}
代码示例来源: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: 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: com.centurylink.mdw/mdw-common
public static Parser getParser(MutableDataSet renderOptions) {
if (renderOptions == null)
return parser;
return Parser.builder(renderOptions).build();
}
代码示例来源:origin: vsch/flexmark-java
@Override
public boolean transferReferences(final MutableDataHolder document, final DataHolder included) {
if (document.contains(ZZZZZZS) && included.contains(ZZZZZZS)) {
return Parser.transferReferences(ZZZZZZS.getFrom(document), ZZZZZZS.getFrom(included), ZZZZZZS_KEEP.getFrom(document) == KeepType.FIRST);
}
return false;
}
代码示例来源: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.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: vsch/flexmark-java
@Override
public boolean transferReferences(final MutableDataHolder document, final DataHolder included) {
if (document.contains(FOOTNOTES) && included.contains(FOOTNOTES)) {
return Parser.transferReferences(FOOTNOTES.getFrom(document), FOOTNOTES.getFrom(included), FOOTNOTES_KEEP.getFrom(document) == KeepType.FIRST);
}
return false;
}
代码示例来源: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();
Node document = parser.parse(aText);
int count = 4;
int idx = 0;
代码示例来源: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
@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: vsch/flexmark-java
@Override
public boolean transferReferences(Document document, Document included) {
// transfer references from included to document
boolean transferred = false;
if (options.contains(EXTENSIONS)) {
for (Extension extension : options.get(EXTENSIONS)) {
if (extension instanceof ReferenceHoldingExtension) {
ReferenceHoldingExtension parserExtension = (ReferenceHoldingExtension) extension;
if (parserExtension.transferReferences(document, included)) transferred = true;
}
}
}
// transfer references
if (document.contains(REFERENCES) && included.contains(REFERENCES)) {
if (transferReferences(REFERENCES.getFrom(document), REFERENCES.getFrom(included), REFERENCES_KEEP.getFrom(document) == KeepType.FIRST)) {
transferred = true;
}
}
if (transferred) {
document.set(HtmlRenderer.RECHECK_UNDEFINED_REFERENCES, true);
}
return transferred;
}
代码示例来源: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));
}
}
内容来源于网络,如有侵权,请联系作者删除!