Imho, the best way would be to re-structure your text, e.g. using the structure field or modules or the page builder, instead of putting everything into a big text area field and then do string replacements. Or create a plugin similar to the columns plugin and use like this:
The structure field is an interesting idea. The pitfall is that I then need to do something with the content in order for it to work.
With my fragile function I don’t need to to that. My original content looks like this (before the parsing):
## Title1
Some text
## Title2
Some text2
I see now that I should have written this before to make it clear how it looks. Because it’s so simple, I’m a bit offensive against the structure field and the kirbytext tag suggestions.
But I have not made a decisions yet so I’ll think about it. More ideas are welcome as well.
That would have been brilliant if it would have worked. What it does is that it’s breaking into more columns than set. You set 3 columns but it’s broken into 4 columns.
It seems like the only way is to use a parent element and I’ve decided to stick with my hacky solution. I could use javascript to fix it with the dom but that would probably be a bit jumpy when page loads (javascript loads late to not render block).
If you’re not nesting sections properly, you might want to use an element with neutral semantics (<div>) rather than misuse an element with specific semantics (<section>).
I think you are right about that after reading this:
The section element is not a generic container element. When an element is needed for styling purposes or as a convenience for scripting, authors are encouraged to use the div element instead. A general rule is that the section element is appropriate only if the element’s contents would be listed explicitly in the document’s outline.