本文整理汇总了Java中com.vladsch.flexmark.ast.util.TextCollectingVisitor类的典型用法代码示例。如果您正苦于以下问题:Java TextCollectingVisitor类的具体用法?Java TextCollectingVisitor怎么用?Java TextCollectingVisitor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TextCollectingVisitor类属于com.vladsch.flexmark.ast.util包,在下文中一共展示了TextCollectingVisitor类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertToText
import com.vladsch.flexmark.ast.util.TextCollectingVisitor; //导入依赖的package包/类
public String convertToText(String markdown){
TextCollectingVisitor textCollectingVisitor = new TextCollectingVisitor();
return textCollectingVisitor.collectAndGetText(markdownParser.parse(markdown));
}
示例2: create
import com.vladsch.flexmark.ast.util.TextCollectingVisitor; //导入依赖的package包/类
@Override
public NodeRenderer create(DataHolder options) {
return new NodeRenderer() {
@Override
public Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() {
HashSet<NodeRenderingHandler<?>> set = new HashSet<>();
set.add(new NodeRenderingHandler<>(Image.class, new CustomNodeRenderer<Image>() {
@Override
public void render(Image node, NodeRendererContext context, HtmlWriter html) {
if (!context.isDoNotRenderLinks()) {
String altText = new TextCollectingVisitor().collectAndGetText(node);
ResolvedLink resolvedLink = context.resolveLink(LinkType.IMAGE, node.getUrl().unescape(), null);
String url = resolvedLink.getUrl();
if (!node.getUrlContent().isEmpty()) {
// reverse URL encoding of =, &
String content = Escaping.percentEncodeUrl(node.getUrlContent()).replace("+", "%2B").replace("%3D", "=").replace("%26", "&");
url += content;
}
final int index = url.indexOf('@');
if (index >= 0) {
String[] dimensions = url.substring(index + 1, url.length()).split("\\|");
url = url.substring(0, index);
if (dimensions.length == 2) {
String width = TextUtils.isEmpty(dimensions[0]) ? "auto" : dimensions[0];
String height = TextUtils.isEmpty(dimensions[1]) ? "auto" : dimensions[1];
html.attr("style", "width: " + width + "; height: " + height);
}
}
html.attr("src", url);
html.attr("alt", altText);
if (node.getTitle().isNotNull()) {
html.attr("title", node.getTitle().unescape());
}
html.srcPos(node.getChars()).withAttr(resolvedLink).tagVoid("img");
}
}
}));
return set;
}
};
}