[Syntax="HTML"] errors

We know you have an opinion on how things should be run around here. These are suggestions for the forums, and the website.This forum is not a place to ask for suggestions to your own coding (or otherwise) problems.

Moderator: General Moderators

Post Reply
ReDucTor
Forum Commoner
Posts: 90
Joined: Thu Aug 15, 2002 6:13 am

[Syntax="HTML"] errors

Post by ReDucTor »

Well after being told that I'm breaking the rules too many times because I use code tags, and constantly having my posts edited to syntax="html"

I started to notice the syntax="html" dont work properly

Code: Select all

<script language="text/javascript">
if(black<green)
alert("color change");
alert("broken tags <b>");
</script>
WTF?! This crap is <b>broken</b>

Code: Select all

<script language="text/javascript">
if(black<green)
alert("color change");
</script>
This is <b>semi</b> working?!

Code: Select all

<script language="text/javascript">
x = "black&orange";
</script>
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Nor does PHP :)

Code: Select all

?>
<a href="<?php echo $blah ?>"><!-- that's php in there not an HTML string -->
<?php
echo "$var"; 
echo "{$var['foo']}";

btw that last one is invalid it should be

Code: Select all

<script language="text/javascript">
x = "black&orange";
</script>
Unless you use a CDATA section

Code: Select all

<script language="text/javascript"><[CDATA[
x = "black&orange";
]]></script>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The HTML tags work just fine. Your problem is the fact that you've included Javascript which will not parse as HTML. The same goes for PHP in HTML. There is little to nothing we can do.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

I've noticed that UNION and other keywords in syntax="sql" block are no highligted.

PS: @feyd - Posts: 29997, still 3 to go :)
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

feyd wrote:The HTML tags work just fine. Your problem is the fact that you've included Javascript which will not parse as HTML. The same goes for PHP in HTML. There is little to nothing we can do.
That's very defeatest. The Zend Studio IDE copes with everything I've just mentioned and more. So clearly it is possible, in fact with enough time and will I could do it myself.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

ole wrote:That's very defeatest. The Zend Studio IDE copes with everything I've just mentioned and more. So clearly it is possible, in fact with enough time and will I could do it myself.
No, it's being realistic and understanding the plugin that's used for highlighting does not understand multiple languages in a single snippet. It would have to know a lot more in order to highlight everything perfectly.

However, if you wish to make a better highlighter that supports context sensitive highlighting and all the languages we support like that, be my guest.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Nah it would take ages.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

A simpler refinement to the algorithm would be to detect instances of <script> and then highlight it as a script until a "</script>" string is encountered.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Ambush Commander wrote:A simpler refinement to the algorithm would be to detect instances of <script> and then highlight it as a script until a "</script>" string is encountered.
The highlighter is a fairly basic lexer with very little understanding of the data it is parsing. It would likely require a fairly significant modification.
ReDucTor
Forum Commoner
Posts: 90
Joined: Thu Aug 15, 2002 6:13 am

Post by ReDucTor »

Where is the lexical parser which is used on the forum, so we can see just how much will need to be modified?

Because It looks rather ugly when most the times i use the syntax tags the syntax highlighting just screws up and looks worse then if I use code tags
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

It's called Geshi. A simple web search will show you how to get the code.

Note that we are using the phpbb mod form, which is a bit older than the most recent release of Geshi.
ReDucTor
Forum Commoner
Posts: 90
Joined: Thu Aug 15, 2002 6:13 am

Post by ReDucTor »

Testing.

Code: Select all

<script language="text/javascript"><!--
if(black<green)
alert("color change");
alert("broken tags <b>");
--></script>
WTF?! This crap is <b>broken</b>

Code: Select all

<script language="text/javascript"><!--
if(black<green)
alert("color change");
--></script>
This is <b>semi</b> working?!

Code: Select all

<script language="text/javascript"><!--
x = "black&orange";
--></script>
If this displays properly, wouldnt be hard to modify the 'COMMENT_MULTI' handler to take that block and run it through the Javascript syntax highlighter.

btw. Upgrading Geshi fixes some of the problems
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

ReDucTor wrote:If this displays properly, wouldnt be hard to modify the 'COMMENT_MULTI' handler to take that block and run it through the Javascript syntax highlighter.
That would have repercussions for the other syntaxes though.
ReDucTor wrote:Upgrading Geshi fixes some of the problems
We're holding off on making modifications until after we've settled on the phpbb 3 upgrade, I believe. phpbb 3's variant is newer, if I recall.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

GeSHi is a part of phpBB? I did not know that.
I'd think that parsing <script> inside of HTML wouldn't be too difficult if GeSHi didn't always do all of the work, such as adding the surrounding tags and such.
Post Reply