HTML Variants Syntaxes
This page gathers the documentation about the HTML variants syntaxes and their specificities.
Annotated XHTML
This syntax puts supplementary information in the rendered XHTML in order to be used by the CKEditor.
Metadata Annotation
Metadata provided in the page structure (XDOM) are now output when using the Annotated XHTML renderer, using the following rules:
- it produces a container with the class xwiki-metadata-container
- the container is a div or a span depending if the metadata is an inline context or not
- all metadata are provided in dedicated attribute named on the schema data-xwiki-key where key is the metadata name.
Then the following XDOM:
beginMetaData [[syntax]=[xwiki/2.0]]
beginParagraph
onWord [Heading]
endParagraph
endMetaData [[syntax]=[xwiki/2.0]]
endDocument
will be interpreted like this:
<span>Heading</span>
</div>
Macro Annotation
Macros are annotated by HTML comments that allow reconstructing the original content. The content between them can further be wrapped in metadata blocks to mark the content as non-generated with the goal of allowing editing of the content in the WYSIWYG editor. The following XDOM:
beginMetaData [[non-generated-content]=[java.util.List<org.xwiki.rendering.block.Block>]]
beginParagraph
onWord [Some content]
endParagraph
endMetaData [[non-generated-content]=[java.util.List<org.xwiki.rendering.block.Block>]]
endMacroMarkerStandalone [testinlineeditingmacro] [] [Some content]
will be interpreted as:
<div data-xwiki-non-generated-content="java.util.List<org.xwiki.rendering.block.Block>" class="xwiki-metadata-container">
<p>Some content</p>
</div>
<!--stopmacro-->
Note that the full content of the macro is contained in the HTML comment. If there is no non-generated content, the HTML code between the comments will be ignored during parsing.
Annotated HTML5
Since XWiki 14.0, Annotated HTML 5 uses the same metadata and macro markers as annotated XHTML 1.0, before that some parts were missing, see https://jira.xwiki.org/browse/XRENDERING-630. Note that the `data-`-attributes used for metadata are actually only valid in HTML 5 and thus annotated HTML 5 should be preferred whenever possible. With the availability of a (X)HTML 5 parsers in XWiki 14.1 (see https://jira.xwiki.org/browse/XRENDERING-375), this should always be possible unless backwards-compatibility needs to be maintained.