Pregunta

I'm working on a job board that accepts API posts from a number of other services. We are constantly having trouble with the html that is received, eg <div> tags not being closed, inline CSS styles being used etc.

Each service we receive from has it's own rules and quirks. The problem is compounded because end users are copy/pasting from Word files into their wysiwyg editors, and only then do they get sent to us!

It seems that the only robust solution is to strip all of the html. But that annoys users because all their bullets, bold text and headings are missing.

I've tried to use formulas that replace <p> tags with line breaks and suchlike but I've never managed to make it work satisfactorily.

Can anybody suggest an approach or solution that has worked for them?

I'm specifically looking at ways to fix bad markup, as opposed to enforce good markup. This is because on many occasions the end user is stuck with a bad system and most will not have the knowledge to understand or fix bad html.

(We're on Classic ASP and in the process of migrating to MVC.)

¿Fue útil?

Solución

Probably you can partially solve this problem by implementing something like browser quirks mode. If client sends you good enough markup then post it as "rich" markup and respond with "success". And if client sends you something too messed up - post it as striped version and respond with the markup error list. if he wants cool "rich" markup he should fix it.

Otros consejos

Display your clients responses inside iframe on your end.

Since Iframe will not interfere with your design layouts - client will see what they sent to you(and either fix their mistakes or get what they deserved) and your page will look intact and pretty.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top