[Mediawiki-l] XHTML generation
brion at pobox.com
Thu Feb 17 19:19:31 UTC 2005
> <a href="http://portal.wikinerds.org/canada-flag" class='external'
> The XHTML above is generated by Wikipedia, but in my opinion MW should use
> only " and not ' i.e. it should be class="external" instead of 'external'
Thank you for your opinion. It will be dutifully studied, found wanting,
For the people in the audience who are interested in accuracy, note that
XML allows attribute values to be quoted either with double quotes or
single quotes. Here's the formal lexical definition:
AttValue ::= '"' ([^<&"] | Reference)* '"'
| "'" ([^<&'] | Reference)* "'"
Classic SGML-based HTML additionally allows attribute values to be
unquoted if they contain only certain characters (eg border=1, but
*not* bgcolor=#EEEEEE which is actually illegal!) XHTML limits itself to
XML's stricter syntax, so only single and double-quoted attribute values
Since strings in PHP source code are themselves usually either single or
double-quoted, instances of the same quote character within the string
must be escaped with a backslash to appear as a literal character.
Convenience for the coder thus often prompts the use of one or the other
quote style for XHTML markup being produced from PHP code. Something
like "<p class='error'>$err</p>" is easier for the coders to read than
When outputting user-supplied data which is escaped using
htmlspecialchars(), generally double-quotes are used as that function's
default behavior does transform " to " but does not transform ',
requiring additional work to produce a string suitable for literal
inclusion in a single-quoted XML attribute.
Both quote forms are equally legal and produce equivalent results, so
source code readability tends to outweigh the minor issue of aesthetic
consistency in the markup output. Markup output is already butt-ugly
because it's not spaced or indented nicely, and nobody's going to look
at it very often; it's for consumption of the browser while the source
code is maintained by human programmers.
-- brion vibber (brion @ pobox.com)
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 253 bytes
Desc: OpenPGP digital signature
Url : http://lists.wikimedia.org/pipermail/mediawiki-l/attachments/20050217/5d490a84/attachment.pgp
More information about the MediaWiki-l