简体   繁体   English

google-code-prettify不会将类添加到Java代码的SPAN标记中

[英]google-code-prettify doesn't add the classes to SPAN tags for Java code

I'm trying to integrate google-code-prettify to my site in order to prettify Java code. 我正在尝试将google-code-prettify集成到我的网站中,以美化Java代码。 I followed the instructions at http://google-code-prettify.googlecode.com/svn/trunk/README.html . 我按照http://google-code-prettify.googlecode.com/svn/trunk/README.html上的说明进行操作。 I can verify that I get SPAN elements for the tokens in the code samples, so the lexing seems to work. 我可以验证是否在代码示例中获得了令牌的SPAN元素,因此词法似乎可以正常工作。 However, the generated SPAN tags miss the class attribute and thus the CSS cannot prettify it. 但是,生成的SPAN标记缺少class属性,因此CSS无法对其进行美化。 Also I recognized that the SPAN tags should probably be generated in lowercase, but they are in uppercase. 我也认识到SPAN标记可能应该以小写形式生成,但是它们以大写形式生成。

Any clues what might be wrong? 任何线索可能有什么问题吗?

OK, I got it: The document was starting with an XML declaration: 好的,我明白了:该文档以XML声明开头:

<?xml version="1.0" encoding="UTF-8"?>

This seems to confuse the Javascript code somehow. 这似乎使Javascript代码有些混乱。 Once I removed the declaration, the highlighting worked. 删除声明后,突出显示起作用了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM