javascript 美化文本区域内的代码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11767305/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 14:17:07  来源:igfitidea点击:

Prettify code inside a textarea

javascript

提问by Alaa Gamal

i have found this project

我找到了这个项目

http://code.google.com/p/google-code-prettify/

http://code.google.com/p/google-code-prettify/

i've tested it and it works fine

我已经测试过了,它工作正常

but it only works with (<pre>)

但它只适用于 ( <pre>)

i want use it with (<textarea>)

我想和 ( <textarea>) 一起使用

but if i replace <pre>to <textarea>

但如果我替换<pre><textarea>

it's not working !!

它不工作!

So how to use this script with textarea?

那么如何在 textarea 中使用这个脚本呢?

回答by Prasanth

Have you tried codemirror?

你试过代码镜像吗?

It does what you want: prettifycode in textarea.

它做你想做的事:美化textarea 中的代码。