JDK-8002387 : Improve rendered HTML formatting for {@code}
  • Type: Bug
  • Component: tools
  • Sub-Component: javadoc(tool)
  • Affected Version: 8
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2012-11-07
  • Updated: 2015-05-27
  • Resolved: 2013-05-03
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8 b91Fixed
Related Reports
Blocks :  
Relates :  
Description
Multi-line blocks of example code within:

<pre>{@code
line1...
line2...
line3...
}</pre>

are indented differently than when put in just <pre></pre>.  In particular, the first line is not indented.

For an example of the problem, see example.txt for the JavaDoc and rendered .html, and screenshot.png for how this looks in the browser.

I believe this could be fixed if the line break following <pre>{@code were carried over to the .html.  For example:

 <pre><code>DateFormat preCode = DateFormat.getDateInstance();

would become:

 <pre><code>
DateFormat preCode = DateFormat.getDateInstance();

Comments
Can/should scan text outside inline tags for <pre> and honor whitespace if {@code...} is in <pre>
30-04-2013

Bumped up priority because this is a potential blocker for those working on fixing doclint comments
06-04-2013

Needs to be fixed for JDK 8.
07-11-2012

Currently, whitespace between the tag name and tag content is discarded in com.sun.tools.javadoc.Comment#getInlineTags, c. line 323, leading to the observed effect. The simplest hack solution is to detect if the inline tag is immediately preceded by <pre> (ignore case), and if so, don't skip the whitespace between the tag name and content. A more sophisticated solution would be a more tolerant recognition of an open <pre> tag, but that seems best deferred for now.
07-11-2012