Support for figure captions in XWiki syntax and the WYSIWYG editor

Note that it would probably break backward compatibility slightly if we do it for xwiki/2.1 so we’d need to decide if we accept that breakage or if we want it in a new xwiki/2.2 syntax.

This is what it currently does in xwiki/2.1: https://rendering.xwiki.org/xwiki/bin/view/Main/WebHome?inputsyntax=xwiki%2F2.1&outputsyntax=xdom%2Bxml%2Fcurrent&input=[[(((test)))>>https%3A%2F%2Fxwiki.org]] #HDemo

Also, we’d need to decide what we do if used inline since the parsers should never throw an error. We need a degraded mode in this case.

I’m not sure if this is breaking backwards-compatibility, as I have the impression that we already support block content inside links, just the wrapping elements are not removed: https://rendering.xwiki.org/xwiki/bin/view/Main/WebHome?inputsyntax=xwiki%2F2.1&outputsyntax=html%2F5.0&input=[[(((test)))>>https%3A%2F%2Fxwiki.org]] #HDemo

In particular:

  • There must be no wrapping <span class="wikiexternallink">
  • There must be no wrapping <p>

While this could create the impression that this is easy to implement, I think this is actually quite difficult to properly implement, in particular:

  • CKEditor 4 has no support for nesting block content in links (I have not checked CKEditor 5).
  • XWiki syntax parsing only supports this because we are using a separate parser to parse the link label.
  • WikiModel also doesn’t support this kind of nesting, thus adapting the XHTML 5 parser or also properly parsing this right in the parser for XWiki syntax will require non-trivial changes in WikiModel. In particular, parsing a link currently automatically triggers the opening of a paragraph even though it should only do that if the link contains just phrasing content (which is not known at that point).
  • Our body filter in HTMLCleaner would need to be adjusted to not to wrap <a> in a <p>-tag (in HTML 5) - that’s relatively easy, though, apart from the fact that we cannot simply use the same for HTML 4 and HTML 5.
  • It is not clear to me how we should render this in XHTML 1.0 or any other syntax we support (like LaTeX).

Supporting this syntax just for images seems way easier to me as in HTML, WikiModel and Rendering Listener API we just handle this as figure/figure caption and not as (image) reference.

Actually this is not really supported. It’s just that we don’t do anything special to handle standalone blocks inside reference labels. We have a jira issue for this, to provide valid XDOM. Normally we should have stripped the standalone blocks.

Sure, that’s ok with me too FTM (until we want to support it), I didn’t see it in the 4 options that you provided above. Provided users can’t enter standalone blocks in references when using the wysiwyg editor.