本文整理汇总了Java中org.pegdown.ast.VerbatimNode类的典型用法代码示例。如果您正苦于以下问题:Java VerbatimNode类的具体用法?Java VerbatimNode怎么用?Java VerbatimNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VerbatimNode类属于org.pegdown.ast包,在下文中一共展示了VerbatimNode类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serialize
import org.pegdown.ast.VerbatimNode; //导入依赖的package包/类
@Override
public void serialize(final VerbatimNode node, final Printer printer) {
printer.println().print("<pre><code");
String className = "prettyprint";
if (!StringUtils.isEmpty(node.getType())) {
className = className.concat(" " + node.getType());
}
printAttribute(printer, "class", className);
printer.print(">");
String text = node.getText();
// print HTML breaks for all initial newlines
while (text.charAt(0) == '\n') {
printer.print("<br/>");
text = text.substring(1);
}
printer.printEncoded(text);
printer.print("</code></pre>");
}
示例2: visit
import org.pegdown.ast.VerbatimNode; //导入依赖的package包/类
@Override
public void visit(VerbatimNode vn) {
final String lines[] = vn.getText().split("\n");
if( lines.length == 1 ) {
_buffer.append( "\n{noformat}")
.append(vn.getText())
.append( "{noformat}\n\n");
return;
}
if( vn.getType()==null || vn.getType().isEmpty() ) {
_buffer.append( "\n{noformat}\n")
.append(vn.getText())
.append("\n{noformat}\n\n")
;
return;
}
_buffer.append( format("\n{code:%s}\n", vn.getType()) )
.append(vn.getText())
.append("\n{code}\n\n")
;
}
示例3: serialize
import org.pegdown.ast.VerbatimNode; //导入依赖的package包/类
@Override
public void serialize(VerbatimNode node, Printer printer) {
Type type = Type.getByName(node.getType());
String formatted = type.wrap(node.getText());
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
SourceStringReader reader = new SourceStringReader(formatted);
String desc;
try {
desc = reader.generateImage(baos, type.getFormatOption());
} catch (IOException e) {
throw new GeneratorException("Could not generate uml for node " + node, e);
}
final String rendered = type.render(baos.toByteArray(), desc);
printer.print(rendered);
}
示例4: serialize
import org.pegdown.ast.VerbatimNode; //导入依赖的package包/类
@Override
public void serialize(final VerbatimNode node, final Printer printer) {
printer.println().print("<pre><code");
// if (!StringUtils.isEmpty(node.getType())) {
// printAttribute(printer, "class", node.getType());
// }
printer.print(">");
String text = node.getText();
// print HTML breaks for all initial newlines
while (text.charAt(0) == '\n') {
printer.print("<br/>");
text = text.substring(1);
}
printer.printEncoded(text);
printer.print("</code></pre>");
}
示例5: process
import org.pegdown.ast.VerbatimNode; //导入依赖的package包/类
@Override
public void process(int level, Node node, InvocationContext context) {
VerbatimNode vNode = (VerbatimNode) node;
SourceCode code = convertToSourceCode(vNode);
Attributes attributes = context.peekAttributes(level);
applyAttributes(code, attributes);
ITextContext iTextContext = context.iTextContext();
List<Element> elements = iTextContext.emitButCollectElements(code);
for (Element element : elements) {
ITextUtils.applyAttributes(element, attributes);
context.append(element);
}
}
示例6: visit
import org.pegdown.ast.VerbatimNode; //导入依赖的package包/类
/**
* Accept verbatim node.
* <p>
* put literals to translation entry.
* @param node verbatim node.
*/
@Override
public void visit(final VerbatimNode node) {
int start = node.getStartIndex();
if (handler.getChars(start, 3).equals("```")) {
if (!handler.getChars(start + 3, 1).equals("\n")) {
// github favored fenced code with language name.
int langEnd = handler.findFirst(start + 3, '\n');
if (langEnd > 0 && langEnd > start) {
String lang = handler.getChars(start + 3, langEnd - start - 3);
handler.startFenced(start, lang);
handler.putEntry(node);
handler.endFenced();
} else {
handler.throwTranslationException();
}
} else {
handler.startFenced(start, "");
handler.putEntry(node);
handler.endFenced();
}
} else {
handler.startVerbatim(start);
handler.putEntry(node);
handler.endVerbatim();
}
}
示例7: visit
import org.pegdown.ast.VerbatimNode; //导入依赖的package包/类
@Override
public void visit(VerbatimNode verbatim) {
Text elem =new Text(verbatim.getText());
elem.getStyleClass().add("code");
Text newline = new Text("\n");
this.parent.addChild(elem);
this.parent.addChild(newline);
}
示例8: visit
import org.pegdown.ast.VerbatimNode; //导入依赖的package包/类
@Override
public void visit(@NotNull VerbatimNode node) {
if ("dollar".equals(node.getType())) {
try {
new DollarParserImpl(new ParserOptions()).parse(
new ScriptScope(node.getText(), "(markdown)", true, false), node.getText());
} catch (Exception e) {
throw new DollarException(e, node.getText());
}
}
}
示例9: visit
import org.pegdown.ast.VerbatimNode; //导入依赖的package包/类
/**
* Overrides the default implementation to set the language to "no-highlight" no
* language is specified. If highlighting is disabled or auto-highlighting is enabled,
* this method just calls the default implementation.
*
* @param node The AST node.
*/
@Override
public void visit(VerbatimNode node) {
if ( options.isHighlightEnabled() && !options.isAutoHighlightEnabled() && node.getType().isEmpty() ) {
VerbatimNode noHighlightNode = new VerbatimNode(node.getText(), "no-highlight");
noHighlightNode.setStartIndex(node.getStartIndex());
noHighlightNode.setEndIndex(node.getEndIndex());
super.visit(noHighlightNode);
}
else {
super.visit(node);
}
}
示例10: visit
import org.pegdown.ast.VerbatimNode; //导入依赖的package包/类
public void visit(final VerbatimNode node) {
}
示例11: f
import org.pegdown.ast.VerbatimNode; //导入依赖的package包/类
@Override
public void f(VerbatimNode node) {
System.out.printf( " text=[%s], type=[%s]", node.getText(), node.getType());
}
示例12: convertToSourceCode
import org.pegdown.ast.VerbatimNode; //导入依赖的package包/类
private SourceCode convertToSourceCode(VerbatimNode vNode) {
String lang = vNode.getType();
String content = vNode.getText();
return new SourceCode(lang, content);
}
示例13: visit
import org.pegdown.ast.VerbatimNode; //导入依赖的package包/类
@Override public void visit(VerbatimNode node) {
//To change body of implemented methods use File | Settings | File Templates.
}