...

View Full Version : is there a way to tell validator to ignore deliberate markup validation errors?



ptrcao
02-12-2011, 12:12 PM
is there a way to tell validator to ignore deliberate markup validation errors?

all the time, there are non-html codes on my page which don't comply with html validation, but nonetheless get picked up as such. they have a legit role amongst my html and can't be done away with. eg thirdparty widgets, math markup, etc.

it's annoying for 3 reasons: firstly people in this forum will be led to misperceive me as sloppier than i actually am and don't take me as seriously; second SEO takes a hit, and lastly, it's hard to comb thru a page of hundreds of markup errors just to find the genuine errors i'm interested in fixing.

VIPStephan
02-12-2011, 01:02 PM
OK, I assume you’re talking about the site in your signature and I validated the differentiation intro page (http://www.mathannotated.com/page.html?topic=differentiation&subtopic=introduction), and really, most of the errors don’t seem deliberate due to any math markup or third party widgets (FB Like button) but simply because you:


Forgot to encode special characters as HTML entities (like ampersands as &amp;, < as &lt; etc.)
Are using an inline frame although this is not allowed with a strict doctype (OK, I see this is from an Amazon widget)
Didn’t to implement the FB Like button properly, using the respective xmlns attribute in your opening <html> tag (and putting the respective meta tags which apparently don’t validate by themselves but with a little workaround: http://stackoverflow.com/questions/2761622/new-facebook-like-button-html-validation#answer-3221120)
Forgot to close some elements properly.


You can get rid of most of the errors already if you encode any occurrence of & as &amp;. It’s unfortunate that Amazon provides an iframe for the widget but if you really need the pages to validate then add that iframe with JS or something. I’m kinda happy that you are using the XHTML strict doctype so I wouldn’t want you to resort to transitional (where iframes – among a lot of other crap – would be regarded as valid). Another option – although I don’t know how the current state of support is (especially in IE) – is to replace the iframe with an object element since not only you can include Flash with the object element but also other things like HTML or PDF documents: http://joliclic.free.fr/html/object-tag/en/.

ptrcao
02-12-2011, 05:19 PM
Thanks VIPSteve; right, I've not been especially motivated to clean up that particular page because it's rampant with errors from the Amazon widget, making it difficult to sift through and pick up my own errors...

http://validator.w3.org/check?uri=http%3A%2F%2Fwww.mathannotated.com%2Fpage.html%3Ftopic%3Ddifferentiation%26%26subtopic%3Di ntroduction&charset=%28detect+automatically%29&doctype=Inline&group=0

To show you what I mean, it's difficult to avoid this kind of thing:

Here is an example of math markup where the "&" symbol has no choice but to remain as such; cannot encode as "&amp;" as the program reading this needs to see "&". (It's being used as an alignment marker.)
…t{conjugate}}{\text{conjugate}}$)} \\ &=\lim_{h \rightarrow 0} \frac{(16+h)-16…

I'll definitely follow up with your useful suggestions. Did the results of that validation test really suggest that my errors outnumbered the amazon widget errors? :p I didn't know my errors were that bad!

I'll definitely be interested to try your solution to clean up the path of destruction left by this troublesome little amazon widget.

VIPStephan
02-12-2011, 06:26 PM
Well, maybe it helps to denote the math markup as “character data” (CDATA – as opposed to PCDATA: parsed character data)?

http://www.devwebpro.com/to-parse-or-not-to-parse-cdata-explained/
http://en.wikipedia.org/wiki/CDATA

Should do the trick if you write it like:


<li> The gradient of tangent, denoted \( y'(x) \) is a limit of the form
<![CDATA[
\begin{align*}
\lim_{h \rightarrow 0} \frac{y_2-y_1}{x_2-x_1}
&= \lim_{h \rightarrow 0} \frac{f(x_2)-f(x_1)}{x_2-x_1} \\

&= \lim_{h \rightarrow 0} \frac{f(x_1+h)-f(x_1)}{(x_1+h)-{x_1}} \\
&= \lim_{h \rightarrow 0} \frac{f(x_1+h)-f(x_1)}{h}
\end{align*}
]]>
</li>


Now, the iframe can’t be valid in strict XHTML since it itself is not allowed. But you’ll at least get less errors if you, as I said, encode the ampersands in the URL as &amp; (don’t worry, the URL will still work) and remove the nevertheless invalid attributes like marginwidth/marginheight, etc. To get it completely valid you can try to convert the iframe to an object like this:


<object type="text/html" data="http://rcm.amazon.com/e/cm?t=mathanno-20&amp;o=1&amp;p=6&amp;l=st1&amp;mode=books&amp;search=math%20trigonometry&amp;fc1=000000&amp;lt1=&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" style="border:none; width: 120px; height: 150px;">(alternative content here, e. g. the plain link to the source)</object>


However, as proper support was always limited in some browsers, especially when it comes to styling. I don’t know how the current state is as I haven’t tried this for a few years.

ptrcao
02-12-2011, 06:42 PM
Well, maybe it helps to denote the math markup as “character data” (CDATA – as opposed to PCDATA: parsed character data)?

http://www.devwebpro.com/to-parse-or-not-to-parse-cdata-explained/
http://en.wikipedia.org/wiki/CDATA

Should do the trick if you write it like:


<li> The gradient of tangent, denoted \( y'(x) \) is a limit of the form
<![CDATA[
\begin{align*}
\lim_{h \rightarrow 0} \frac{y_2-y_1}{x_2-x_1}
&= \lim_{h \rightarrow 0} \frac{f(x_2)-f(x_1)}{x_2-x_1} \\

&= \lim_{h \rightarrow 0} \frac{f(x_1+h)-f(x_1)}{(x_1+h)-{x_1}} \\
&= \lim_{h \rightarrow 0} \frac{f(x_1+h)-f(x_1)}{h}
\end{align*}
]]>
</li>


Now, the iframe can’t be valid in strict XHTML since it itself is not allowed. But you’ll at least get less errors if you, as I said, encode the ampersands in the URL as &amp; (don’t worry, the URL will still work) and remove the nevertheless invalid attributes like marginwidth/marginheight, etc. To get it completely valid you can try to convert the iframe to an object like this:


<object type="text/html" data="http://rcm.amazon.com/e/cm?t=mathanno-20&amp;o=1&amp;p=6&amp;l=st1&amp;mode=books&amp;search=math%20trigonometry&amp;fc1=000000&amp;lt1=&amp;lc1=3366FF&amp;bg1=FFFFFF&amp;f=ifr" style="border:none; width: 120px; height: 150px;">(alternative content here, e. g. the plain link to the source)</object>


However, as proper support was always limited in some browsers, especially when it comes to styling. I don’t know how the current state is as I haven’t tried this for a few years.

Thanks, very helpful. :)

I've always been scared to edit third party scripts. I worry that Amazon might consider it a violation of their policy and cancel my account with them... Any experience with this sort of thing? In this case it seems like a trivial and superficial edit, but to be on the safe side I should establish it is ok first.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum