本文整理匯總了Java中org.pegdown.PegDownProcessor.parseMarkdown方法的典型用法代碼示例。如果您正苦於以下問題:Java PegDownProcessor.parseMarkdown方法的具體用法?Java PegDownProcessor.parseMarkdown怎麽用?Java PegDownProcessor.parseMarkdown使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.pegdown.PegDownProcessor
的用法示例。
在下文中一共展示了PegDownProcessor.parseMarkdown方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: check
import org.pegdown.PegDownProcessor; //導入方法依賴的package包/類
private void check(PegDownPlugins.Builder extraPluginsBuilder, String markdown, String expectedAst) {
Reference<Parser> parserRef = new Reference<Parser>();
PegDownPlugins plugins =
(extraPluginsBuilder == null ? PegDownPlugins.builder() : extraPluginsBuilder)
.withPlugin(GenericBoxPlugin.class, parserRef)
.build();
// ---
PegDownProcessor processor = new PegDownProcessor(Extensions.ALL, plugins);
parserRef.set(processor.parser);
RootNode rootNode = processor.parseMarkdown(normalize(markdown).toCharArray());
String s = dumpAST(rootNode);
System.out.println("GenericBoxPluginTest.check::" + s);
assertThat(normalize(s.trim())).isEqualTo(normalize(expectedAst));
}
示例2: check
import org.pegdown.PegDownProcessor; //導入方法依賴的package包/類
private void check(String markdown, String expectedAst) {
Reference<Parser> parserRef = new Reference<Parser>();
PegDownPlugins plugins =
PegDownPlugins.builder()
.withPlugin(LinkContentPlugin.class, parserRef)
.build();
// ---
PegDownProcessor processor = new PegDownProcessor(Extensions.ALL, plugins);
parserRef.set(processor.parser);
RootNode rootNode = processor.parseMarkdown(normalize(markdown).toCharArray());
String s = dumpAST(rootNode);
assertThat(normalize(s.trim())).isEqualTo(normalize(expectedAst));
}
示例3: attributesPlugin
import org.pegdown.PegDownProcessor; //導入方法依賴的package包/類
@Theory
public void attributesPlugin(@ForAll @InRange(minInt = 0, maxInt = 0x0000FFFF) int extensions) throws IOException {
String mkd = loadResource("attributesText-simple.md").trim();
String ast = loadResource("attributesText-simple.ast").trim();
PegDownPlugins plugins = PegDownPlugins
.builder()
.withPlugin(AttributesPlugin.class)
.build();
PegDownProcessor processor = new PegDownProcessor(extensions, plugins);
RootNode rootNode = processor.parseMarkdown(normalize(mkd).toCharArray());
String s = dumpAST(rootNode);
assertThat(normalize(s.trim())).isEqualTo(normalize(ast));
}
示例4: astBuild_simpleCase
import org.pegdown.PegDownProcessor; //導入方法依賴的package包/類
@Test
public void astBuild_simpleCase() throws IOException {
String mkd = loadResource("attributesText-simple.md").trim();
String ast = loadResource("attributesText-simple.ast").trim();
PegDownPlugins plugins = PegDownPlugins
.builder()
.withPlugin(AttributesPlugin.class)
.build();
PegDownProcessor processor = new PegDownProcessor(Extensions.ALL, plugins);
RootNode rootNode = processor.parseMarkdown(normalize(mkd).toCharArray());
String s = dumpAST(rootNode);
assertThat(normalize(s.trim())).isEqualTo(normalize(ast));
}
示例5: astBuild_advancedCase
import org.pegdown.PegDownProcessor; //導入方法依賴的package包/類
@Test
public void astBuild_advancedCase() throws IOException {
String mkd = loadResource("attributesText.md").trim();
String ast = loadResource("attributesText.ast").trim();
PegDownPlugins plugins = PegDownPlugins
.builder()
.withPlugin(AttributesPlugin.class)
.build();
PegDownProcessor processor = new PegDownProcessor(Extensions.ALL, plugins);
RootNode rootNode = processor.parseMarkdown(normalize(mkd).toCharArray());
String s = dumpAST(rootNode);
assertThat(normalize(s.trim())).isEqualTo(normalize(ast));
}
示例6: processString
import org.pegdown.PegDownProcessor; //導入方法依賴的package包/類
private void processString(String usecase, String mkd, Function<InvocationContext, InvocationContext> customizer) throws Exception {
Reference<Parser> parserRef = new Reference<Parser>();
ITextContext iTextContext = openDocument(usecase);
PegDownPlugins plugins = PegDownPlugins
.builder()
.withPlugin(AttributesPlugin.class)
.withPlugin(GenericBoxPlugin.class, parserRef)
.build();
PegDownProcessor processor = new PegDownProcessor(Extensions.ALL, plugins);
parserRef.set(processor.parser);
RootNode rootNode = processor.parseMarkdown(mkd.toCharArray());
InvocationContext context = customizer.apply(new InvocationContext(iTextContext));
if (context == null) {
fail("No context");
return;
}
context.process(0, rootNode);
context.flushPendingChapter();
iTextContext.close();
}
示例7: process
import org.pegdown.PegDownProcessor; //導入方法依賴的package包/類
private void process(final char[] article) throws IOException, TranslationException {
handler = new EntryHandler(this, article);
MarkdownSerializer serializer = new MarkdownSerializer(handler);
PegDownProcessor processor = new PegDownProcessor(PARSER_OPTION);
astRoot = processor.parseMarkdown(article);
checkArgNotNull(astRoot, "astRoot");
astRoot.accept(serializer);
// If handler has a exception when process, finish() throws TranslationException
handler.finish();
}
示例8: test
import org.pegdown.PegDownProcessor; //導入方法依賴的package包/類
@Test
public void test() throws IOException {
try {
PegDownProcessor processor = new PegDownProcessor(Extensions.FENCED_CODE_BLOCKS);
RootNode rootNode = processor.parseMarkdown(FileUtils.readFileToString(new File("README.tmpl.md")).toCharArray());
rootNode.accept(new DocTestingVisitor());
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
示例9: dumpAST
import org.pegdown.PegDownProcessor; //導入方法依賴的package包/類
@Test
@Parameters({
"astText.md, astText.ast",
})
public void dumpAST(String mkdSrc, String astSrc) throws IOException {
String mkd = loadResource(mkdSrc).trim();
String ast = loadResource(astSrc).trim();
PegDownProcessor processor = new PegDownProcessor(Extensions.ALL);
RootNode rootNode = processor.parseMarkdown(normalize(mkd).toCharArray());
String s = dumpAST(rootNode);
assertThat(normalize(s.trim())).isEqualTo(normalize(ast));
}
示例10: table_multi_line_cell
import org.pegdown.PegDownProcessor; //導入方法依賴的package包/類
@Test
@Ignore("Multiline cell not supported")
public void table_multi_line_cell() throws Exception {
String mkd = loadResource("table-multiline-cells.md").trim();
String ast = loadResource("table-multiline-cells.ast").trim();
PegDownProcessor processor = new PegDownProcessor(Extensions.ALL);
RootNode rootNode = processor.parseMarkdown(mkd.toCharArray());
String s = dumpAST(rootNode);
assertThat(normalize(s.trim())).isEqualTo(normalize(ast));
}
示例11: table1AST__with_caption_column_alignment_colspan
import org.pegdown.PegDownProcessor; //導入方法依賴的package包/類
@Test
public void table1AST__with_caption_column_alignment_colspan() throws Exception {
String mkd = loadResource("table1.md").trim();
String ast = loadResource("table1.ast").trim();
PegDownProcessor processor = new PegDownProcessor(Extensions.ALL);
RootNode rootNode = processor.parseMarkdown(normalize(mkd).toCharArray());
String s = new Dumper(normalize(mkd)).dump(rootNode).out.toString();
assertThat(normalize(s.trim())).isEqualTo(normalize(ast));
}
示例12: line_break_within_paragraph
import org.pegdown.PegDownProcessor; //導入方法依賴的package包/類
@Test
public void line_break_within_paragraph() throws Exception {
String mkd = "" +
"Two empty space at the end of the line \n" +
"should act as a new line in the paragraph\n" +
"\n" +
"This should be an other paragraph...\n" +
"but with no space at the end of the line\n" +
"\n" +
"\n" +
"And yet another one";
PegDownProcessor processor = new PegDownProcessor(Extensions.ALL);
RootNode rootNode = processor.parseMarkdown(normalize(mkd).toCharArray());
String s = new Dumper(normalize(mkd)).dump(rootNode).out.toString();
assertThat(normalize(s.trim())).isEqualTo(normalize("" +
"RootNode [0-185]\n" +
" ParaNode [0-84]\n" +
" SuperNode [0-82]\n" +
" TextNode [0-38] 'Two empty space at the end of the line'\n" +
" SimpleNode [38-41] Linebreak\n" +
" TextNode [41-82] 'should act as a new line in the paragraph'\n" +
" ParaNode [84-164]\n" +
" SuperNode [84-161]\n" +
" TextNode [84-117] 'This should be an other paragraph'\n" +
" SimpleNode [117-120] Ellipsis\n" +
" SimpleNode [120-121] Linebreak\n" +
" TextNode [121-161] 'but with no space at the end of the line'\n" +
" ParaNode [164-185]\n" +
" SuperNode [164-183]\n" +
" TextNode [164-183] 'And yet another one'"));
}
示例13: parseMarkdown
import org.pegdown.PegDownProcessor; //導入方法依賴的package包/類
private RootNode parseMarkdown(String resourcePath) throws IOException {
String mkd = loadResource(resourcePath).trim();
PegDownPlugins plugins = PegDownPlugins
.builder()
.withPlugin(AttributesPlugin.class)
.build();
PegDownProcessor processor = new PegDownProcessor(Extensions.ALL, plugins);
return processor.parseMarkdown(mkd.toCharArray());
}
示例14: usecase__sibling_then_of_type
import org.pegdown.PegDownProcessor; //導入方法依賴的package包/類
@Test
@SuppressWarnings("unchecked")
public void usecase__sibling_then_of_type() throws Exception {
String mkd = loadResource("image-04-ref.md").trim();
PegDownPlugins plugins = PegDownPlugins
.builder()
.withPlugin(AttributesPlugin.class)
.build();
PegDownProcessor processor = new PegDownProcessor(Extensions.ALL, plugins);
RootNode rootNode = processor.parseMarkdown(mkd.toCharArray());
TreeNavigation nav;
nav = new TreeNavigation();
nav.push(rootNode);
nav.pushChild(3);
assertThat(nav.peek()).isInstanceOf(ParaNode.class);
//
//
Optional<TreeNavigation> result =
siblingBefore()
.then(ofType(AttributesNode.class))
.query(nav);
assertThat(result.isPresent()).isTrue();
assertThat(result.get().peek()).isInstanceOf(AttributesNode.class);
}
示例15: makeHelpText
import org.pegdown.PegDownProcessor; //導入方法依賴的package包/類
private void makeHelpText(ScriptFieldAnswer answer, Pane parent) {
TextFlow flow = new TextFlow();
DataType fieldDataType = answer.getField().getDataType();
if (fieldDataType instanceof DataType.Enumeration) {
StringBuilder b = new StringBuilder();
String last = "";
for (String v : ((DataType.Enumeration)fieldDataType).getValues()) {
if (b.length() > 0) {
b.append(", ");
}
b.append(last);
last = v;
}
if (b.length() > 0) {
b.append(" or ");
}
b.append(last);
getJavaFxParent(flow).addChild(new Text("Possible values: " + b + "\n"));
}
MarkdownToJavafx mdToFx = new MarkdownToJavafx(this.getJavaFxParent(flow));
PegDownProcessor mdProcessor = new PegDownProcessor(Extensions.FENCED_CODE_BLOCKS);
if (answer.getField().getDescription() != null) {
RootNode node = mdProcessor.parseMarkdown(answer.getField().getDescription().toCharArray());
node.accept(mdToFx);
}
parent.getChildren().add(flow);
flow.setMaxWidth(350);
//helpText = helpText.trim();
//helpText.replace('\n', ' ');
//helpText.replace('\t', ' ');
//Text help = new Text(answer.getField().getDescription());
//RootNode node = mdProcessor.parseMarkdown(answer.getField().getDescription().toCharArray());
////help.getStyleClass().add("help");
//return help;
}