nautical nautical - 7 months ago 17
HTML Question

Suppress a newline inside <pre> tags in Javadoc

I am documenting a java method using Javadoc. On occasion I use

<pre>
tags for fromatting. Inside the
<pre>
tags I use tags like
<em>
,
<b>
etc. to format the text. Sometimes the lines get very long due to the tags that do not show later. So I would like to insert a linebreak for readability in the Javadoc that will not show later. The following example shall clarify what I am trying to do:

/**
* <pre>
*
* <b><em>This</em></b> is <em><b>a</em></b> very <em><b>short</em></b> <em>sentence</em>
*
* </pre>
*


This will later show in the browser as


This is a very short sentence


As you can see, the tags make the sentence very long in the editor, so I want to insert a newline in the editor to improve readability, but it shall display as one line in the browser.

/**
* <pre>
*
* <b><em>This</em></b> is <em><b>a</em></b> <supress this newline>
* very <em><b>short</em></b> <em>sentence</em>
*
* </pre>


Is there a way to suppress a newline inside
<pre>
tags? If not, can a similar result be achieved without using
<pre>
tags?

VGR VGR
Answer

This isn’t really a javadoc question, it’s a general HTML question.

You can use an HTML comment:

/**
 * <pre>
 * 
 * <b><em>This</em></b> is <em><b>a</em></b> <!--
 * -->very <em><b>short</em></b> <em>sentence</em>
 * 
 * </pre>