简体   繁体   中英

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. I followed the instructions at 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. However, the generated SPAN tags miss the class attribute and thus the CSS cannot prettify it. Also I recognized that the SPAN tags should probably be generated in lowercase, but they are in uppercase.

Any clues what might be wrong?

OK, I got it: The document was starting with an XML declaration:

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

This seems to confuse the Javascript code somehow. Once I removed the declaration, the highlighting worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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