Add alt parameter to <area>

View: New views
1 Messages — Rating Filter:   Alert me  

Add alt parameter to <area>

by Platonides :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello all,
Studying the non-conformant XHTML output at Wikipedia produced by the
mediawiki extension EasyTimeline [1] i have narrowed it down to the
ploticus, which is used by this extension.
The problem lies in that ploticus mapfile output is of the form:

<area shape="rect" href="/wiki/Macintosh_Plus" coords="139,11,198,31"
title="Macintosh Plus" >
<area shape="rect" href="/wiki/Macintosh_XL" coords="93,76,141,96"
title="Macintosh XL" >
<area shape="rect" href="/wiki/Macintosh_SE" coords="185,54,232,75"
title="Macintosh SE" >

This produces XHTML validation errors [2], because the <area> element
must have an alt attribute [3]:
<!ELEMENT area EMPTY>
<!ATTLIST area
  %attrs;
  %focus;
  shape       %Shape;        "rect"
  coords      %Coords;       #IMPLIED
  href        %URI;          #IMPLIED
  nohref      (nohref)       #IMPLIED
  alt         %Text;         #REQUIRED
  target      %FrameTarget;  #IMPLIED
  >

You can find attached a patch against ploticus 2.40 which fixes adds
this missing alt attribute.
If there's a title attribute, alt takes its value. Else an empty alt is
sent.

I also added a slash at the end of the area, to make it xml-friendly.
There's a space before it, as recommended by xhtml appendix C2 so i
don't expect any breakage from it.

I would be grateful if you incorpored this on next release.
Best regards

Platonides


1- https://bugzilla.wikimedia.org/show_bug.cgi?id=14727
2-
http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FTemplate%3ATimeline_of_compact_Macintosh_models
3- http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
4- http://www.w3.org/TR/xhtml1/#C_2


--- clickmap.c 2007-11-23 23:06:05.000000000 +0100
+++ clickmap.c 2008-07-05 00:40:43.146916100 +0200
@@ -187,8 +187,8 @@
  fprintf( fp, "<area shape=\"rect\" %s%s%c coords=\"%d,%d,%d,%d\" ",
  (buf[0] == '\0') ? "nohref" : "href=\""   , buf,    (buf[0] == '\0' ) ? ' ' : '"',
  box[ i ].x1 - tx, box[ i ].y1 - ty, box[ i ].x2 - tx, box[ i ].y2 - ty );
- if( titles[i] != NULL ) fprintf( fp, "title=\"%s\" %s >\n", titles[i], targetstr );
- else fprintf( fp, "%s >\n", targetstr );
+ if( titles[i] != NULL ) fprintf( fp, "title=\"%s\" alt=\"%s\" %s />\n", titles[i], titles[i], targetstr );
+ else fprintf( fp, "alt=\"\" %s />\n", targetstr );
  }
  }
 
LightInTheBox - Buy quality products at wholesale price!