HOW TO: Ignore specified HTML segments/sections in documents

For technical support for all editions of CSS HTML Validator. Includes bug reports.
Post Reply
User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3425
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

HOW TO: Ignore specified HTML segments/sections in documents

Post by Albert Wiersch » Fri Dec 02, 2005 9:26 am

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
Image
Albert Wiersch

User avatar
RSteinwand
Rank VI - Professional
Rank VI - Professional
Posts: 600
Joined: Mon Jun 09, 2008 2:12 pm
Location: Fargo, ND
Contact:

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

Post by RSteinwand » Fri Jan 15, 2010 1:35 pm

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?
Rick

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3425
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

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

Post by Albert Wiersch » Fri Jan 15, 2010 9:39 pm

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.
Image
Albert Wiersch

User avatar
roedygr
Rank V - Professional
Rank V - Professional
Posts: 370
Joined: Fri Feb 17, 2006 5:22 am
Location: Victoria BC Canada
Contact:

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

Post by roedygr » Wed Jan 20, 2010 6:27 am

There is a catch. cseignore will not let you get away with high bit characters.

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3425
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

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

Post by Albert Wiersch » Wed Jan 20, 2010 11:21 am

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.
Image
Albert Wiersch

Post Reply