Page 1 of 1
[Syntax="HTML"] errors
Posted: Wed Aug 22, 2007 1:39 am
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>
Posted: Wed Aug 22, 2007 4:19 am
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>
Posted: Wed Aug 22, 2007 6:59 am
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.
Posted: Wed Aug 22, 2007 7:02 am
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

Posted: Wed Aug 22, 2007 7:18 am
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.
Posted: Wed Aug 22, 2007 7:43 am
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.
Posted: Wed Aug 22, 2007 10:25 am
by Ollie Saunders
Nah it would take ages.
Posted: Wed Aug 22, 2007 2:56 pm
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.
Posted: Wed Aug 22, 2007 5:30 pm
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.
Posted: Wed Aug 22, 2007 5:37 pm
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
Posted: Wed Aug 22, 2007 5:41 pm
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.
Posted: Wed Aug 22, 2007 6:38 pm
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
Posted: Wed Aug 22, 2007 7:43 pm
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.
Posted: Thu Aug 23, 2007 9:16 am
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.