Re: AsciidoctorJ Block Processing

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: AsciidoctorJ Block Processing

mojavelinux
Administrator
Sean,

This is an area of the code that Robert Panzer has been working on. He identified a problem whereby the config map was not properly synced between Java and the underlying Ruby runtime. Since then, he's taken steps to address it. I wonder if those changes fix your issue.

Keep in mind that in the long term, I'd like to get away from programmatically defining metadata (which is currently very crude) and instead use annotations. Annotations offer a much more concise and less complex way of configuring an extension. See my proposal at https://github.com/asciidoctor/asciidoctorj/issues/196.

Cheers,

-Dan

On Fri, May 8, 2015 at 3:31 PM, sean.osterberg [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hi guys, I'm writing a block processor and have been leaning heavily on the AsciidoctorJ examples to help me. After running into some issues, I've also been referring to these "docs" here: https://github.com/asciidoctor/asciidoctor-documentation/issues/30, which outline the content_model and contexts. I can't get the following to process properly, and I don't know why. Could you please tell me what I'm doing wrong? I think the docs need to be updated, and I'm happy to make a contribution once I figure out what's going on here.

Here's my version of the YellBlock processor. I've tried multiple combinations of contexts and content_models, but this seems the most logical given the issue I linked above:

public class YellBlock extends BlockProcessor {
    private final Asciidoctor asciidoctor;

    private static Map<String, Object> configs = new HashMap<String, Object>();

    static {
        configs.put("contexts", Arrays.asList(":listing"));
        configs.put("content_models", ":compound");
    }

    public YellBlock(String name, Asciidoctor asciidoctor) {
        super(name, configs);
        this.asciidoctor = asciidoctor;
    }

    @Override
    public Object process(AbstractBlock 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<Object, Object>());
    }
}

And here is the sample file that's not getting processed correctly:

= Tabs test

this page is an example of tabs

[[tabs]]
----
Make this text uppercase.
----

My ultimate goal, however, is to process tabs in the following manner, so any guidance is welcome:

[[tabs]]
----
[tab,title="Foo"]
....
This is the foo tab
....
[tab,title="Bar"]
....
This is the bar tab
....
----



If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/AsciidoctorJ-Block-Processing-tp3150.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--