Code formatting in this forum is problematic.

edited March 2016 in General

Hi, using the code formatting feature I noticed these problems.

When I hit the [C] icon two grave characters appear but putting any code inside them is a huge mistake because it won't get formatted. Though it is mentioned in the link down the text box that using markdown will help but it does not work. https://en.wikipedia.org/wiki/Grave_accent https://en.wikipedia.org/wiki/Markdown

Example void setup() { size(500, 500); }

So the best deal is to paste the code first and then select it and then hit the [C] icon. However this brings another problem that the code is not highlighted.

This was pasted selected and formatted in the beginning. void setup() { size(500, 500); }

This was done at the edit.

void setup()
{
    size(500, 500);
}

Comments

  • You see why all users have troubles formatting their code. It has been mentioned all of the time in these forums.

  • There are 2 ways to have code in a post: a short code within a line uses grave accent or a longer code (Minimum 1 line of code) uses 4 empty spaces at the beginning of the code.

    In the 2nd format it is important to have 2 empty lines before and after the code block. Also every line must have 4 or more spaces.

    When the you posted the post and submitted it (!!! don't do this before really submitting!!!) and the code looks wrong hit F5 to update the website.

  • There is a sticky thread telling you all this. It might need a bit of a prune though. I'll look at it later.

    I'm not that surprised that people don't see the sticky thread but I am surprised that people post code and do nothing about it when it ends up looking like garbage.

  • I've updated the sticky thread slightly, moved some things around to try and make things clearer, but it wasn't as bad as i remembered.

    i think the big problem is that people don't read it before posting, which i can't do a lot about.

  • yeah, the C button does different things depending on whether there is selected text or not.

    my one bit of advice would be to not use the C button but ctrl-o instead (which is the gist of my changes above)

  • i appear to have made the sticky post non-sticky. bother...

  • Thanks for the answers.

    I had visited this post as you mentioned and it explains everything in detail. https://forum.processing.org/two/discussion/32/how-to-format-text-and-code-on-the-new-forum/p1

    However I want to point that this is a web design error.

    Let's say now by usability terms, first you will have to paste the code, then scroll all the way up, then start to select it, scrol all the way down and then hit the format button. This is very inefficient.

    The best case is to type two accent grave characters, do the paste. Anything inside accent graves will have to be 100% code, otherwise is a no go. This is how Github does the job and it's very effective. Also I post on other forums that support BBCode and this makes sense because you use the [code][/code] tags and the job is done. Unfortunately one-liners will have to be discarded, because I consider that there is no way to provide meaningful code in a single line, they are virtually useless.

    Also in this post: https://forum.processing.org/two/discussion/32/how-to-format-text-and-code-on-the-new-forum/p1

    However I notice the same problem with highlighting. If you read the code after where it says "will indent a text selection with 4 spaces." You will see that the code is not highlighted. This is because the user formatted the code and posted. Whatever post I made so far I noticed that in order to enable code highlight I had to edit and save it, otherwise the highlight is not enabled.

  • i never have any problem posting code and i just use the highlight / ctrl-o method.

    that thread you linked was written just after we'd migrated to this forum software and everyone was trying to get to grips with the functionality. a lot of the information in it is beta and is best ignored. PhiLho later summarised that into the sticky thread (perhaps a bit too early as the keyboard shortcut changed afterwards) but it was still too complicated. hopefully it's clearer now.

    highlight code, hit ctrl-o. that's it.

    (apart from the multipart comments and the blank lines and the urls and the smilies and the @ symbols...) 8)

  • I really don't have any problems with posting code - just the 2 lines before and after the code block

    And maybe F5 / ctrl-r after posting...

Sign In or Register to comment.