A user has approached me with the request of being able to use CSS to indent heading depending on their level (either just the heading content or the heading + content). Something similar to https://stackoverflow.com/questions/46690572/indent-content-based-on-headings
There are some complex ways to achieve this using the current HTML structure. For example: https://stackoverflow.com/a/46690811/153102
However, I think it could be a good idea to modify the HTML Renderers to do materialize the SectionBlock in the HTML for some use cases like this one. A first idea would be to use DIV with a class attribute (e.g.
In the initial discussion I had with other devs, the following points were brought up.
We would need to modify the HTML parsers to handle this since otherwise the DIV would be converted to GroupBlock
I don’t think it’s a good idea to wrap sections in DIVs:
- we end up with headings inside nested DIVs which breaks the current section editing: the section edit pencils are shown only for top level headings (direct children of
- it will break any XWiki extension that expects the headings to be directly under the content wrapper. Numbered Paragraphs and Numbered Headings?
- the nested DIVs will make WYSIWYG editing more difficult
- first, in order to match the view mode, the WYSIWYG editor would have to generate the nested section DIVs also when you create a heading
- once you are inside a section DIV (e.g. for H2) and you want to create a new heading of the same level or higher (e.g. for H1) you need to get out of the section DIV, or the editor needs to do this automatically…
- editing content wrapped in DIVs is cumbersome and unexpected for the user
I’d like to discuss 2 points in this thread:
- How could we help the user achieve the heading indentation, if not using DIVs?
- Is it a good idea to use DIV to materialize SectionBlock so that some JS or CSS can be done more easily on sections by users of XWiki? Marius raised some good points but maybe the issues can be fixed. I think that if we were starting writing XWiki today and we were deciding how our HTML would look like, we would probably use a DIV to materialize the sections so that operations can be done on them more easily.