本文整理汇总了Java中org.pegdown.ast.TextNode类的典型用法代码示例。如果您正苦于以下问题:Java TextNode类的具体用法?Java TextNode怎么用?Java TextNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TextNode类属于org.pegdown.ast包,在下文中一共展示了TextNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: f
import org.pegdown.ast.TextNode; //导入依赖的package包/类
@Override
public boolean f(TextNode p, Node parent, int index ) {
if( index != 0 ) return false;
if( "note:".equalsIgnoreCase(p.getText()) ) {
element = "note"; // SET ELEMENT TAG
return true;
}
if( "warning:".equalsIgnoreCase(p.getText()) ) {
element = "warning"; // SET ELEMENT TAG
return true;
}
if( "info:".equalsIgnoreCase(p.getText()) ) {
element = "info"; // SET ELEMENT TAG
return true;
}
if( "tip:".equalsIgnoreCase(p.getText()) ) {
element = "tip"; // SET ELEMENT TAG
return true;
}
return false;
}
示例2: visit
import org.pegdown.ast.TextNode; //导入依赖的package包/类
@Override
public void visit(final ExpImageNode ein) {
// We always have a URL, relative or not
final ArrayList<String> alt = new ArrayList<String>();
boolean found = findByClass(ein, TextNode.class, new FindPredicate<TextNode>() {
@Override
public boolean f(TextNode node, Node parent, int index) {
alt.add(node.getText());
return true;
}
});
if (!found) {
throw new IllegalStateException("The alt name should be mandatory in Markdown for images: " + ein.url);
}
String titlePart = isNotBlank(ein.title) ? format("|title=\"%s\"", ein.title) : "";
_buffer.append( format( "!%s|alt=\"%s\"%s!", ein.url, alt.get(0), titlePart));
}
示例3: BlockRule
import org.pegdown.ast.TextNode; //导入依赖的package包/类
Rule BlockRule() {
StringBuilderVar style = new StringBuilderVar();
StringBuilderVar body = new StringBuilderVar();
return NodeSequence(
StartMarker(),
Optional(
String("style="),
Sequence(OneOrMore(Letter()), style.append(match()), Spn1())),
Sequence(Body(), body.append(match())),
EndMarker(),
push(
new ExpImageNode("title",
createWebsequenceUrl(style.getString(), body.getString()),
new TextNode("")))
);
}
示例4: BlockRule
import org.pegdown.ast.TextNode; //导入依赖的package包/类
Rule BlockRule() {
ParamVar<String, String> params = new ParamVar<String, String>();
StringBuilderVar name = new StringBuilderVar();
StringBuilderVar value = new StringBuilderVar();
StringBuilderVar body = new StringBuilderVar();
return NodeSequence(
StartMarker(),
ZeroOrMore(
Sequence(
ParameterName(), name.append(match()),
String("="),
OneOrMore(Alphanumeric()), value.append(match())),
Sp(),
params.put(name.getString(), value.getString()),
name.clear(), value.clear()),
Body(),
body.append(match()),
EndMarker(),
push(
new ExpImageNode(
"title", createYumlUrl(params.get(), body.getString()), new TextNode("")))
);
}
示例5: process
import org.pegdown.ast.TextNode; //导入依赖的package包/类
@Override
public void process(int level, Node node, InvocationContext context) {
RefLinkNode refLink = (RefLinkNode) node;
@SuppressWarnings("unchecked")
TextNode text = (TextNode) lookupChild(refLink.referenceKey, TextNode.class);
if (text == null) {
log.warn("Unknown reference link structure... {}", refLink);
context.processChildren(level, node);
return;
}
References.Ref ref = context.references().lookup(text.getText());
if (ref != null) {
Node altNode = refLink.getChildren().get(0);
context.process(level, new ExpLinkNode(ref.title(), ref.url(), altNode));
return;
}
log.warn("Reference not found for link {}", text.getText());
}
示例6: process
import org.pegdown.ast.TextNode; //导入依赖的package包/类
@Override
public void process(int level, Node node, InvocationContext context) {
RefImageNode refImage = (RefImageNode) node;
@SuppressWarnings("unchecked")
TextNode text = (TextNode) lookupChild(refImage.referenceKey, TextNode.class);
if (text == null) {
log.warn("Unknown reference image structure... {}", refImage);
context.processChildren(level, node);
return;
}
References.Ref ref = context.references().lookup(text.getText());
if (ref != null) {
Node altNode = refImage.getChildren().get(0);
context.process(level, new ExpImageNode(ref.title(), ref.url(), altNode));
return;
}
log.warn("Reference not found for image {}", text.getText());
}
示例7: summary
import org.pegdown.ast.TextNode; //导入依赖的package包/类
public static String summary(final Node node) {
final List<String> tokens = new ArrayList<>();
tokens.add(typeCode(node));
if (node instanceof TextNode) {
tokens.add("'" + ((TextNode)node).getText() + "'");
}
if (node instanceof SuperNode) {
final List<Node> children = ((SuperNode)node).getChildren();
if (!children.isEmpty()) {
for (Node n : children) {
tokens.add(summary(n));
}
} else {
tokens.add("()");
}
}
return "(" + StringUtils.join(tokens, " ") + ")";
}
示例8: declareReference
import org.pegdown.ast.TextNode; //导入依赖的package包/类
private void declareReference(ReferenceNode node) {
TextNode text = (TextNode) node.getChildren().get(0).getChildren().get(0);
String title = node.getTitle();
String url = node.getUrl();
String key = text.getText();
Ref ref = new Ref(key, url, title);
references.put(key, ref);
}
示例9: process
import org.pegdown.ast.TextNode; //导入依赖的package包/类
@Override
public void process(int level, Node node, InvocationContext context) {
TextNode tNode = (TextNode) node;
RichText text = new RichText(tNode.getText(), context.peekFont());
ITextContext iTextContext = context.iTextContext();
iTextContext.emit(text);
}
示例10: visit
import org.pegdown.ast.TextNode; //导入依赖的package包/类
@Override
public void visit(TextNode text) {
Text elem =new Text(text.getText());
for(String style :this.styles){
elem.getStyleClass().add(style);
}
this.styles.clear();
this.parent.addChild(elem);
}
示例11: printChildren
import org.pegdown.ast.TextNode; //导入依赖的package包/类
private void printChildren(StringBuffer buff, ExpLinkNode node) {
//this is ugly as it can get, but again this parser is quite restricted
//so this is an adhoc method for printing links
if (node.getChildren().size() > 0 && node.getChildren().get(0).getChildren().size() >0){
Node textNode = node.getChildren().get(0).getChildren().get(0);
//she sells shells ...
if(textNode instanceof TextNode){
buff.append(((TextNode)textNode).getText());
}
}
}
示例12: collectChildrensText
import org.pegdown.ast.TextNode; //导入依赖的package包/类
@Override
public void collectChildrensText(SuperNode node, AnchorNodeInfo nodeInfo) {
for (Node child : node.getChildren()) {
// accumulate all the text
if (child instanceof TextNode) {
nodeInfo.text.append(((TextNode) child).getText());
if (nodeInfo.startIndex == 0) {
nodeInfo.startIndex = child.getStartIndex();
}
nodeInfo.endIndex = child.getEndIndex();
} else if (child instanceof SuperNode) {
collectChildrensText((SuperNode) child, nodeInfo);
}
}
}
示例13: visit
import org.pegdown.ast.TextNode; //导入依赖的package包/类
public void visit(final TextNode node) {
}
示例14: putEntry
import org.pegdown.ast.TextNode; //导入依赖的package包/类
/**
* Functions called from Serializer.
*
* @param node PegDown's TextNode node.
*/
void putEntry(final TextNode node) {
String text = node.getText();
putEntry(text);
currentBufPosition = node.getEndIndex();
}
示例15: printTag
import org.pegdown.ast.TextNode; //导入依赖的package包/类
@Override
protected void printTag(TextNode node, String tag) {
String pre = "";
String post = "";
switch (tag.toLowerCase()) {
case "b":
case "strong":
pre = post = "*";
break;
case "i":
case "em":
pre = post = "_";
break;
case "p":
post = "\n\n";
break;
case "br":
post = "\n";
break;
case "code":
pre = post = "`";
break;
case "pre":
pre = post = "```\n";
break;
case "blockquote":
pre = "> ";
break;
case "ul":
case "ol":
pre = post = "\n";
break;
case "li":
pre = " - ";
post = "\n";
break;
default:
// unsupported transform type
log.warn("Slack does not offer a markup substitute for tag {}", tag);
pre = String.format("<%s>", tag);
post = String.format("</%s>", tag);
}
printer.print(pre);
printer.printEncoded(node.getText());
printer.print(post);
}