I've got a (large, hairy, evil) database full of raw dumps from MySQL
that look like this:
<code>
+----+----------+
| k | t |
+----+----------+
| 1 | apple |
| 2 | orange |
| 3 | pear |
+----+----------+
3 rows in set (0.00 sec)
</code>
When displayed in HTML, the extra spaces don't show, leaving this:
+----+----------+
| k | t |
+----+----------+
| 1 | apple |
| 2 | orange |
| 3 | pear |
+----+----------+
3 rows in set (0.00 sec)
Using <pre> tags won't work, due to other complications with the way
carriage returns are being automatically converted to <br> tags at the
end of each line.
Can anyone recommend a PHP preg_replace statement that would change all
spaces within <code></code> tags to nonbreaking spaces? (This
seems like it ought to be out there somewhere in dozens of examples; if
it is, please feel free to rub my nose in my failure to RTFM.)
I really want to do this with a regular expression and a bunch of other
crawling around; each data record is already filtered through
preg_replace to pop external links up in new browser windows and so
forth. It would be outstanding if I could just add another find pattern
and another replace pattern to the existing module and be done.
Thanks very much,
--Kent
that look like this:
<code>
+----+----------+
| k | t |
+----+----------+
| 1 | apple |
| 2 | orange |
| 3 | pear |
+----+----------+
3 rows in set (0.00 sec)
</code>
When displayed in HTML, the extra spaces don't show, leaving this:
+----+----------+
| k | t |
+----+----------+
| 1 | apple |
| 2 | orange |
| 3 | pear |
+----+----------+
3 rows in set (0.00 sec)
Using <pre> tags won't work, due to other complications with the way
carriage returns are being automatically converted to <br> tags at the
end of each line.
Can anyone recommend a PHP preg_replace statement that would change all
spaces within <code></code> tags to nonbreaking spaces? (This
seems like it ought to be out there somewhere in dozens of examples; if
it is, please feel free to rub my nose in my failure to RTFM.)
I really want to do this with a regular expression and a bunch of other
crawling around; each data record is already filtered through
preg_replace to pop external links up in new browser windows and so
forth. It would be outstanding if I could just add another find pattern
and another replace pattern to the existing module and be done.
Thanks very much,
--Kent
Comment