The extension provides a possibility to 'pretty-print' gherkin (files) (*.feature) to html or docbook/pdf.
The feature files get parsed by the extension and converted to asciidoc markdown which then is included into the document.
While I was able to produce a working solution by setting up an IncludeProcessor, I was wondering if there was a simple solution to do this in a *BlockProcessor*.
The block processor would have to return complex content (section with nested subsections and paragraphs etc) and not just a simple image or paragraph as in most extension examples.
For example, processing the following block:
Feature: A simple feature
Scenario: A simple scenario
Given a simple step
Then another simple step
should return a *section* block element corresponding to the following asciidoc source:
== A simple feature
=== A simple scenario
* Given a simple step
* The another simple step
Any hints how to do this (in Java) or where to find more information (not the gherkin parsing part, just the block creation stuff)? Thanks a lot.
I have not tried but I think you should do something like:
I think this is not going to be possible in Java yet. Because I have seen that you only can create Block, but not Section (which is also a Block),in Ruby implementation you will be able to do it but not in Java, so if you can open an issue I will address for next version :).
Maybe you can try something like return createBlock(parent, "section", Arrays.asList(upperLines), attributes, new HashMap<Object, Object>());
I don't necessarily see it as a bad thing that you need to append the section (either in source or AST form) manually and return nil. There are certain assumptions we make internally that a block-level processor is going to return a concrete block and not a section (an abstract block). Having said that, I do think it should be possible eventually. But until we've made the necessary changes, one of the two approaches I suggested are what you'll need to use in the interim.
This is obviously key information for the (planned) extension writing guide.
I'm super excited about the gherkin extension. I'd love to add that to the extensions-lab when it's ready!
On Wed, Sep 10, 2014 at 12:37 PM, asotobu [via Asciidoctor :: Discussion] <[hidden email]> wrote:
I think there is a bug in Asciidoctor. I am reviewing but if you return a Section in a block extension instead of a Block, next exception is thrown
org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `lines' for #<Asciidoctor::Section:0x26350ea2>
So now I am not sure if it will be possible to create a section inside a block.
I will keep you informed :)
If you reply to this email, your message will be added to the discussion below: