Lifelesspeople.com

 Forum FAQsForum FAQs  Knowledge BaseKnowledge Base  RulesRules   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   HostingHosting   RegisterRegister 
 DonateDonate   WikiWiki   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PHP highlight_string() not wrapping text

 
Lifelesspeople.com Forum Index -> Web Architects' Abode
Post new topic   Reply to topic View previous topic :: View next topic  
Author Message
Scott
tutorialtoday.com


Joined: 24 Mar 2005
Posts: 2593
Location: Mississauga, Ontario

PostPosted: Wed Jan 30, 2008 4:19 pm    Post subject: PHP highlight_string() not wrapping text Reply with quote

For some reason the code won't wrap when it is highlighted.

http://www.tutorialtoday.com/read_tutorial/7/

As you can see here, long strings won't wrap even though there are spaces and it has a set width.
_________________
Tutorial Management Script - Version 1.3 Released
TutorialToday - Up and running, submit your tutorials!
Linux Tutorials - Coming Soon
Back to top
 
ClickFanatic
Est. 2005


Joined: 18 Jan 2005
Posts: 3877
Location: A particular geographic area

PostPosted: Thu Jan 31, 2008 7:11 am    Post subject: Reply with quote

That is because the function inserts one or more non-breaking-spaces ( ) for white-space characters (spaces and tabs) in the code.
These special characters will prevent the line from wrapping regardless of the CSS applied.

Here are your options:
- use CSS (overflow: auto;) to force scroll bars.
- use GeSHi for your syntax highlighting needs.

I would recommend the second option. GeSHi is very customisable and supports many more languages than just PHP.
_________________
Captain Jell-O Buster from the Future
[img]http://feeds.feedburner.com/sparepencil.1.gif[/img]
Back to top
 
Scott
tutorialtoday.com


Joined: 24 Mar 2005
Posts: 2593
Location: Mississauga, Ontario

PostPosted: Thu Jan 31, 2008 8:40 am    Post subject: Reply with quote

I just used the overflow:auto; and it works now, thanks.
_________________
Tutorial Management Script - Version 1.3 Released
TutorialToday - Up and running, submit your tutorials!
Linux Tutorials - Coming Soon
Back to top
 
krt
...


Joined: 11 Jan 2005
Posts: 4619
Location: Down Under

PostPosted: Thu Jan 31, 2008 6:32 pm    Post subject: Reply with quote

Good coding practice dictates line lengths should not be over a certain length anyway, e.g. 80 characters, but then, you probably won't be the only one writing the code to be submitted so either replace single   with an actual space or use a more suitable highlighter.

I never really liked highlight_string() for anything beyond trivial tasks anyway, even though many issues with it have been fixed, and besides, it only applies to PHP code which is not very useful for a tutorials site that will probably have code in many other languages, at least HTML.
Back to top
 
Display posts from previous:   
Post new topic   Reply to topic    Lifelesspeople.com Forum Index -> Web Architects' Abode All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Home | Hosting | News | Forum | Links | System Status | About | Archive | Donate ]
Powered by phpBB © 2001, 2002 phpBB Group
All trademarks and copyrights on this page are owned by their respective owners. Posts and comments are owned by the poster. Everything else © 2001 - 2007 Lifelesspeople.com