%%% How to make a box disappear at a line break

Let us consider the problem of marking spaces in a paragraph with some
symbol, like in the following example:

\medskip
\begingroup
\obeyspaces
\def {%
\setbox0\hbox{$\cdot$}%
\dimen0=\wd0\relax
\hskip1ptplus2pt%
\cleaders\box0\hskip\dimen0%
\hskip1ptplus2pt%
}\line{\hfil\vbox{\restorefont{rm}\rm\hsize9.5cm\parindent0pt%
Ten typowy testowy akapit tekstu daje przy okazji rodzaj filigranowego %
wysypu hodowli pieczarek w zielonym kasztanie regloryfikacji %
stanowisk ministerialnych i podsypanych minimalistom jako fetysz %
zaduchu studziennych barykad.}\hfil}
\endgroup
\medskip

The hard part is to make the symbol disappear when such a ``space'' occurs at
a line break.  We cannot use \verb|\discretionary| for that purpose since we
need the ``space'' to be stretchable to make justification possible.
Moreover we want to be able to associate some penalty (e.g., 0) with our
breakpoints other than \verb|\(ex)hyphenpenalty|.
\medskip
As it turns out any box can be made discardable by putting it into
\verb|\cleaders| to the exact width of the box in question.  According to his
rules \TeX\ will put exactly one copy of the box in the text. So the
construct will look exactly like the box itself but will behave like a glob
of glue. In particular it will disappear at a line break.

Here are the macros used in the preceding passage:
\beginverbatim
\obeyspaces
\def {%
\setbox0\hbox{$\cdot$}%
\dimen0=\wd0\relax
\hskip1ptplus2pt%
\cleaders\box0\hskip\dimen0%
\hskip1ptplus2pt%
}
\rm\hsize9.5cm\parindent0pt
Ten typowy testowy akapit tekstu daje przy okazji rodzaj filigranowego %
wysypu hodowli pieczarek w zielonym kasztanie regloryfikacji %
stanowisk ministerialnych i podsypanych minimalistom jako fetysz %
zaduchu studziennych barykad.%
\endverbatim

Stretchability is achieved with separate globs of glue not to allow \TeX\ to
insert more than one copy of the box in case of an overstretched space.
\medskip
Note that this trick can be used in vertical mode as well (e.g., to separate
paragraphs with some graphical element except the case when a paragraph
boundary occurs at a page break). A discardable box can have arbitrary
complexity, it can include colour, EPS graphics, and so on.

\endinput
