Reputation: 19765
Yes, I am struggling with displaying data from our database that CONTAINS markup! One particular field I am displaying has an open-bold tag but no close bold tag. I am trying to 'contain' this markup so it doesn't affect the rest of the page.
The data coming from my database is like this text:
this is soem nasty <b>data
(note the lack of a closing < /b > tag)
If I enclose the markup in a div, the rest of the page is bold:
<div>this is some nasty <b>data</div>
However if I wrap it in a table like this:
<table><tr><td>this is some nasty <b>data</td></tr></table>
All is well! In fact, the DOM inspector for both FF (FireBug) and IE9 show the tree. In the div-case, it shows the open-b tag and the rest of the document contained within it. But the table seems to enclose it.
How can I get this to 'close the b' without a table?
Upvotes: 1
Views: 52
Reputation: 19765
I took a cue from HTML rich-text editors like TinyMCE and built up an IFrame. It seems to contain the arbitrary, possibly-mal-formed content better.
Upvotes: 0
Reputation: 5253
I've read somewhere that HTML Purifier should be able to achieve this. Might be worth trying.
Upvotes: 0
Reputation: 174977
You use a closing </b>
tag properly, like any sane human being.
You can use DOMDocument
and tidy
to try and fix the malformed markup in case you have no control over it, but it's best if you could fix it before it got to your database.
Upvotes: 1