Page 1 of 2

Old posts syntax highlighting issues

Posted: Mon Mar 29, 2010 3:00 am
by VladSun
viewtopic.php?f=2&t=114380&p=599351

I have an SQL code in my post - now it's absolutely unreadable :(

The same applies to viewtopic.php?f=50&t=113253 - even PHP blocks are a mess.

Re: Old posts syntax highlighting issues

Posted: Mon Mar 29, 2010 12:14 pm
by Benjamin
Yeah phpBB actually saves these posts in the database with the html added and line feeds removed. I'm not aware of any method to migrate these to the new format. I resaved all the posts in the second thread. This removed the html but did not restore the line feeds.

Re: Old posts syntax highlighting issues

Posted: Mon Mar 29, 2010 1:54 pm
by VladSun
Hm, when I try to edit my old posts they are still "well-formated" - i.e. it's a plain text surrounded with [ php ] BBtags ... Does phpBB do some "reverse" formatting? I'm not very familiar with phpB, but it seems very hard yo me to do a "reverse formatting" from an HTML to a plain BBcode/plain text. Even if it's done this way, can't you use it to "reformat" to the new version?

Re: Old posts syntax highlighting issues

Posted: Mon Mar 29, 2010 2:56 pm
by Benjamin
Yes, it actually does that. Either by removing the HTML or somehow parsing it. I haven't had time to dig around in the code in order to figure out how it all works. Even the

Code: Select all

tags are assigned their own unique ID's, which seems pointless to me.

Re: Old posts syntax highlighting issues

Posted: Tue Mar 30, 2010 2:28 am
by VladSun
VladSun wrote:Hm, when I try to edit my old posts they are still "well-formated" - i.e. it's a plain text surrounded with [ php ] BBtags
Blah, they are not so well-formatted - the new lines are missing.

Re: Old posts syntax highlighting issues

Posted: Tue Mar 30, 2010 1:09 pm
by josh
The new formatting is great and all, but I don't see why adding a new format has to break the old one, regardless of what phpbb does internally. Just allow the html....

100,000s of thousands of posts are now essentially destroyed....

I don't know what the purpose of coming on this site is if our posts are going to be destroyed by future enhancements.

Re: Old posts syntax highlighting issues

Posted: Tue Mar 30, 2010 1:11 pm
by Benjamin
I agree. I didn't write the code. Unfortunately, we had to upgrade the forums. Perhaps you can research a fix?

Re: Old posts syntax highlighting issues

Posted: Tue Mar 30, 2010 1:23 pm
by Benjamin
Tell you what, I'll take another look at the old records as compared to the new records and report my findings. Perhaps we can write a script to reformat them.

Re: Old posts syntax highlighting issues

Posted: Tue Mar 30, 2010 1:48 pm
by AbraCadaver
It seems to be how the code tags were entered. See here, mine look fine and weiry's look bad: viewtopic.php?f=1&t=109717

The only way I've ever included code is with the

Code: Select all

 tags, [code=php ], [code=sql ], etc...  Were there other ways to do code blocks?

[syntax=php]echo "Testing old [ code=php ] way"; [/syntax]

Re: Old posts syntax highlighting issues

Posted: Tue Mar 30, 2010 1:52 pm
by Benjamin
Yes. His use php bb tags, while yours used code=php tags.

Re: Old posts syntax highlighting issues

Posted: Tue Mar 30, 2010 1:54 pm
by Weirdan
AbraCadaver wrote:Were there other ways to do code blocks?

Code: Select all

, [sql]

Re: Old posts syntax highlighting issues

Posted: Fri Apr 02, 2010 11:05 am
by minorDemocritus
I noticed that when I use the [ syntax=php ] form for code blocks, it doesn't give line numbers. Is there any way to add that in, or am I doing it wrong?

I was trying to get the (apparently) old [ code=php ] form to work, but it ate all my code. :banghead: I think the parser doesn't like something in my large code block over in the Coding Critique section... [ syntax=php ] works, but without line numbers, and if i replace [ syntax=php ] bbcode with [ code=php ], previewing eats all my code. Any suggestions?

Re: Old posts syntax highlighting issues

Posted: Sun Apr 04, 2010 4:28 am
by minorDemocritus
I think the most problematic instance of this is in the Tutorials, as well as the stickies and guidelines. Some of the tutorials seem VERY helpful, but alas, the code blocks are broken!

I'd like to help out with this issue. Should I just report very helpful posts that are stricken with the problem, or is the something more I can do?

I noticed that if you quote one of these problem posts, the editor doesn't keep the HTML mess, it just shows what (I assume) the original contents of the code block is, inside the bbcode tags. So, it should be pretty simple to replace:

Code: Select all

[syntax=php]or
[/syntax]
...with the corrected bbcode tags.

I hesitate to start work on coding a routine for that, since I'm not that familiar with the interworkings of phpBB. I'll get started on learning it, so hopefully I can help out more.

EDIT: OK, wow. I realized that most of the stuff I'm saying was covered days ago, in this very thread. I've got to stop feeling helpful at 4 in the morning. Please forgive, I promise I mean well.

Re: Old posts syntax highlighting issues

Posted: Sun Apr 04, 2010 6:34 pm
by josh
minorDemocritus wrote:I think the most problematic instance of this is in the Tutorials, as well as the stickies and guidelines. Some of the tutorials seem VERY helpful, but alas, the code blocks are broken!
Exactly, For every post that someone made sticky there were 1,000 other that individual people had bookmarked, taken time to write as "notes to themselves", etc.. All gone. :nono:
I noticed that if you quote one of these problem posts, the editor doesn't keep the HTML mess, it just shows what (I assume) the original contents of the code block is, inside the bbcode tags. So, it should be pretty simple to replace:
Exactly. 1 line of code to run old posts thru html_entity_decode http://www.php.net/manual/en/function.h ... decode.php (or bypass whatever is escaping it in the first place).

There is no reason NOT to do this. If you're worried about someone hacking the site thru editing of their old posts you can use HTML purifier or equivalent.

In my opinion this change should be reverted. I'd rather go back to what we had then loose 100s of thousands of posts. As a forum of programmers, we should have tested & thought about the possible consequences before making an abrupt change to a new syntax highlighter that broke backwards compatibility.

Like I said, I am appreciative of the attempted good deed, but whoever made the call to move forward on a new editor, should step up to the plate/man up and fix this or revert it out.

Re: Old posts syntax highlighting issues

Posted: Sun Apr 04, 2010 11:32 pm
by Benjamin
Great theory, however the line feeds are not in the database.