本文整理汇总了Java中com.vladsch.flexmark.ast.Document类的典型用法代码示例。如果您正苦于以下问题:Java Document类的具体用法?Java Document怎么用?Java Document使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Document类属于com.vladsch.flexmark.ast包,在下文中一共展示了Document类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: format
import com.vladsch.flexmark.ast.Document; //导入依赖的package包/类
private static String format(String input, int wrapLength) {
// parse markdown
Document document = Parser.builder().build().parse(input);
// format
List<Pair<Paragraph, String>> formattedParagraphs = new SmartFormat(null, null)
.formatParagraphs(document, wrapLength);
// build result
StringBuilder output = new StringBuilder(input);
for (int i = formattedParagraphs.size() - 1; i >= 0; i--) {
Pair<Paragraph, String> pair = formattedParagraphs.get(i);
Paragraph paragraph = pair.getFirst();
String newText = pair.getSecond();
int startOffset = paragraph.getStartOffset();
int endOffset = paragraph.getEndOffset();
if (paragraph.getChars().endsWith("\n"))
endOffset--;
output.replace(startOffset, endOffset, newText);
}
return output.toString();
}
示例2: test
import com.vladsch.flexmark.ast.Document; //导入依赖的package包/类
@Test
void test() throws IOException {
Parser p = Parser.builder().build();
Node document = p.parse("# Heading\n" +
"Paragraph with\n" +
"multiple lines and [link](example.com)");
AnnotatedTextBuildingVisitor visitor = new AnnotatedTextBuildingVisitor();
visitor.visit((Document) document);
AnnotatedText text = visitor.getText();
Assertions.assertEquals("Heading\nParagraph with multiple lines and link", text.getPlainText());
}
示例3: create
import com.vladsch.flexmark.ast.Document; //导入依赖的package包/类
@Override
public NodePostProcessor create(Document document) {
return new TwitterNodePostProcessor(document);
}
示例4: create
import com.vladsch.flexmark.ast.Document; //导入依赖的package包/类
@Override
public NodePostProcessor create(Document document) {
return new ButtonNodePostProcessor(document);
}
示例5: create
import com.vladsch.flexmark.ast.Document; //导入依赖的package包/类
@Override
public NodePostProcessor create(Document document) {
return new VideoLinkNodePostProcessor(document);
}
示例6: render
import com.vladsch.flexmark.ast.Document; //导入依赖的package包/类
public static String render(String source) {
Document document = parser.parse(source);
return renderer.render(document);
}
示例7: visit
import com.vladsch.flexmark.ast.Document; //导入依赖的package包/类
public void visit(Document node) {
visitChildren(node);
}
示例8: asHtml
import com.vladsch.flexmark.ast.Document; //导入依赖的package包/类
@Override
public String asHtml(RenderContext context, String markdown) {
Document document = (Document) parser.parse(markdown);
return renderer(context).render(document);
}