![](/img/trans.png)
[英]syntax highlighting of code snippets in a web page “google-code-prettify” not working with aspx and html code
[英]Can I Google-Code-Prettify only a portion of the page? (run a javascript function on a specified portion of the page)
我正在使用google-code-prettify格式化我放置在网站上的一些代码。 该代码是由我通过javascript函数动态添加的。
该代码提交得很好……并且漂亮美观。 但是,为了使其工作,我必须运行prettyPrint();。 我插入代码后的功能。 当我这样做时,现有代码块会缩进,并为它们提供新的行号。
看起来像这样:
新插入的代码块:
1. function test(){ document.write("hello world"); }
现有的代码块变成这样:
1.
1. function test(){ document.write("hello world");}
有什么办法可以防止这种情况? 可能仅在动态插入的代码上运行该功能? 更改现有代码块的类名? (我一直不成功,也许我做错了)
将包含需要格式化的新插入代码的字符串传递给prettyPrintOne
。
本教程描述了一个实现此目的的实现: 语法突出显示Google Prettify的la StackOverflow 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.