dougouqin0763 2014-02-10 20:41
浏览 42
已采纳

在PHP的GeSHi中设置<PRE>标签的最大宽度

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?

  • 写回答

1条回答 默认 最新

  • douchong8393 2014-02-10 20:46
    关注

    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 */
      }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行