Whitespace Removal

In-between the tags that GoHT creates it will leave in the whitespace that you have used. This is going to be fine in most cases. However, there are times when you will want to remove the whitespace. This is done by using either of the greater-than > or lesser-than < characters.

Removing Whitespace Around Tags

To remove whitespace outside of tags, you can use the greater-than > character.

%p Normal whitespace
%p> Outside whitespace will be removed
%p Normal whitespace

renders as:

<p>Normal whitespace</p><p>Outside whitespace will be removed</p><p>Normal whitespace</p>

The middle paragraph removed the surrounding whitespace, so now all three paragraphs are on the same line.

Had it been the last paragraph that had the greater-than > character, then the whitespace after the paragraph would have been removed.

%p Normal whitespace
%p Normal whitespace
%p> Outside whitespace will be removed

it would have rendered as:

<p>Normal whitespace</p>
<p>Normal whitespace</p><p>Outside whitespace will be removed</p>

Removing Whitespace Inside Tags

To remove whitespace inside tags, you can use the lesser-than < character.

%p
  Normal whitespace
%p<
  Inside whitespace will be removed
%p
  Normal whitespace

renders as:

<p>
  Normal whitespace
</p>
<p>Inside whitespace will be removed</p>
<p>
  Normal whitespace
</p>

There is no difference in the above and this:

%p
  Normal whitespace
%p Inside whitespace never existed
%p
  Normal whitespace

renders as:

<p>
  Normal whitespace
</p>
<p>Inside whitespace never existed</p>
<p>
  Normal whitespace
</p>

You’re more likely to want to remove the whitespace between tags when you are nesting them.

%p<
  %span 
    This span is contained!

renders as:

<p><span>
  This span is contained!
</span></p>

The whitespace between the p and span tags has been removed but the whitespace inside the span tag has been left in place.

Combined

You can use both the greater-than > and lesser-than < characters together. The order that you use them will not matter. Use <> or >< as you see fit.

%p
  %span<> 
    This span is contained!

renders as:

<p><span>This span is contained!</span></p>

We’ve removed the whitespace outside the span tag because it used the greater-than > character, and we’ve removed the whitespace inside the span tag because it used the lesser-than < character.