Questions about attribute substitution, treeprocessor, and builtin inline and inline macros.

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

Questions about attribute substitution, treeprocessor, and builtin inline and inline macros.

David Jencks
I've written a javascript asciidoctor.js extension that renders stem content into inline svg. I've followed the ruby asciidoctor-mathematical design of using a treeprocessor. This seems to work well except that attribute substitution always uses the document header attributes rather than the most recent attributes, even when the attributes are redefined in the same block. Tracing the execution, it appears that the new attribute values are in the paragraph block, but apply_subs doesn't seem to use them when called from a tree processor whereas apply_subs does when called from the html5 converter.

First question... why would there be a difference in behavior? So far I haven't seen any difference in arguments or state, but I could easily have missed something.

I think an alternative implementation strategy would be for a tree processor to transform stem blocks and stem inline into block macro and inline block macro calls, and then let the converter call into these extensions. That is, along with the treeProcessor extension I'd register a MathJax block macro and MathJax inline block macro, and transform [stem] to [mathjax] and stem: to MathJax: (leaving out the details).

Second question.... is this likely to produce more fidelity with built-in stem processing?

Third question... why aren't the built in inline stuff that looks somewhat like inline macros, such as stem:, xref:, image:, already exposed as extension points, either as inline macros with a default implementation, or as additional extension types? Similarly, why doesn't [stem] appear as a block extension or a new kind of extension?

Fourth question... Could the Antora html5 converter be replaced by a treeProcessor that rewrites the inline stuff it modifies to call inline macros, e.g. xref >> antora-xref, together with appropriate inline macro extensions?