Code Tags

I am wondering if it is possible to reprogram the Forum software, to intercept blocks of code, which are submitted without code tags.

When a topic or message is being submitted, the Forum software could parse the message text and look for the phrases (say) 'void Setup()' and 'void Loop()' and determine if they are outside of code tags. If outside code tags, then the submitted text could be rejected with the advice 'please put your code in between code tags'.

Steve

Yes, that is possible - but realizable? Not so much, I guess... :wink:

Danois90:
Yes, that is possible - but realizable? Not so much, I guess... :wink:

Surely someone of high rank on this Forum knows the programmers?

Steve

steve1001:
Surely someone of high rank on this Forum knows the programmers?

I do not think that the forum is custom made for Arduino, a styled version of phpBB would be my guess.

Wouldn’t work for snippets. :smiley:

Steve1001,

Nahhhh... don't want that! It's one of the filters I use when deciding whether or not to answer a question. If someone can't understand what 'how to use forum - please read' means then I am much less likely to answer their question, on the basis both that they need to learn the rules if they want VOLUNTEERS to help them and also if they can't understand those simple words what chance is there of them understanding any help I might give?

The other closely related filter I use is the one where they say something like 'I don't need to post all my code'. This is true of course, they don't, and I don't need to offer help.

Also, it would block posts where people just mentioned void setup(), even if they weren't posting a sketch.

Such as this post. And the first post in this thread.

TheMemberFormerlyKnownAsAWOL:
Wouldn't work for snippets. :smiley:

I'm sure it could be made to work.

do
Parse the text
if text contains 'void setup()' and 'void loop()'
if text does not contain codetag and endcodetag
reject submitted text
exit do
else
approve submitted text
exit do
end if
end if
loop

I'm not too sure what you mean by snippets, but if you are referring to the odd functions and lines of code that are submitted outside of code tags then it would be ok to leave those as is I guess.
It seems like thousands of hours has been wasted telling people to USE CODE TAGS when they submit a whole sketch.

Or am I missing your point?

Steve

(edited because my hastily typed psuedo code was bad)

GypsumFantastic:
Also, it would block posts where people just mentioned void setup(), even if they weren't posting a sketch.

Such as this post. And the first post in this thread.

To be intelligent about it, the parser could do further tests, and look for multiple instances of '{' and '}' (and other code markers) in conjunction with 'void Setup()' and 'void Loop()' to determine if there has been just a casual mention of Setup and Loop or not.

Steve

the parser could do further tests, and look for multiple instances of '{' and '}' (and other code markers) in conjunction with 'void Setup()' and 'void Loop()' to determine if there has been just a casual mention of Setup and Loop or not.

It is not easy to parse text with accuracy. For instance this
[­code]
setup()
{
//code for setup() goes here (by the way, should setup() in the comments be in code tags ?)
}
[­/code]
looks like it uses code tags, but it doesn't

UKHeliBob:
It is not easy to parse text with accuracy. For instance this
[­code]
setup()
{
//code for setup() goes here (by the way, should setup() in the comments be in code tags ?)
}
[­/code]
looks like it uses code tags, but it doesn't

That block of text looks like it is using code tags. I cant see how it is not using code tags. Please explain, I feel I am missing something?

'code' and '/code' are the code tags in the text block, aren't they?

Steve

(edited because typing 'code' inside square brackets messed up my format)

The [nobbc] tag blocks tags interpretation so that you can type 8) [code] or [i] safely

This is probably easier to detect code using machine learning and training, there are hundred thousands of posts available To train the system.

Posts with Code detected without code tags could pop up an alert rejecting the post, may be letting the user state “its OK, that’s how I want to post” leaving it to moderator to trash the post if infringing

(i do from time to time post code snippets without code tags to explain something using colors, which you can’t do within code tags)

I think that this will take too long to setup, and the developers will just loop around and around.

That block of text looks like it is using code tags. I cant see how it is not using code tags. Please explain, I feel I am missing something?

I told you that parsing text was not easy !

There is a non printing character in the tags which means that the forum software does not recognise them as code tags so prints them as normal text.

J-M-L:
(i do from time to time post code snippets without code tags to explain something using colors, which you can’t do within code tags)

