Index: zen/template.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/themes/zen/zen/template.php,v retrieving revision 1.13 diff -u -p -r1.13 template.php --- zen/template.php 21 Apr 2008 17:03:03 -0000 1.13 +++ zen/template.php 30 Apr 2008 20:06:35 -0000 @@ -339,10 +339,12 @@ function phptemplate_preprocess_block(&$ /** * Converts a string to a suitable html ID attribute. * - * - Preceeds initial numeric with 'n' character. + * http://www.w3.org/TR/html4/struct/global.html#h-7.5.2 specifies what makes a + * valid ID attribute in HTML. This function: + * + * - Ensure an ID starts with an alpha character by optionally adding an 'n'. * - Replaces any character except A-Z, numbers, and underscores with dashes. * - Converts entire string to lowercase. - * - Works for classes too! * * @param $string * The string @@ -350,11 +352,13 @@ function phptemplate_preprocess_block(&$ * The converted string */ function zen_id_safe($string) { - if (is_numeric($string{0})) { - // If the first character is numeric, add 'n' in front - $string = 'n'. $string; + // Replace with dashes anything that isn't A-Z, numbers, dashes, or underscores. + $string = strtolower(preg_replace('/[^a-zA-Z0-9_-]+/', '-', $string)); + // If the first character is not a-z, add 'n' in front. + if (!ctype_lower($string{0})) { // Don't use ctype_alpha since its locale aware. + $string = 'id' . $string; } - return strtolower(preg_replace('/[^a-zA-Z0-9_-]+/', '-', $string)); + return $string; } /**