Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
In a treeprocessor, I want to get the current value of att from:
= Title :att: 1 = block1 text :att: 2 =block2 text From experimenting, I *think* block.getDocument.getAttributes() returns environment attributes + header attributes as they were defined at the start of processing; block.getAttributes() returns things like role and style, ie just the attributes that are specific to that block. Is it possible to get the value of a document attribute as it is immediately prior to the block? Using 1.6.0-alpha.5 via asciidoctor-ant. |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
rockyallen, This has come up often and, unfortunately, a limitation of the Asciidoctor processor at the moment. The in-flow document attributes are not available to the AST. They get "played" once when the document is parsed and once again when the document is converted. Depending on where your code runs in processing lifecycle, you may see different values. What needs to happen is that core needs to designate a node for an attribute entry so they live in the tree. Well, technically, they do live in the tree, but they are in a private area. Without changing core too much, one possible idea is to make the document attribute accessible via the block (since it's already stored on the block). That might look something like block.getDocumentAttributes(). (These are not the same as block.getDocument().getAttributes()). I think the next step is to open an issue in asciidoctor/asciidoctor to discuss whether in-flow document attributes should be in the AST and, if so, what are they called, where do they go, and how do we access them. Cheers, -Dan On Sun, Oct 8, 2017 at 3:56 AM rockyallen [via Asciidoctor :: Discussion] <[hidden email]> wrote: In a treeprocessor, I want to get the current value of att from: ... [show rest of quote] -- Dan Allen | @mojavelinux | https://twitter.com/mojavelinux |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
This post was updated on May 12, 2020; 4:24pm.
Hi all,
does somebody know if there is already solution for this issue? I am facing the same problem: ====== Title [#myid] :status: new :otherattr: -- Bla Bla Bla -- I need to access the attributes :status:, :otherattr: within a TreeProcessor. Is there maybe a workaround in asciidoctorj 1.6.x? E.g. using Ruby directly? Thanks! |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
You have to:
— traverse the entire tree in order — replay the attributes, and when you’re done reset them. If you can understand javascript, you can find an example in David Jencks
/
asciidoctor-mathjax.js I assume the necessary methods are exposed in AsciidoctorJ, but I don’t know, and there seem to be some limitations there, so it might not be possible. David Jencks
... [show rest of quote] |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
I fear that playback_attributes is not exposed on asciidoctorj - at least I couldn't find it.
Is there any other workaround? Is it somehow possible to expose it? It also seems that the issue has been open for a very long time: https://github.com/asciidoctor/asciidoctorj/issues/139 Thanks! Regards, Daniel |
Free forum by Nabble | Edit this page |