dongnuoyi8833 2012-01-14 23:01
浏览 33
已采纳

在textarea中使用geshi

Yes, sound weird. But I'm trying to make a text editor inside the browser. I've seen some programs use it. Like wordpress and unet. But I'm not sure if they use a custom one or not. However, this topic explains why geshi won't work in textarea: Why isn't textarea an input[type="textarea"]? I simply get the code of the colors. Just wondering if there's a way around this. I've tried searching but I was without luck.

<textarea><?php geshi_highlight($source, 'php'); ?></textarea>

edit::the variable $source contains php code.

Output is basically the span style that geshi outputs.

  • 写回答

1条回答 默认 最新

  • douyamitong57935 2012-01-14 23:14
    关注

    That kind of formatting does not work in a textarea, that's one its properties. You probably want to make some HTML contentEditable, but it won't work quickly out of the box, there needs to be a mechanism where an alteration triggers new highlighting. And that would probably involve a lot of traffic to and from the server, to the point of it not being a viable solution. You probably would end up using a javascript syntax highlighter like http://jush.sourceforge.net/ or others, and I haven't actually seen a 'live' syntax highlighter editor in the wild yet (as in: only plain textareas with a syntax-highlighted 2nd box), but then again I've never been searching for it.... I like my editors local ;).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