jafartke / google-code-prettify

Automatically exported from code.google.com/p/google-code-prettify
Apache License 2.0
0 stars 0 forks source link

Fails to handle less-than in certain circumstances #338

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

<!DOCTYPE html>
<head><script 
src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></s
cript></head>
<body>
<pre class="prettyprint lang-java">
for(int i = 0; i <things.length; i++)
</pre>
</body></html>

What is the expected output?  What do you see instead?

The expected output is the line of Java code normally highlighted. The actual 
output is "for(int i = 0; i"

What version are you using?  On what browser?

Whatever version is currently at 
https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js

Browser: Chrome and Firefox both have the issue. Other browsers not tested.

Please provide any additional information below.

The following work fine:

for(int i = 0; i < things.length; i++) // with a space after the less-than
for(int i = 0; i <10; i++) // with a number instead of a variable

Original issue reported on code.google.com by paul....@gmail.com on 16 Mar 2014 at 10:14

GoogleCodeExporter commented 8 years ago
Sorry, the test case above is flawed. The less-than sign in HTML is not legal 
and should have been escaped. I had tried to extract a minimal test case from 
my application and didn't get it quite right.

In my app I am loading source code over Ajax, and passing it into 
prettyPrintOne(). Now, for this to work correctly I need to HTML escape the 
source code before I pass it in. It seems counter-intuitive that I need to do 
that, and the documentation does not mention it. I suggest you either change 
prettyPrintOne() so this isn't required, or update the docs to make it clear 
you need to do this. Thanks.

Original comment by paul....@gmail.com on 17 Mar 2014 at 11:26

GoogleCodeExporter commented 8 years ago
I'm glad you got it working.

Original comment by mikesamuel@gmail.com on 17 Mar 2014 at 5:45