org.pegdown.ast.VerbatimNode Java Examples

The following examples show how to use org.pegdown.ast.VerbatimNode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlantUmlVerbatimSerializer.java    From protostuff-compiler with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #2
Source File: DocletSerializer.java    From markdown-doclet with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
    }
}