Long code pastes in the forum
-
At least in the forum it is IMHO desiderable to somehow have a way to collapse/shorten very long code pastes (10+ lines), possibly with a div with a fixed height and "overflow: scroll" or similar, and optionally unroll/collapse each code block with a small button or text. This should dramatically increase the readability of forum threads.
I'm not sure if it's useful on the wiki as well, but I'd say yes.
-
That sounds like a good idea.
I created a JIRA entry: "QTWEBSITE-174":http://bugreports.qt.nokia.com/browse/QTWEBSITE-174 -
I'm upping this for a somehow different reason: I'm starting to think that code pastes in the forum of more than, say, 10 lines, (i.e.: a snippet) should be somehow forbidden; or, in general, highly discouraged. (OR: see down)
I'm starting to completely ignore threads where someone just dumps 3-4 files of 20+ lines each, because I don't want to copy/paste every snippet into a different file just to get them compiled and see where the problem is. Therefore, I suggest:
to recommend people to paste in the forum snippets only, and put long/multifile code in a .zip file uploaded somewhere (but this all in all can discourage users; and the forum post itself becomes unliked with the code it should contain, that is, we can lose track of the code - the user deletes it, the website where it's uploaded to gets down, whatever -, thus making the forum post useless); OR
to introduce attachments to forum posts (but this, IIRC, can lead to legal and general security troubles); OR
to keep long pastes in the forum, but to put as default the already existing < code > tag for code, extended with the syntax
@
<code [lang=LL] [name=foo]>
...
</code>
@
where lang=LL is used to specify the syntax highlighting that should be applied (c++, python, ...) and name=foo is used to give a file name to that piece of code. The missing piece of the puzzle is some neat trickery to assemble all the named <code> sections in a post into a .zip file.What do you think about it?
-
I'm for having a collapse/expand feature and maybe set it to collapsed as default at a threshold of lines - and only in the forum.
I agree with the reasons why #1 and #2 are not a viable solutions.
Regarding #3: we use a js based syntax highlighter that you can find "here":http://alexgorbatchev.com/SyntaxHighlighter/. The team behind this site doesn't want to develop a custom syntax highlighter (I'm sure you understand) so if what we want deviates from the current solution we can:
Use another syntax highlighter
Wait for upgrades to the current solution
Option 1 isn't that far out to be honest, there are a bunch of ideas out there about what we can do with a server-side php based solution. One thing is that the js. file provided for the client solution we have now gets too big to include all Qt functions :)
But for now my view is that we hold our horses and revisit it once our feature race towards summer has landed.
Thank you for views and ideas (and wiki contributions!) peppe , it's very much on the radar. Vote for QTWEBSITE-174, it helps!