Bug 164259

Summary: XML in javadoc <pre/> tags keep indenting line
Product: [Eclipse Project] JDT Reporter: Ben Rowlands <ben>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: VERIFIED DUPLICATE QA Contact:
Severity: normal    
Priority: P3    
Version: 3.2   
Target Milestone: 3.2.2   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Ben Rowlands CLA 2006-11-12 09:27:23 EST
If I want to add a literal XML snippet to a javadoc comment I can place the XML inside a <pre> tag. Eclipse escapes the '<' and' '>' correctly but insists on indenting the XML to the right each time I reformat the source code. 

For example, if I type:

/**
 *  <pre>
 *    <foo/>
 *  </pre>
 */

After formatting it becomes:

/**
 * <pre>
 *  &lt;foo/&gt;
 * </pre>
 */

However subsequent re-formatting of the source file indents the XML to the each time. So after 3 reformattings, the javadoc becomes:

/**
 * <pre>
 *     &lt;foo/&gt;
 * </pre>
 */

This is very anoying as the spaces are *inside* the pre tag so show up in the generated javadocs. Additionally if the build processes includes a step to clean the source code using the formatter each build intends the line!

Note, my source formatter preferences have the following options enabled:

  * Format HTML tags
  * Format Java code snippets

Can the javadoc formatter be made smart enough not to indent the text if it is XML?

Note, if I disable the option "Format Java code snippet" the line is *not* indented (but neither is it escaped; and I really want to have Java code snippets formatted in addition to the ability to add XML examples, for example to show configuration examples or example XML output).
Comment 1 Olivier Thomann CLA 2006-11-12 14:18:09 EST

*** This bug has been marked as a duplicate of 99738 ***
Comment 2 Maxime Daniel CLA 2007-01-16 00:17:36 EST
Verified for 3.2.2 using build M20070112-1200.
Comment 3 Eric Jodet CLA 2007-02-06 02:38:15 EST
Verified for 3.3 M5 using build I20070205-0009