My first extension based on "83.5. Block Processor Example"

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

My first extension based on "83.5. Block Processor Example"

DrAscii
This post was updated on .
Hi guys,

I started with AsciiDoc(tor) a few days ago. My problem: I have zero ruby skills so I need help with my first little extension.

What I do right know

Without the extension I write often something like this:

[.feature]
--
*Feature*

abc

123
--

What I would like to have

[feature]
abc
+
123

(This should lead to the same HTML as my current workaround.)

What I found so far

After reading the manual I think the chapter 83.5 Block Processor Example is the part I'm looking for. But I have no idea how to adapt the code to my needs and get it running. Maybe you can add another example based on my request to the manual? I think other people are looking for similar things.

Thanks!

Best regards
DrAscii
Reply | Threaded
Open this post in threaded view
|

Re: My first extension based on "83.5. Block Processor Example"

mojavelinux
Administrator
In order to support blank lines in the content, you must enclose the lines in a block (it could be an open block or some other block). So the closest thing you can have is:

[feature]
--
abc

123
--

That would be implemented as something like:

Asciidoctor::Extensions.register do
  block :feature do
    on_context :open
    process do |parent, reader, attrs|
      # magic goes here
    end
  end
end

If you are okay with:

[feature]
abc
{blank}
123

Then you could use on_context: :paragraph

The continuation line is only relevant for lists.

Cheers,

-Dan

On Sat, Feb 29, 2020 at 9:49 AM DrAscii [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hi guys,

I started with AsciiDoc(tor) a few days ago. My problem: I have zero ruby skills so I need help with my first little extension.

What I do right know

Without the extension I write often something like this:

.feature
--
*Feature*

abc

123
--

What I would like to have

[feature]
abc
+
123

(This should lead to the same HTML as my current workaround.)

What I found so far

After reading the manual I think the chapter 83.5 Block Processor Example is the part I'm looking for. But I have no idea how to adapt the code to my needs and get it running. Maybe you can add another example based on my request to the manual? I think other people are looking for similar things.

Thanks!

Best regards
DrAscii



If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/My-first-extension-based-on-83-5-Block-Processor-Example-tp7705.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux