Go Back   SitePoint Forums > Forum Index > Program Your Site > PHP
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Apr 11, 2005, 02:15   #1
ArticleBot
SitePoint Articles
 
ArticleBot's Avatar
 
Join Date: Apr 2001
Posts: 0
Article Discussion

This is an article discussion thread for discussing the SitePoint article, "Highlight Source Code in Your PHP Application"
ArticleBot is offline   Reply With Quote
Old Apr 11, 2005, 02:15   #2
mmj
Test cases complete. 0 fails.
 
mmj's Avatar
 
Join Date: Feb 2001
Location: Melbourne Australia
Posts: 6,721
Quote:
The resulting HTML code, after the highlighting is performed, is not XHTML-compliant. This issue is corrected in PHP5, but in PHP4, the highlighter uses the <font> tag,
The <font> element is valid in HTML 4.01 Transitional and XHTML 1.0 Transitional. Therefore the <font> element is not an XHTML specific problem and is as much a problem in HTML 4.01.

Quote:
Output is provided in XHTML format, using <span> tags for semantics and CSS styles for formatting
<span> elements provide no semantic meaning. If a <span> has a descriptive "class" attribute, then it will help humans who speak the same language to understand its purpose. However, this does not make code 'semantic'. Using <span> with some CSS is the exact equivalent of using <font>, and does not give any semantic information to the document.
mmj is offline   Reply With Quote
Old Apr 11, 2005, 14:18   #3
joern_h@gmx.net
SitePoint Community Guest
 
Posts: n/a
See http://planetxml.de/highlighter/ for another highlighting script. Its a new Driver for PEARs highlighter that uses the syntax descriptions of the KDE editor. The first two files in the list show the source code and the usage.
  Reply With Quote
Old Apr 14, 2005, 10:31   #4
devon
SitePoint Community Guest
 
Posts: n/a
Regarding the posting by mmj...

Use of the <span> tag as opposed to <font> is not intended to provide semantics, it is to describe the code as device independent. Consequently, there is in fact a large difference between <span> and <font>. <font> is exclusively related visual presentation, whereas <span> is a delineation that can be rendered by any form of user agent, including a screen reader, based on the associated css. While this is not necessarily an important consideration to a script that is intended to display based on color-coding, by using <span>, one could apply an aural css with different vocal emphasis representing the different tokens, and thus make reading a php script accessible to a visually impaired programmer. Similarly, any future technologies relating to Web access will be able to apply relevant CSS information to the classes, and render the code appropriately.

One other note: while you stated that <font> is valid in HTML 4.01 and XHTML 1.0, in both of these specifications, it is flagged as deprecated, meaning that its existence will not be guaranteed in future versions of either spec. Preparing for the future is an important tool of any responsible Web professional!
  Reply With Quote
Old Apr 15, 2005, 00:44   #5
johno
SitePoint Zealot
 
johno's Avatar
 
Join Date: Sep 2003
Location: Bratislava, Slovakia
Posts: 185
Check out this one http://hvge.sk/scripts/fshl/
Supports multiple and mixed languages and compared to GeSHi it's really fast. I mean REALLY FAST.

Online example is at http://hvge.sk/scripts/fshl/online/
johno is offline   Reply With Quote
Old Apr 20, 2005, 23:36   #6
Kadence
SitePoint Addict
 
Join Date: Nov 2004
Location: New Jersey
Posts: 302
This is just what I've been looking for. Thanks.
Kadence is offline   Reply With Quote
Old Apr 29, 2005, 23:40   #7
Nigel McNie
SitePoint Community Guest
 
Posts: n/a
It's worth noting that future versions of GeSHi will support multiple languages in the same source - e.g. HTML, PHP, Javascript and CSS all in one - see the demo at http://geshi.org/.

Although it's slower than other solutions, good highlighting will always be an intensive process and you'd be advised to use some form of caching for highlighted text if you are not already -- Pear::Cache_Lite is just one example of a good caching solution.
  Reply With Quote
Old May 25, 2005, 12:25   #8
asp_funda
SitePoint Wizard
 
asp_funda's Avatar
 
Join Date: Jun 2003
Location: Andromeda Galaxy
Posts: 4,596
Cool

Quote:
Originally Posted by mmj
The <font> element is valid in HTML 4.01 Transitional and XHTML 1.0 Transitional. Therefore the <font> element is not an XHTML specific problem and is as much a problem in HTML 4.01.


<span> elements provide no semantic meaning. If a <span> has a descriptive "class" attribute, then it will help humans who speak the same language to understand its purpose. However, this does not make code 'semantic'. Using <span> with some CSS is the exact equivalent of using <font>, and does not give any semantic information to the document.

Looks like in his haste to write this article, Mr.Stoyan Stefanov overlooked a point or two as well a standard or two.

Anyway, its a good starter for someone starting out on syntax highlighting & doesn't know where to begin.

Also I'd like to highlight a point that Mr.Stoyan Stefanov overlooked. The Enscript utility mentioned at the end of the article is a *NIX only, that is, it runs only on UNIX & LINUX. so unless you are not on one of those platforms, ... Also, I don't think its extendable, the plugin I mean, you are restricted with the languages that are supported by Enscript & unless you have root permissions to your server, you can't mod it.

This thing is what bugged me when I wanted syntax highlighting for a bit or two of code that I post on my blog. B'coz I needed to test it locally as well. Then GeSHi crossed my path & I based my syntax-hiliting plugin for WordPress on it. If anyone is interested, its link is in my signature.
asp_funda is offline   Reply With Quote
Old Jul 7, 2005, 02:55   #9
macleo
SitePoint Member
 
Join Date: Jul 2005
Posts: 2
thanks !very beautifully!
macleo is offline   Reply With Quote
Old Sep 29, 2005, 00:43   #10
itaym02
SitePoint Member
 
Join Date: Jul 2004
Location: Rehovot
Posts: 12
helps - thanks
itaym02 is offline   Reply With Quote
Old Oct 13, 2006, 03:37   #11
dscriptor
SitePoint Evangelist
 
dscriptor's Avatar
 
Join Date: Oct 2005
Location: in front of my computer
Posts: 570
this is great!
dscriptor is offline   Reply With Quote
Old Jun 8, 2007, 05:39   #12
object_freedom
SitePoint Community Guest
 
Posts: n/a
thanks 4 helps,
very great!!
  Reply With Quote
Old Sep 16, 2007, 02:12   #13
Anonymous
SitePoint Community Guest
 
Posts: n/a
good introduction, help me much
  Reply With Quote
Old Dec 1, 2008, 12:52   #14
softexp23
SitePoint Community Guest
 
Posts: n/a
Great article !
What if you want to hilight a file where php and html coexist ?
  Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 18:11.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved