在文本区域内使用 geshi
是的,听起来很奇怪。但我正在尝试在浏览器中创建一个文本编辑器。我见过一些程序使用它。比如 wordpress 和unet。但我不确定他们是否使用定制的。 然而,本主题解释了为什么 geshi 不能在 textarea 中工作: 为什么 textarea 不是输入[type="textarea"]? 我只是得到了颜色的代码。只是想知道是否有办法解决这个问题。我尝试过搜索,但没有运气。
<textarea><?php geshi_highlight($source, 'php'); ?></textarea>
编辑::变量 $source 包含 php 代码。
输出基本上就是geshi输出的span风格。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这种格式在文本区域中不起作用,这是它的属性之一。您可能想要制作一些 HTML
contentEditable
,但它不会开箱即用,需要有一种机制可以让更改触发新的突出显示。这可能会涉及大量进出服务器的流量,以至于它不是一个可行的解决方案。您可能最终会使用 JavaScript 语法荧光笔,例如 http://jush.sourceforge.net/ 或其他,而且我实际上还没有在野外见过“实时”语法突出显示编辑器(例如:只有带有语法突出显示的第二个框的纯文本区域),但话又说回来,我从来没有在寻找它......我就像我的本地编辑一样;)。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 ;).