I think having the a ability to have formatting (color, bold, italics, underline, strike-through) in code posted with Code Tags would be more useful than a not-gonna-happen Auto-Detect Code Tag Inserter

The solution to the Omitted Code Tag problem is simple: contributors just need to discipline themselves and not answer any questions until the code is properly posted.

Detecting ill-posted code could be as simple as searching for curly brackets {} outside code tags - that would catch both complete sketches and most snippets. The method is far from perfect, though.

gfvalvo:
I think having the a ability to have formatting (color, bold, italics, underline, strike-through) in code posted with Code Tags would be more useful than a not-gonna-happen auto-detect code tag inserter.

Agreed

The solution to the Omitted Code Tag problem is simple: contributors just need to discipline themselves and not answer any questions until the code is properly posted.

well, if I’m in a good day, I have setup a text shortcut and I type #tags# and it is replaced by

====
Please correct your post above and add code tags around your code:
[code]`` [color=blue]// your code is here[/color] ``[/code].

It should look like this:// your code is here
(Also press ctrl-T (PC) or cmd-T (Mac) in the IDE before copying to indent your code properly)

UKHeliBob:
I told you that parsing text was not easy !

There is a non printing character in the tags which means that the forum software does not recognise them as code tags so prints them as normal text.

I'm not getting your point! Please spell it out?

I am going to type [ code ] some text in a code block [ /code ].

some text in a code block

It seems ok. What are the unprintable characters?

I do a lot (a hell of a lot) of text parsing, and it is not that hard to come up with something that works. This seems a trivial task here.

Steve

steve1001:
I am wondering if it is possible to reprogram the Forum software, to intercept blocks of code, which are submitted without code tags.

When a topic or message is being submitted, the Forum software could parse the message text and look for the phrases (say) 'void Setup()' and 'void Loop()' and determine if they are outside of code tags. If outside code tags, then the submitted text could be rejected with the advice 'please put your code in between code tags'.

Steve

I am sure the good people at Arduino would welcome your completed code detection code and incorporate the code after a vigorous testing cycle.

But you'll not do this project cause it will take much time and money on your part, correct?


How would you detect this code to place it in code tags?
spi_transaction_t trans_desc;
trans_desc = { };
trans_desc.addr = 0;
trans_desc.cmd = 0;
trans_desc.flags = 0;
trans_desc.length = (8 * 2) + (8 * byteReadSize) ;
trans_desc.tx_buffer = txData;
trans_desc.rxlength = byteReadSize * 8 ;
trans_desc.rx_buffer = rxData;
txData[0] = (uint8_t)addressToRead;
txData[1] = 0x0;
return spi_device_transmit( hSPI, &trans_desc);
Out of curiosity.

Idahowalker:
I am sure the good people at Arduino would welcome your completed code detection code and incorporate the code after a vigorous testing cycle.

But you'll not do this project cause it will take much time and money on your part, correct?


How would you detect this code to place it in code tags?
spi_transaction_t trans_desc;
trans_desc = { };
trans_desc.addr = 0;
trans_desc.cmd = 0;
trans_desc.flags = 0;
trans_desc.length = (8 * 2) + (8 * byteReadSize) ;
trans_desc.tx_buffer = txData;
trans_desc.rxlength = byteReadSize * 8 ;
trans_desc.rx_buffer = rxData;
txData[0] = (uint8_t)addressToRead;
txData[1] = 0x0;
return spi_device_transmit( hSPI, &trans_desc);
Out of curiosity.

Hi Idahowalker

"But you'll not do this project cause it will take much time and money on your part, correct?"

Where did that come from? I have no agenda here. I mentioned nothing about payment for my time! And no, you are not correct. If I had access to the Forum source code (whatever language it is written in?) and could work out how to modify it then I would happily spend a lot of time on it, for nothing. I am very proficient in VB.Net, and can just about get by programming up the Arduinos in C, so modifying the Forum software may be beyond my capability.
I have been trying to get over how trivial a coding task this is. And it looks like something the Forum could do with. If I had a dime for every USE CODE TAGS that has been typed ...........

I would say that small blocks such as your snippet do not really need to be in code blocks. It is a short descriptive block, that can live in the text region of the post.
The complete sketches (absolute pages of the stuff) that the posters are posting, need to be in code blocks.

Steve