livebs / syntaxhighlighter

Automatically exported from code.google.com/p/syntaxhighlighter
GNU General Public License v3.0
0 stars 0 forks source link

Not rendering Java 5 code correctly #43

Open GoogleCodeExporter opened 8 years ago

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

1. Use the following code snippet:

<pre name="code" class="java">
package com.centuryminds.softreferences;

import java.util.ArrayList;
import java.util.List;

/**
 * A group of {@link Item}
 */
public class Group<T extends Item>
{
  private final List<T> items = new ArrayList<T>();

  public void add(T item)
  {
    items.add(item);
  }

  // other methods
  // ...
}
</pre>

What is the expected output? What do you see instead?
I would like to see the code rendered as is, but instead, I see:

# package com.centuryminds.softreferences;  
#   
# import java.util.ArrayList;  
# import java.util.List;  
#   
# /** 
#  * A group of {@link Item} 
#  */  
# public class Group<t extends="" item="">  
# {  
#   private final List<t> items = new ArrayList<t>();  
#   
#   public void add(T item)  
#   {  
#     items.add(item);  
#   }  
#   
#   // other methods  
#   // …  
# }  
# </t></t></t> 

My take is that SyntaxHighlighter does not fully support Java 5, or at
least the generics feature introduced in that version.

What version of the product are you using?

1.5.1

On what operating system?

Firefox 2.0+ on MacOS X Tiger

Original issue reported on code.google.com by ruben...@gmail.com on 9 Nov 2007 at 1:13

GoogleCodeExporter commented 8 years ago
Please fix this

Original comment by brant.bo...@gmail.com on 19 Jan 2008 at 9:02

GoogleCodeExporter commented 8 years ago
Use <textarea> instead of <pre> using highlighting Java code that uses generic.

issue is the browser treats <T extends Item> as a <T> tag with attributes 
'extends'
and 'item'

this code should work:

<textarea name="code" class="java" cols="60" rows="10">
package com.centuryminds.softreferences;

import java.util.ArrayList;
import java.util.List;

/**
 * A group of {@link Item}
 */
@WebService
public class Group<T extends Item> {
  private final List<T> items = new ArrayList<T>();

  public void add(T item) {
    items.add(item);
  }
}
</textarea>

I doubt there is a fix for this when using <pre> tag since the DOM sees <T 
extends
Item> as a XML tag.

Original comment by vaf...@gmail.com on 5 Feb 2008 at 1:46

GoogleCodeExporter commented 8 years ago
Yes, it works now, thanks!

Original comment by ffi...@gmail.com on 26 Jun 2008 at 1:24