This issue has been created
There are 2 comments.
 
 
XWiki Platform / cid:jira-generated-image-avatar-00318f7c-01fa-4903-870f-ffaf4b74e7c1 XWIKI-24059 Open

Inconsistencies between UniAst and Macro AST

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-895bc09e-872b-4f6f-85da-952eef476fab Marius Dumitru Florea created this issue on 24/Feb/26 15:41
 
Summary: Inconsistencies between UniAst and Macro AST
Issue Type: cid:jira-generated-image-avatar-00318f7c-01fa-4903-870f-ffaf4b74e7c1 Bug
Affects Versions: 18.1.0
Assignee: Unassigned
Components: Node - UniAST - API
Created: 24/Feb/26 15:41
Priority: cid:jira-generated-image-static-major-04a1d033-367a-4235-9677-8da0a9e512be Major
Reporter: Marius Dumitru Florea
Description:

I noticed there are differences between how blocks are defined in UniAst and Macro Ast, which I find surprising. I understand why Macro Ast needs to define its own types, but I was expecting these duplicated types to have the same structure / constraints as the types defined by UniAst. I mean, I don't see why a specific type of block would have different constraints when outside a macro than when inside a macro. Here are the differences I noticed:

  • lists have a numbered property inside macros, but not outside
  • break block is not supported inside macros
  • macroBlock has a call property (with id, params and body) outside macros and the name and params properties inside macros. Why the difference and why the limitation that a macro (call) block can't specify a body when inside another macro?
  • block styles have cssClasses inside a macro but not outside
  • list items have a number property outside macros but not inside
  • list items can have block level children outside macros but not inside => this is quite surprising because I was expecting to have more freedom / fewer restrictions inside the read-only output of a macro. You can edit lists with block level content, but you can't have a macro generating lists with block level content.
  • the image can have caption and styles outside a macro but not inside, again very counter-intuitive to me
  • table header cell can have rowspan and colspan outside a macro but not inside
  • inline image is allowed outside macros but not inside
  • inlineMacro has the same problem as macroBlock: call(id, params, body) vs. name, params

Are these differences by design, for a good reason, or are they just the result of code duplication that left the Macro Ast out of sync with UniAst?

 
 

2 comments

 
cid:jira-generated-image-avatar-895bc09e-872b-4f6f-85da-952eef476fab Marius Dumitru Florea on 24/Feb/26 15:47
 

I raised this issue because on the server-side the macro output doesn't use a different AST definition. There is a single AST, the XDOM, which can have Macro blocks (corresponding to macro calls) and Macro Marker blocks (corresponding to macro output). A macro is basically a XDOM transformation that replaces a Macro blocks with Macro Marker blocks. But the macro output is still XDOM. Macros can generate paragraph or list blocks, which are no different from the paragraph and list blocks found outside macros.

 
cid:jira-generated-image-avatar-895bc09e-872b-4f6f-85da-952eef476fab Marius Dumitru Florea on 24/Feb/26 15:51
 

Note that I hit this issue while testing XWIKI-23349. If I try to edit a page with this content:

{{velocity wiki="true"}}
* red
* green
* blue
{{/velocity}}

I get

Failed to render macro: Reached a theoretically unreachable statement

and the root cause is that lists inside macro output support only inline content, and the server-side UniAst renderer outputs paragraphs inside lists in order to match the UniAst constraint that lists contain block level content.