Page 1 of 1

HOW TO: Ignore specified HTML segments/sections in documents

Posted: Fri Dec 02, 2005 9:26 am
by Albert Wiersch
Here's a little "trick" that most people aren't aware of. If you have a certain part or section of an HTML or XHTML document that you want CSE HTML Validator to ignore, then you can enclose it in "cseignore" tags.

Example:

Code: Select all

<cseignore>bad HTML here</cseignore>
or
<!--cseignore-->bad HTML here<!--/cseignore-->
In v8.04 and above, for better compatibility with other syntax checkers and validators, <!--cseignore--> (case sensitive) can be used to simulate a <cseignore> start tag and <!--/cseignore--> (case sensitive) can be used to simulate a </cseignore> end tag. (New v8.04)

NOTE: This works only with CSE HTML Validator's own validator engine. HTML Tidy, nsgmls, JavaScript Lint, PHP, etc will not understand these special tags and comments.

If using JavaScript Lint for JavaScript checking, then you can use this to ignore part of a document:

Code: Select all

/*jsl:ignore*/
(code that fires warnings)
/*jsl:end*/
For more information (JavaScript Lint):
http://www.javascriptlint.com/docs/index.htm

Re: HOW TO: Ignore specified HTML segments/sections in documents

Posted: Fri Jan 15, 2010 1:35 pm
by RSteinwand
Hi Albert,

I still get a HTML Tidy warning with this:
<!--cseignore-->
<link type="text/css" media="all" href="/css/<%= InsertCSS() %>" rel="stylesheet" />
<!--/cseignore-->

... and get a Javascript SyntaxError with this:
<!--cseignore-->
<div id="nav"><script type="text/javascript"><%= InsertMenu() %></script></div>
<!--/cseignore-->

If you have code to comment out the non-CSE parts (like HTML Tidy or nsgmls), maybe you can add that to this thread as well?

Re: HOW TO: Ignore specified HTML segments/sections in documents

Posted: Fri Jan 15, 2010 9:39 pm
by Albert Wiersch
Thanks Rick, I've added this:
NOTE: This works only with CSE HTML Validator's own validator engine. HTML Tidy, nsgmls, JavaScript Lint, PHP, etc will not understand these special tags and comments.

I've also added information about ignoring part of a document with JavaScript Lint. I don't believe the other checkers support ignoring parts of a document.

Re: HOW TO: Ignore specified HTML segments/sections in documents

Posted: Wed Jan 20, 2010 6:27 am
by roedygr
There is a catch. cseignore will not let you get away with high bit characters.

Re: HOW TO: Ignore specified HTML segments/sections in documents

Posted: Wed Jan 20, 2010 11:21 am
by Albert Wiersch
roedygr wrote:There is a catch. cseignore will not let you get away with high bit characters.
True. I've added this to the documentation:
NOTE: Does not ignore "high ASCII characters" for the "high ASCII" character check, if enabled.