Go Down

Topic: Code Tags (Read 1 time) previous topic - next topic

TheMemberFormerlyKnownAsAWOL

But don't you get tired of that!
No, it's useful triage.

PerryBebbington

But don't you get tired of that!


Sometimes, but then I don't always reply, safe in the knowledge that someone else will. If you read the occasions when I do reply you will have noticed that I always trying to find new ways to tell people to follow the forum instructions.

Delta_G

Just give me access to the Forum source code and I'll do it for you. Let's not mull it over too much, just dive in there and get it done. (insert smiley).


Steve

Why do you need the forum software to write a parser?  You could write that stand alone.  If it can take forum posts and properly identify what parts are code and what parts aren't then porting it into the forum software would be simple.  All the parser actually needs in order to test is the text from the forum, not the forum software.  The big problem is writing the parser, not integrating it into something else. 
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

steve1001

Why do you need the forum software to write a parser?  You could write that stand alone.  If it can take forum posts and properly identify what parts are code and what parts aren't then porting it into the forum software would be simple.  All the parser actually needs in order to test is the text from the forum, not the forum software.  The big problem is writing the parser, not integrating it into something else. 
Hi Delta G
I'm afraid I do not know how the PHPBB software works. I am presuming the forum software runs, and functions within it accept the text from the posters when they press the SUBMIT button. The forum software then saves the submitted text to a database, and other functions in the software then present the database contents to browser side. For me , the parsing bit would be easy. It's the integration and implementation that I do not know about.

When I started this thread I was kind of hoping that some of the expert programmers that are regulars on this forum were actually involved with the forum sofware, and had some control over it. I kind of hoped that if they had access then changes could be made. It appears that that is not the case. 

Steve





Delta_G

That's exactly what I mean.  You've got the cart before the horse.  Write the parser and prove that it works and it will be a lot easier to get someone interested in implementing it in the forum. 
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

steve1001

#35
Oct 17, 2019, 06:28 pm Last Edit: Oct 17, 2019, 06:29 pm by steve1001
That's exactly what I mean.  You've got the cart before the horse.  Write the parser and prove that it works and it will be a lot easier to get someone interested in implementing it in the forum.  
I now see your point. I have already been searching PHPBB sites, to get an idea of the language used and how things are being implemented, and the way things work. I currently get the idea that an Extension is the way to go, to avoid problems when upgrades are installed. If I make any progress ... I'll Be Back.

Meanwhile, countless time and effort will continue to be wasted, telling the posters how to post. (Just joking! smiley)


Steve

Delta_G

You're still talking about bulletin board software.  Forget that.  Write code that takes a block of text and finds the code.  You don't need to know anything about the forum software to do that.  That is the hard part. 

Once you have something that actually works to detect the code THEN we start looking at how to add that to the forum software.  Only then does it become important what they use.  Up to that point it's just a text parser. 

You've still got the cart before the horse.  The reason you're not getting any traction getting anyone interested in adding anything to the forum software is that everyone thinks this parser will be more difficult than you do.  If you solve that hard problem then surely someone will help solve the trivial problem of having the forum software use that code and porting that code to whatever language or style they desire. 

It's the algorithm you gotta work out.  And that's the hard part. 
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

Danois90

Here is one example of how to prompt ppl who are posting code outside tags to correct their post before posting it. It's pretty basic, though..

Code: [Select]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<script language="javascript">

var mustCheckForm = true;

function removeBBTag(tag, fromStr) {
let start, end = 0;
do {
start = fromStr.indexOf('[' + tag + ']');
if (start > -1) {
end = fromStr.indexOf('[/' + tag + ']', start);
if (end < 0) end = fromStr.length;
fromStr = fromStr.substring(0, start) + fromStr.substring(end + tag.length + 3, fromStr.length);
}
} while (start > -1);
return fromStr;
}

function hasCodeOutsideTags(contentStr)
{
//Remove [nobbc] tags
contentStr = removeBBTag('nobbc', contentStr);

//Remove existing [code] tags
contentStr = removeBBTag('code', contentStr);

//Test 1: Curly brackets
if ((contentStr.indexOf('{') > -1) || (contentStr.indexOf('}') > -1)) return true;

//Test 2: Lines ending with semicolon
let lastChar = ' ';
for (i = 0; i < contentStr.length; i++) {
let curChar = contentStr.charAt(i);
if (('\r\n'.indexOf(curChar) > -1) && (lastChar == ';')) return true;
else if ('\r\n\t '.indexOf(curChar) < 0) lastChar = curChar;
}

return false;
}

function checkForm() {
if (mustCheckForm) {
mustCheckForm = false;
let ctrl = document.getElementById('theText');
if (ctrl) {
if (hasCodeOutsideTags(ctrl.value)) {
document.getElementById('theMessage').style.display='block';
return false;
}
}
}
return true;
}

function textChange()
{
mustCheckForm = true;
document.getElementById('theMessage').style.display='none';
}

</script>
</head>
<body>
<div>
<div style="background:yellow;width:800px;display:none" id="theMessage">
It seems like you are posting code without using the proper formatting.
If you do not know how to properly post code please read the <a href="#">How
to use the form</a> topic.
</div>
<form action="#" onsubmit="return checkForm()">
<textarea id="theText" style="width:800px;height:400px" onchange="textChange()" onkeyup="textChange()"></textarea>
<br/>
<input type="submit" value="Post"/>
</div>
</form>
</body>


Must be saved to a *.htm file in order to test. Works with Firefox.
Instead of mocking what's wrong, teach what's right! ;)
When you get help, remember to thank the helper and give some karma!
Please, do NOT send me any private messages!!

steve1001

#38
Oct 17, 2019, 08:16 pm Last Edit: Oct 18, 2019, 04:01 am by steve1001
Great stuff Danois90.

I dropped the text from a recent post I found in the Programming section (I did not have to look too far!), and it automatically rejected the post with a helpful message. Happy days.

I was just writing a reply to Delta-G offering to do the same thing, but in VB.Net. Watch this space.

Again, good stuff (and they said it was difficult).

Steve



RuskinF

Yes, I am sure it can be done. But only if this thread is made to reach the the ones who control this forum and if they will to do it.

Go Up