Re: order of extension processing
Posted by
mojavelinux on
Nov 21, 2018; 7:12pm
URL: https://discuss.asciidoctor.org/order-of-extension-processing-tp6581p6589.html
Bernhard,
You have correctly derived that a block processor an inline macro processor operate in different phases. This stems from the fact that Asciidoctor only parses down to the block level during the parse phase. All inline parsing is deferred until the convert phase. This will eventually be fixed, as tracked by
https://github.com/asciidoctor/asciidoctor/issues/61.
The best thing I can advise is to capture the document attributes you want at the time the block is processed and store them somewhere as a stack, such as on the block or in the document.catalog. Then, consult that stack when processing the inline macro. In other words, you need to do some state management yourself.
I hope that helps! Let me know if you need more info.
Cheers,
-Dan
On Tue, Nov 6, 2018 at 11:53 AM ttmetro [via Asciidoctor :: Discussion] <
[hidden email]> wrote:
I've created 2 extension, a BlockProcessor and an InlineMacroProcessor.
Apparently they are executed in different phases: first the BlockProcessor is called to handle all the blocks, later the InlineMacroProcessor.
I need their attributes in the sequence they appear in the document. Is there a way to do this?
Motivation: the block and macro process Python code, that is written to a file, evaluated, and in a later pass inserted into the document. E.g. the block might set up a computation, the macro display the results inline.
Thanks!
Bernhard
--