Re: Pedagogic validation

On Thu, Sep 10, 2009 at 10:38 PM, Simon Pieters wrote:
>
> I had an idea about having an option in the validator that just asserts
> which coding conventions are used in the document; something like:
>
>   minimized attributes: none
>   unquoted attributes: none
>   single quoted attributes: ...list of occurrences...
>   double quoted attributes: ...list of occurrences...
>   etc.
>
> This wouldn't make the validator take any position about The Right Set of
> Rules, but would still allow teachers to enforce a particular coding style
> on their students.

...just like what we have in html5lib's HTMLSerializer:
http://code.google.com/p/html5lib/source/browse/python/src/html5lib/serializer/htmlserializer.py#55
 - quote_attr_values (boolean): should attribute values always be quoted?
 - quote_char (either " or ' ): which quote should be used?
 - use_best_quote_char (boolean): should quote_char always be used, or
should we try to use the best quote char depending on the value (if
the value contains " but no ', single-quote it; if it contains ' but
no ", double-quote it; otherwise use quote_char)
 - minimize_boolean_attributes (boolean): should boolean attributes be
in minimized form or not? (disabled vs. disabled="disabled")
 - use_trailing_solidus (boolean): should void elements have a trailing solidus?
 - space_before_trailing_solidus (boolean): if use_trailing_solidus is
True, should a space be inserted before the trailing solidus?
 - escape_lt_in_attrs (boolean): should < be escaped as &lt; in
attribute values or left as-is?
 - escape_rcdata (boolean): should RCDATA content be escaped (<
becomes &lt;, > becomes &gt; and & becomes &amp;, >/&gt; isn't
strictly necessary but html5lib actually inherits this behavior from
xml.sax.saxutils.escape())
 - inject_meta_charset (boolean): in html5lib, ensures (if True) the
serialized document has a <meta charset>; in a validator, would
enforce (or not) the presence of the <meta charset>
 - omit_optional_tags (boolean): in html5lib, omit (if True) optional
tags (such as </p>, </td>, </li>, etc.); in a validator, would allow
(or not) omitted optional tags

Actually, a particular combination of these flags are enough to make a
polyglot document:
http://code.google.com/p/html5lib/source/browse/python/src/html5lib/serializer/xhtmlserializer.py

-- 
Thomas Broyer
/tɔ.ma.bʁwa.je/

Received on Friday, 11 September 2009 08:07:18 UTC