Login  Register

Re: How to exploit ContentPart attributes (RubyHash) from Java

Posted by mojavelinux on Apr 04, 2019; 9:24pm
URL: https://discuss.asciidoctor.org/How-to-exploit-ContentPart-attributes-RubyHash-from-Java-tp6827p6835.html

Michaël,

I think what you're looking for are block attributes instead of document attributes. These are specified differently.

[subsystem=NewValue]
== Sample Section

Now, when you look for the attributes on a node, you will find "subsystem" among them.

Document attributes that are changed mid-document are not available to the AST (without doing some magic incantations). That's because document attributes are not part of the AST beyond the document header. This is explained here: https://github.com/asciidoctor/asciidoctor/issues/1485#issuecomment-142184143

Cheers,

-Dan

On Thu, Apr 4, 2019 at 10:49 AM Michaël Melchiore [via Asciidoctor :: Discussion] <[hidden email]> wrote:
To give a bit of context, I intended to use attributes to tag special values for easy programmatic access when parsing the document.

For example, I was thinking on writing software requirement documents with AsciiDoc and use AsciidoctorJ to implement some tooling.

Each top level section of the document would be dedicated to a software requirement. I thought section attributes would be useful to capture some metadata about each requirement (allocated subsystem, target version...).
I could use the attribute in two interesting ways:

* reference in the requirement text to avoid duplicating information
* from the Java API to efficiently access the metadata value without complex and fragile requirement text parsing logic

So my use case is that one section has a set of fixed attributes each with a single value. My previous example could have lead you to believe I want to detect attribute value changes in arbitray places of the document. This is not the case, my need is much simpler and I control the layout of the document.

Michaël


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/How-to-exploit-ContentPart-attributes-RubyHash-from-Java-tp6827p6832.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