Re: RFE: using Tidy to strip out comments from HTML

In <20010214190338.52846.qmail@web11601.mail.yahoo.com>, Erik Talvola <talvola@yahoo.com> writes:
> A question came up at work recently about whether
> there was a quick and dirty script to remove all HTML
> comments from a page.  I figured, well Tidy must do
> it, but didn't see any option.

pprint.c has a routine for printing comments:

  static void PPrintComment(Out *fout, uint indent,
                   Lexer *lexer, Node *node)

You can disable comments by disabling output in this route (or add an extra 
option to remove comments, might be a nice addition for the tidy base also)

Keep in mind that some comments may not really be intended as comments, e.g.

<script>
<!-- 
  ...
// hide this from old browsers -->
</script>

-- 
Klaus Johannes Rusch
KlausRusch@atmedia.net
http://www.atmedia.net/KlausRusch/

Received on Sunday, 18 February 2001 08:42:15 UTC