org.asciidoctor.ast.PhraseNode Java Examples

The following examples show how to use org.asciidoctor.ast.PhraseNode. 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: Helper.java    From helidon-build-tools with Apache License 2.0 6 votes vote down vote up
/**
 * Create a new link helper.
 * @param node the node representing the link
 * @return the link helper or {@code null} if the provided node is
 * {@code null}
 */
@SuppressWarnings("unchecked")
public Link link(PhraseNode node){
    if (node == null) {
        return null;
    }
    Map<String, Object> docAttrs = node.getDocument().getAttributes();
    Map<String, Object> nodeAttrs = node.getAttributes();
    return new Link((Map<String, Page>) docAttrs.get("pages"),
            (Page) docAttrs.get("page"), node.getType(),
            (String) nodeAttrs.get("path"),
            (String) nodeAttrs.get("refid"),
            (String) nodeAttrs.get("fragment"),
            node.getTarget(),
            (String) nodeAttrs.get("title"),
            node.getText(), node.getId(),
            (String) nodeAttrs.get("window"));
}
 
Example #2
Source File: JRubyProcessor.java    From asciidoctorj with Apache License 2.0 6 votes vote down vote up
@Override
public PhraseNode createPhraseNode(ContentNode parent, String context, String text, Map<String, Object> attributes, Map<String, Object> options) {

    Ruby rubyRuntime = JRubyRuntimeContext.get(parent);

    options.put(Options.ATTRIBUTES, RubyHashUtil.convertMapToRubyHashWithStrings(rubyRuntime, attributes));

    RubyHash convertedOptions = RubyHashUtil.convertMapToRubyHashWithSymbols(rubyRuntime, options);

    IRubyObject[] parameters = {
            ((ContentNodeImpl) parent).getRubyObject(),
            RubyUtils.toSymbol(rubyRuntime, context),
            text == null ? rubyRuntime.getNil() : rubyRuntime.newString(text),
            convertedOptions};
    return (PhraseNode) NodeConverter.createASTNode(rubyRuntime, NodeConverter.NodeType.INLINE_CLASS, parameters);
}
 
Example #3
Source File: JRubyProcessor.java    From asciidoctorj with Apache License 2.0 6 votes vote down vote up
@Override
public PhraseNode createPhraseNode(ContentNode parent, String context, List<String> text, Map<String, Object> attributes, Map<Object, Object> options) {

    Ruby rubyRuntime = JRubyRuntimeContext.get(parent);

    options.put(Options.ATTRIBUTES, attributes);

    RubyHash convertMapToRubyHashWithSymbols = RubyHashUtil.convertMapToRubyHashWithSymbolsIfNecessary(rubyRuntime,
            options);

    RubyArray rubyText = rubyRuntime.newArray();
    rubyText.addAll(text);

    IRubyObject[] parameters = {
            ((ContentNodeImpl) parent).getRubyObject(),
            RubyUtils.toSymbol(rubyRuntime, context),
            rubyText,
            convertMapToRubyHashWithSymbols};
    return (PhraseNode) NodeConverter.createASTNode(rubyRuntime, NodeConverter.NodeType.INLINE_CLASS, parameters);
}
 
Example #4
Source File: AsciidocConverter.java    From helidon-build-tools with Apache License 2.0 5 votes vote down vote up
@Override
public String convert(ContentNode node,
                      String transform,
                      Map<Object, Object> opts) {

    if (node != null && node.getNodeName() != null) {
        String templateName;
        if (node.equals(node.getDocument())) {
            templateName = "document";
        } else if (node.isBlock()) {
            templateName = "block_" + node.getNodeName();
        } else {
            // detect phrase node for generated block links
            if (node.getNodeName().equals("inline_anchor")
                    && BLOCKLINK_TEXT.equals(((PhraseNode) node).getText())) {
                // store the link model as an attribute in the corresponding
                // block
                node.getParent().getParent().getAttributes()
                        .put("_link", (PhraseNode) node);
                // the template for the block is responsible for rendering
                // the link, discard the output
                return "";
            }
            templateName = node.getNodeName();
        }
        LOGGER.debug("Rendering node: {}", node);
        return templateEngine.renderString(templateName, node);
    } else {
        return "";
    }
}
 
Example #5
Source File: JRubyProcessor.java    From asciidoctorj with Apache License 2.0 4 votes vote down vote up
@Override
public PhraseNode createPhraseNode(ContentNode parent, String context, String text, Map<String, Object> attributes) {
    return createPhraseNode(parent, context, text, attributes, new HashMap<>());
}
 
Example #6
Source File: JRubyProcessor.java    From asciidoctorj with Apache License 2.0 4 votes vote down vote up
@Override
public PhraseNode createPhraseNode(ContentNode parent, String context, String text) {
    return createPhraseNode(parent, context, text, new HashMap<>());
}
 
Example #7
Source File: JRubyProcessor.java    From asciidoctorj with Apache License 2.0 4 votes vote down vote up
@Override
public PhraseNode createPhraseNode(ContentNode parent, String context, List<String> text, Map<String, Object> attributes) {
    return createPhraseNode(parent, context, text, attributes, new HashMap<>());
}
 
Example #8
Source File: JRubyProcessor.java    From asciidoctorj with Apache License 2.0 4 votes vote down vote up
@Override
public PhraseNode createPhraseNode(ContentNode parent, String context, List<String> text) {
    return createPhraseNode(parent, context, text, new HashMap<>());
}
 
Example #9
Source File: BaseProcessor.java    From asciidoctorj with Apache License 2.0 4 votes vote down vote up
@Override
public PhraseNode createPhraseNode(ContentNode parent, String context, String text, Map<String, Object> attributes) {
    return createPhraseNode(parent, context, text, attributes, new HashMap<>());
}
 
Example #10
Source File: BaseProcessor.java    From asciidoctorj with Apache License 2.0 4 votes vote down vote up
@Override
public PhraseNode createPhraseNode(ContentNode parent, String context, String text) {
    return createPhraseNode(parent, context, text, new HashMap<>());
}
 
Example #11
Source File: BaseProcessor.java    From asciidoctorj with Apache License 2.0 4 votes vote down vote up
@Override
public PhraseNode createPhraseNode(ContentNode parent, String context, List<String> text, Map<String, Object> attributes) {
    return createPhraseNode(parent, context, text, attributes, new HashMap<>());
}
 
Example #12
Source File: BaseProcessor.java    From asciidoctorj with Apache License 2.0 4 votes vote down vote up
@Override
public PhraseNode createPhraseNode(ContentNode parent, String context, List<String> text) {
    return createPhraseNode(parent, context, text, new HashMap<>());
}
 
Example #13
Source File: BaseProcessor.java    From asciidoctorj with Apache License 2.0 4 votes vote down vote up
@Override
public PhraseNode createPhraseNode(ContentNode parent, String context, String text, Map<String, Object> attributes, Map<String, Object> options) {
    return delegate.createPhraseNode(parent, context, text, attributes, options);
}
 
Example #14
Source File: BaseProcessor.java    From asciidoctorj with Apache License 2.0 4 votes vote down vote up
@Override
public PhraseNode createPhraseNode(ContentNode parent, String context, List<String> text, Map<String, Object> attributes, Map<Object, Object> options) {
    return delegate.createPhraseNode(parent, context, text, attributes, options);
}
 
Example #15
Source File: Processor.java    From asciidoctorj with Apache License 2.0 votes vote down vote up
PhraseNode createPhraseNode(ContentNode parent, String context, List<String> text); 
Example #16
Source File: Processor.java    From asciidoctorj with Apache License 2.0 votes vote down vote up
PhraseNode createPhraseNode(ContentNode parent, String context, List<String> text, Map<String, Object> attributes); 
Example #17
Source File: Processor.java    From asciidoctorj with Apache License 2.0 votes vote down vote up
PhraseNode createPhraseNode(ContentNode parent, String context, List<String> text, Map<String, Object> attributes, Map<Object, Object> options); 
Example #18
Source File: Processor.java    From asciidoctorj with Apache License 2.0 votes vote down vote up
PhraseNode createPhraseNode(ContentNode parent, String context, String text); 
Example #19
Source File: Processor.java    From asciidoctorj with Apache License 2.0 votes vote down vote up
PhraseNode createPhraseNode(ContentNode parent, String context, String text, Map<String, Object> attributes); 
Example #20
Source File: Processor.java    From asciidoctorj with Apache License 2.0 votes vote down vote up
PhraseNode createPhraseNode(ContentNode parent, String context, String text, Map<String, Object> attributes, Map<String, Object> options);