0

I've just noticed that tidy_repair_string() is removing my non-breaking spaces from empty elements causing my table to collapse. Basically I've put in:

<td>&nbsp;</td>

and HTML Tidy is stripping them out to:

<td> </td>

which may or may not be some Unicode break but either way it's collapsing. The only &nbsp; related option I've seen is 'quote-nbsp' but that doesn't seem to be it. I think it defaults to on anyway.

How do I keep my non-breaking spaces?

Jeff Atwood
  • 63,320
  • 48
  • 150
  • 153
cletus
  • 616,129
  • 168
  • 910
  • 942

3 Answers3

14

Apply this style, then you do not need to put content in the "empty" cells:

td { empty-cells: show; }

Sparr
  • 7,489
  • 31
  • 48
  • If i remember correctly, you're supposed to put that on the table, not the cell. – Kris Jan 15 '09 at 15:27
  • http://www.w3.org/TR/CSS2/tables.html#empty-cells Applies to table-cell elements. You typically see it applied to a row or table and inheritance takes care of the rest, but it can be applied to single cells (or, more commonly, to styles applied to single cells). – Sparr Jan 15 '09 at 22:00
  • Learned something new today. :) – Jacco Dec 24 '09 at 10:44
2

use the "bare" config option.

more information and an explanation available here: http://osdir.com/ml/web.html-tidy.user/2004-07/msg00005.html

sjstrutt
  • 5,625
  • 6
  • 25
  • 21
0

You could try the following:

$myString = str_replace(" ", "&nbsp;&nbsp;", $someText);

nickf
  • 537,072
  • 198
  • 649
  • 721
Epitaph
  • 3,128
  • 10
  • 34
  • 43