Do I need an extension or not for the following use case ?

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

Do I need an extension or not for the following use case ?

ch007m
Hi,

Do I need an extension or not to cover the following use case ?

I would like to generate a html, pdf file generated from an adoc file where a table will be generated and will contain 2 columns.
The first column corresponds to the name + internal hyperlink of a keyword (= Title starting with name "=== Command")
The second is a summary description of the command (= text defined under "=== Description" section of the "=== Command")

Example of table generated

== Roles

lorem ipsum, lorem ipsum, lorem ipsum, lorem ipsum, lorem ipsum, lorem ipsum

TABLE TO BE GENERATED
| Role | Description |
| Hyperlink to command 1 | lorem ipsum, lorem ipsum |
| Hyperlink to command 2 | lorem ipsum, lorem ipsum |

Asciidoctor example

== Roles

lorem ipsum, lorem ipsum, lorem ipsum, lorem ipsum, lorem ipsum, lorem ipsum

=== Command: 1

==== Description

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla fermentum vel magna ac tincidunt. Nam nec ultrices est. Proin volutpat purus sem, non pharetra erat sodales eget. Ut vulputate maximus odio eu laoreet. Nulla tempor turpis a neque tempor dignissim. Ut cursus feugiat nunc id sagittis. Sed in orci eu.

==== Parameters

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla fermentum vel magna ac tincidunt. Nam nec ultrices est. Proin volutpat purus sem, non pharetra erat sodales eget. Ut vulputate maximus odio eu laoreet. Nulla tempor turpis a neque tempor dignissim. Ut cursus feugiat nunc id sagittis. Sed in orci eu.

=== Command: 2

==== Description

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla fermentum vel magna ac tincidunt. Nam nec ultrices est. Proin volutpat purus sem, non pharetra erat sodales eget. Ut vulputate maximus odio eu laoreet. Nulla tempor turpis a neque tempor dignissim. Ut cursus feugiat nunc id sagittis. Sed in orci eu.

==== Parameters

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla fermentum vel magna ac tincidunt. Nam nec ultrices est. Proin volutpat purus sem, non pharetra erat sodales eget. Ut vulputate maximus odio eu laoreet. Nulla tempor turpis a neque tempor dignissim. Ut cursus feugiat nunc id sagittis. Sed in orci eu.


Charles Moulliard
Apache Committer / Technologist Evangelist / Blogger / MiddleWare Specialist
Twitter : @cmoulliard
Reply | Threaded
Open this post in threaded view
|

Re: Do I need an extension or not for the following use case ?

abelsromero
Yes, your' right. Asciidoctor does not have AsciiDoc code generation like this.
But there are many ways to do that:
- Split the docs and add tags in a way you can use includes to build the table.
- You can always resort to any pre-task (Java, bash,...) to generate code during your build pipeline.
- Extension to build it dinamically.

On the other hand, it seems to be your are trying to build some kind of TOC?
Reply | Threaded
Open this post in threaded view
|

Re: Do I need an extension or not for the following use case ?

ch007m
This is not really a TOC that I'm creating but a table

Which kind of processor (block, tree, ...) should I then develop to support to include within the HTML file or pdf such dynamic table ?
Charles Moulliard
Apache Committer / Technologist Evangelist / Blogger / MiddleWare Specialist
Twitter : @cmoulliard
Reply | Threaded
Open this post in threaded view
|

Re: Do I need an extension or not for the following use case ?

abelsromero
I was hoping for you to go with the includes option. It's more cumbersome but I prefer out-of-the-box solutions -total personal preference-. The only problem with this I find is obtaining the command name from the section title.

About the extension, I can't really say, but just by process of elimination the Treeprocessor ...
- Preprocessor is the easier, it's only adding AsciiDoc line, but I don't recall includes are processed, you won't have access to the included content unless parsed manually.
- Postprocessor deals with raw output data, fine for HTML, but not for PDF which is binary.
- The other options make no sense to me.

-> Treeprocessors exposes the whole AST, so you have all info available, but you'll have to build the table also using the AST API.

Reply | Threaded
Open this post in threaded view
|

Re: Do I need an extension or not for the following use case ?

mojavelinux
Administrator
You could do it with a combination of the block macro and the tree processor. The block macro would be used for placing the block into the tree. But a block macro can't see parts of the tree that have no yet been parsed. So you'll likely create a stub block, then use the tree processor to come back to it and fill it in.

Cheers,

-Dan

On Thu, Apr 9, 2020 at 3:47 AM abelsromero [via Asciidoctor :: Discussion] <[hidden email]> wrote:
I was hoping for you to go with the includes option. It's more cumbersome but I prefer out-of-the-box solutions -total personal preference-. The only problem with this I find is obtaining the command name from the section title.

About the extension, I can't really say, but just by process of elimination the Treeprocessor ...
- Preprocessor is the easier, it's only adding AsciiDoc line, but I don't recall includes are processed, you won't have access to the included content unless parsed manually.
- Postprocessor deals with raw output data, fine for HTML, but not for PDF which is binary.
- The other options make no sense to me.

-> Treeprocessors exposes the whole AST, so you have all info available, but you'll have to build the table also using the AST API.




If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/Do-I-need-an-extension-or-not-for-the-following-use-case-tp7854p7859.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
Reply | Threaded
Open this post in threaded view
|

Re: Do I need an extension or not for the following use case ?

ch007m
Is there an example available (stub processor) and covering that use case ?
Charles Moulliard
Apache Committer / Technologist Evangelist / Blogger / MiddleWare Specialist
Twitter : @cmoulliard
Reply | Threaded
Open this post in threaded view
|

Re: Do I need an extension or not for the following use case ?

David Jencks
I don’t know of an example.  I think the main point is that the two processors be in the same code so they can share state, namely the stub block that needs to be filled in by the tree processor.

FWIW I’ve been working on a related solution for Antora, where the index table and components are on different pages.  In that case the role of the tree processor is taken by querying the Antora content catalog, which can be done in the block processor.  The (javascript) code is at David Jencks / asciidoctor-antora-indexer and I’m working on using it for Camel at CAMEL-14874Generate component index page tables with Antora

Since my solution is intended to be fairly generic I do not have the block macro generate the entire table but rather run only when it immediately follows an existing table, to which it appends rows.  That way the block macro doesn’t need to deal with the complexity of generating the entire table structure, formatting, columns, header, etc etc.  If you adopt that strategy I think your block macro could basically serve to locate the table to append to, and then the tree processor actually do the appending.

David Jencks

On Apr 9, 2020, at 4:30 AM, ch007m [via Asciidoctor :: Discussion] <[hidden email]> wrote:

Is there an example available (stub processor) and covering that use case ?
Charles Moulliard
Apache Committer / Technologist Evangelist / Blogger / MiddleWare Specialist
Twitter : @cmoulliard



If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/Do-I-need-an-extension-or-not-for-the-following-use-case-tp7854p7865.html
To start a new topic under Asciidoctor :: Discussion, [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML