org.asciidoctor.extension.Reader Java Examples

The following examples show how to use org.asciidoctor.extension.Reader. 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: PillarsBlockProcessor.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 an empty block with context "pillars"
    Block block = this.createBlock(parent, "pillars",
            Collections.emptyList(), attributes, opts);
    return block;
}
 
Example #2
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 #3
Source File: YellBlockProcessor.java    From asciidoctorj with Apache License 2.0 5 votes vote down vote up
@Override
public Object process(                                 // <5>
        StructuralNode parent, Reader reader, Map<String, Object> attributes) {

    String content = reader.read();
    String yellContent = content.toUpperCase();

    return createBlock(parent, "paragraph", yellContent, attributes);
}
 
Example #4
Source File: WhenAsciidoctorLogsToConsole.java    From asciidoctorj with Apache License 2.0 5 votes vote down vote up
@Override
public Object process(StructuralNode parent, Reader reader, Map<String, Object> attributes) {
    log(new LogRecord(Severity.INFO, parent.getSourceLocation(), "Hello Log"));
    final List<String> strings = reader.readLines().stream()
            .map(String::toUpperCase)
            .collect(Collectors.toList());

    return createBlock(parent, "paragraph", strings);
}
 
Example #5
Source File: YellBlockProcessor.java    From asciidoctor-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public Object process(StructuralNode parent, Reader reader, Map<String, Object> attributes) {
    List<String> lines = reader.readLines();
    String upperLines = null;
    for (String line : lines) {
        if (upperLines == null) {
            upperLines = line.toUpperCase();
        } else {
            upperLines = upperLines + "\n" + line.toUpperCase();
        }
    }

    return createBlock(parent, "paragraph", Arrays.asList(upperLines), attributes, new HashMap<>());
}
 
Example #6
Source File: JRubyProcessor.java    From asciidoctorj with Apache License 2.0 4 votes vote down vote up
public Parser(Ruby runtime, StructuralNode parent, Reader reader) {
    super(runtime.getModule("Asciidoctor").getClass("Parser"));

    this.reader = reader;
    this.parent = parent;
}