Hi everyone,
with the help of Claude Code, I’ve had another look at XRENDERING-766 and I have a possible fix that correctly preserves the empty parameters after macro and verbatim syntax like {{icon name="add"/}}(% id="test" %), avoiding that it applies to either the macro or the next paragraph.
However, I noticed a deeper problem here that is independent of the concrete fix:
The standard model of WikiModel is that empty parameter syntax is discarded. If the content was icon (% id="test" %), we would also discard that format syntax, even if a closing (%%) was added.
I see several options now:
- We implement the expected behavior expressed in XRENDERING-766 and keep the empty format, but only in that exact situation, i.e., a macro/verbatim syntax at the start of the line followed by an empty format. This seems inconsistent, but the empty format here matters as it is what makes the verbatim or macro inline and not standalone. In the case of a line with further text content, it doesn’t matter as the content of the line is inline, anyway.
- We ignore the empty format as we do in a regular paragraph (or list item), but keep the macro/verbatim inline. This doesn’t survive rendering roundtrips as after rendering back to XWiki syntax, the format is gone and the macro or verbatim is standalone now.
- We ignore the empty format as we do in a regular paragraph (or list item) and the macro or verbatim syntax is treated as standalone verbatim/macro.
- We keep all empty format syntax that has parameters (so an empty bold text would be discarded, an empty format with an
idattribute would be kept). - We keep all empty format syntax.
Note that the first and the last two options might have unintended consequences for WYSIWYG editing as empty format syntax is most likely invisible in WYSIWYG editing.
To me, option 3 seems to be the most consistent one given the existing behavior of WikiModel, but it also doesn’t really fix the original bug. For that, I guess option 1 would be best. But then the question is if we shouldn’t rather implement option 4, but I fear a bit the possible breakages, so this seems a bit better suited for a new syntax version not based on WikiModel.
@mleduc After looking a bit at XWIKI-21973 from which you created the rendering issue, I have the feeling that the example given in XRENDERING-766 is wrong as it misses the key detail that the format is non-empty. Could you confirm that empty formats aren’t interesting here? If yes, I would prefer implementing option 3 as it seems the cleanest (while ensuring that a non-empty format actually keeps the macro as inline).