Java Code Examples for org.asciidoctor.ast.Block#getContent()

The following examples show how to use org.asciidoctor.ast.Block#getContent() . 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: CardBlockProcessor.java    From helidon-build-tools with Apache License 2.0 5 votes vote down vote up
@Override
public Object process(StructuralNode parent,
                      Reader reader,
                      Map<String, Object> attributes) {

    Map<Object, Object> opts = new HashMap<>();
    // means it can have nested blocks
    opts.put("content_model", "compound");

    // create a block with context "card", and put the parsed content into it
    Block block = this.createBlock(parent, "card", reader.readLines(),
            attributes, opts);

    // if the link attribute is present
    // add a link into the content with a marker as text
    String link = (String) attributes.get("link");
    if (link != null) {
        String linkPhrase;
        String linkType = (String) attributes.get("link-type");
        if (linkType == null || linkType.equals("xref")) {
            linkPhrase = "<<" + link + "," + BLOCKLINK_TEXT + ">>";
        } else if (linkType.equals("url")) {
            linkPhrase = "link:" + link + "[" + BLOCKLINK_TEXT + "]";
        } else {
            linkPhrase = null;
            LOGGER.warning(link);
        }
        if (linkPhrase != null){
            parseContent(block, Arrays.asList(linkPhrase));
            // trigger rendering for the nested content here to trigger the
            // converter so that the converter can catch the generated
            // phrase node and add it as an attribute named _link to the
            // block
            block.getContent();
        }
    }
    return block;
}
 
Example 2
Source File: OrderDocumentingHighlighter.java    From asciidoctorj with Apache License 2.0 5 votes vote down vote up
@Override
public String format(Block node, String lang, Map<String, Object> opts) {
    messages.add("format `" + lang + "`");
    return "<pre class='highlight'><code>"
        + node.getContent()
        + "</code></pre>";
}
 
Example 3
Source File: HighlightJsWithLanguageHighlighter.java    From asciidoctorj with Apache License 2.0 4 votes vote down vote up
@Override
public String format(Block node, String lang, Map<String, Object> opts) {
    return "<pre class='highlight'><code class='" + lang + "'>" // <2>
        + node.getContent()                                     // <3>
        + "</code></pre>";
}
 
Example 4
Source File: PrismJsHighlighter.java    From asciidoctorj with Apache License 2.0 4 votes vote down vote up
@Override
public String format(Block node, String lang, Map<String, Object> opts) {
    return "<pre class='highlight'><code>"  // <3>
        + node.getContent()
        + "</code></pre>";
}
 
Example 5
Source File: HighlightJsWithOfflineStylesHighlighter.java    From asciidoctorj with Apache License 2.0 4 votes vote down vote up
@Override
public String format(Block node, String lang, Map<String, Object> opts) {
    return "<pre class='highlight'><code class='" + lang + "'>"
        + node.getContent()
        + "</code></pre>";
}