I'm rendering to html a large block of code with various levels of indenting that I want people to be able to copy into a text editor, with the indenting preserved.
Currently I have lots of characters in the code, which is very messy, and makes it hard to maintain. I'd rather do it via css, using the ::before operator, but all the solutions I've tried have been problematic.
If I insert \00a0 characters before the element using :before, the whitespace is displayed by the browser, but won't copy out into a text editor.
If I use 'pre', the whitespaces in the source are preserved, it makes the rendered html too dependent on the structure of the source code - i.e. if there are divs in the source, it adds extra lines in the rendered code, plus I have to worry about whitespaces and new lines in the source code etc., which is a problem when I reformat the code in the editor, which I have to do quite often to keep it clean (it's fairly dynamic).
So basically I need some css classes that will give me varying levels of indentation, without having to add or actual whitespace in the source, which will also copy from the browser into a text file.