Question

I am using GeSHi for Syntax Highlighting. Is there any way to set width of PRE tag generated by GeSHi?

What I mean is I have a textarea with the width of 500px and therefore as usual text is word-wrapped for long lines. And when I send text from my TextArea to GeSHi, it generates a PRE tag highlighting my code but then it creates a long line instead wrapping like textarea does. Something like this

In below textarea, long lines are word-wrapped like

   ---------------------------------------------
   |  This world is big and we are living here |
   |  for a long long time.                    |
   |                                           |
   ---------------------------------------------

A PRE syntax highlighted code generated by GeSHi has output something like this

   ------------------------------------------------------------------
   |  This world is big and we are living here for a long long time.|
   |                                                                |
   |                                                                |
   ------------------------------------------------------------------

I want to limit this PRE tag width to 500px and word-wrap just like textarea. Is there anything possible?

Was it helpful?

Solution

I haven't used GeSHi but you can probably set some CSS for your PRE tag with this

 .wordwrap { 
     width: 500px;
     white-space: pre-wrap;      /* CSS3 */   
     white-space: -moz-pre-wrap; /* Firefox */    
     white-space: -pre-wrap;     /* Opera <7 */   
     white-space: -o-pre-wrap;   /* Opera 7 */    
     word-wrap: break-word;      /* IE */
  }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top