~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

TidyLib
tidy/src/localize.c

Version: ~ [ 1.0 ] ~

** Warning: Cannot open xref database.

1 /* localize.c -- text strings and routines to handle errors and general messages 2 3 (c) 1998-2005 (W3C) MIT, ERCIM, Keio University 4 Portions Copyright University of Toronto 5 See tidy.h and access.h for the copyright notice. 6 7 You should only need to edit this file and tidy.c 8 to localize HTML tidy. *** This needs checking *** 9 10 CVS Info : 11 12 $Author: arnaud02 $ 13 $Date: 2005/10/25 15:57:27 $ 14 $Revision: 1.145 $ 15 16 */ 17 18 #include "tidy-int.h" 19 #include "lexer.h" 20 #include "streamio.h" 21 #include "message.h" 22 #include "tmbstr.h" 23 #include "utf8.h" 24 25 /* used to point to Web Accessibility Guidelines */ 26 #define ACCESS_URL "http://www.w3.org/WAI/GL" 27 28 /* points to the Adaptive Technology Resource Centre at the 29 ** University of Toronto 30 */ 31 #define ATRC_ACCESS_URL "http://www.aprompt.ca/Tidy/accessibilitychecks.html" 32 33 static const char release_date[] = "1 September 2005"; 34 35 ctmbstr ReleaseDate(void) 36 { 37 return release_date; 38 } 39 40 static struct _msgfmt 41 { 42 uint code; 43 ctmbstr fmt; 44 } const msgFormat[] = 45 { 46 /* ReportEncodingWarning */ 47 { ENCODING_MISMATCH, "specified input encoding (%s) does not match actual input encoding (%s)" }, /* Warning */ 48 49 /* ReportEncodingError */ 50 { VENDOR_SPECIFIC_CHARS, "%s invalid character code %s" }, /* Error */ 51 { INVALID_SGML_CHARS, "%s invalid character code %s" }, /* Error */ 52 { INVALID_UTF8, "%s invalid UTF-8 bytes (char. code %s)" }, /* Error */ 53 { INVALID_UTF16, "%s invalid UTF-16 surrogate pair (char. code %s)" }, /* Error */ 54 { INVALID_NCR, "%s invalid numeric character reference %s" }, /* Error */ 55 56 /* ReportEntityError */ 57 { MISSING_SEMICOLON, "entity \"%s\" doesn't end in ';'" }, /* Warning in HTML, Error in XML/XHTML */ 58 { MISSING_SEMICOLON_NCR, "numeric character reference \"%s\" doesn't end in ';'" }, /* Warning in HTML, Error in XML/XHTML */ 59 { UNESCAPED_AMPERSAND, "unescaped & which should be written as &amp;" }, /* Warning in HTML, Error in XHTML */ 60 { UNKNOWN_ENTITY, "unescaped & or unknown entity \"%s\"" }, /* Error */ 61 { APOS_UNDEFINED, "named entity &apos; only defined in XML/XHTML" }, /* Error in HTML (should only occur for HTML input) */ 62 63 /* ReportAttrError */ 64 65 /* attribute name */ 66 { INSERTING_ATTRIBUTE, "%s inserting \"%s\" attribute" }, /* Warning in CheckLINK, Error otherwise */ 67 { MISSING_ATTR_VALUE, "%s attribute \"%s\" lacks value" }, /* Warning in CheckUrl, Error otherwise */ 68 { UNKNOWN_ATTRIBUTE, "%s unknown attribute \"%s\"" }, /* Error */ 69 { PROPRIETARY_ATTRIBUTE, "%s proprietary attribute \"%s\"" }, /* Error */ 70 { JOINING_ATTRIBUTE, "%s joining values of repeated attribute \"%s\"" }, /* Error */ 71 { XML_ATTRIBUTE_VALUE, "%s has XML attribute \"%s\"" }, /* Error (but deprecated) */ 72 73 /* attribute value */ 74 { XML_ID_SYNTAX, "%s ID \"%s\" uses XML ID syntax" }, /* Warning if XHTML, Error if HTML */ 75 { ATTR_VALUE_NOT_LCASE, "%s attribute value \"%s\" must be lower case for XHTML" }, /* Error if XHTML input, Notice if HTML input and XHTML outout */ 76 { PROPRIETARY_ATTR_VALUE, "%s proprietary attribute value \"%s\"" }, /* Error */ 77 { ANCHOR_NOT_UNIQUE, "%s anchor \"%s\" already defined" }, /* Error */ 78 79 /* attribute name, attribute value */ 80 { BAD_ATTRIBUTE_VALUE, "%s attribute \"%s\" has invalid value \"%s\"" }, /* Error */ 81 { BAD_ATTRIBUTE_VALUE_REPLACED, "%s attribute \"%s\" had invalid value \"%s\" and has been replaced" }, /* Error */ 82 { INVALID_ATTRIBUTE, "%s attribute name \"%s\" (value=\"%s\") is invalid" }, /* Error */ 83 84 /* attribute value, attribute name */ 85 { REPEATED_ATTRIBUTE, "%s dropping value \"%s\" for repeated attribute \"%s\"" }, /* Error */ 86 87 /* no arguments */ 88 { INVALID_XML_ID, "%s cannot copy name attribute to id" }, /* Warning */ 89 { UNEXPECTED_GT, "%s missing '>' for end of tag" }, /* Warning if HTML, Error if XML/XHTML */ 90 { UNEXPECTED_QUOTEMARK, "%s unexpected or duplicate quote mark" }, /* Error */ 91 { MISSING_QUOTEMARK, "%s attribute with missing trailing quote mark" }, /* Error */ 92 { UNEXPECTED_END_OF_FILE_ATTR, "%s end of file while parsing attributes" }, /* Error */ 93 { ID_NAME_MISMATCH, "%s id and name attribute value mismatch" }, /* Error */ 94 { BACKSLASH_IN_URI, "%s URI reference contains backslash. Typo?" }, /* Error */ 95 { FIXED_BACKSLASH, "%s converting backslash in URI to slash" }, /* Error */ 96 { ILLEGAL_URI_REFERENCE, "%s improperly escaped URI reference" }, /* Error */ 97 { ESCAPED_ILLEGAL_URI, "%s escaping malformed URI reference" }, /* Error */ 98 { NEWLINE_IN_URI, "%s discarding newline in URI reference" }, /* Error */ 99 { UNEXPECTED_EQUALSIGN, "%s unexpected '=', expected attribute name" }, /* Error */ 100 { MISSING_IMAGEMAP, "%s should use client-side image map" }, /* Warning (but deprecated) */ 101 102 /* ReportMissingAttr */ 103 { MISSING_ATTRIBUTE, "%s lacks \"%s\" attribute" }, /* Error */ 104 /* ReportWarning */ 105 { NESTED_EMPHASIS, "nested emphasis %s" }, /* Warning */ 106 { NESTED_QUOTATION, "nested q elements, possible typo." }, /* Warning */ 107 { OBSOLETE_ELEMENT, "replacing obsolete element %s by %s" }, /* Warning */ 108 { COERCE_TO_ENDTAG_WARN, "<%s> is probably intended as </%s>" }, /* Warning */ 109 110 /* ReportNotice */ 111 { TRIM_EMPTY_ELEMENT, "trimming empty %s" }, /* Notice */ 112 { REPLACING_ELEMENT, "replacing %s by %s" }, /* Notice */ 113 114 /* ReportError */ 115 { COERCE_TO_ENDTAG, "<%s> is probably intended as </%s>" }, /* Error */ 116 { REPLACING_UNEX_ELEMENT, "replacing unexpected %s by %s" }, /* Error */ 117 { MISSING_ENDTAG_FOR, "missing </%s>" }, /* Error */ 118 { MISSING_ENDTAG_BEFORE, "missing </%s> before %s" }, /* Error */ 119 { DISCARDING_UNEXPECTED, "discarding unexpected %s" }, /* Error */ 120 { NON_MATCHING_ENDTAG, "replacing unexpected %s by </%s>" }, /* Error */ 121 { TAG_NOT_ALLOWED_IN, "%s isn't allowed in <%s> elements" }, /* Error */ 122 { MISSING_STARTTAG, "missing <%s>" }, /* Error */ 123 { UNEXPECTED_ENDTAG, "unexpected </%s>" }, /* Error */ 124 { TOO_MANY_ELEMENTS, "too many %s elements" }, /* Error */ 125 { USING_BR_INPLACE_OF, "using <br> in place of %s" }, /* Error */ 126 { INSERTING_TAG, "inserting implicit <%s>" }, /* Error */ 127 { CANT_BE_NESTED, "%s can't be nested" }, /* Error */ 128 { PROPRIETARY_ELEMENT, "%s is not approved by W3C" }, /* Error */ 129 { ILLEGAL_NESTING, "%s shouldn't be nested" }, /* Error */ 130 { NOFRAMES_CONTENT, "%s not inside 'noframes' element" }, /* Error */ 131 { UNEXPECTED_END_OF_FILE, "unexpected end of file %s" }, /* Error */ 132 { ELEMENT_NOT_EMPTY, "%s element not empty or not closed" }, /* Error */ 133 { UNEXPECTED_ENDTAG_IN, "unexpected </%s> in <%s>" }, /* Error */ 134 { TOO_MANY_ELEMENTS_IN, "too many %s elements in <%s>" }, /* Error */ 135 { UNESCAPED_ELEMENT, "unescaped %s in pre content" }, /* Error (but deprecated) */ 136 137 /* no arguments */ 138 { DOCTYPE_AFTER_TAGS, "<!DOCTYPE> isn't allowed after elements" }, /* Error */ 139 { MISSING_TITLE_ELEMENT, "inserting missing 'title' element" }, /* Error */ 140 { INCONSISTENT_VERSION, "HTML DOCTYPE doesn't match content" }, /* Error */ 141 { MISSING_DOCTYPE, "missing <!DOCTYPE> declaration" }, /* Error */ 142 { CONTENT_AFTER_BODY, "content occurs after end of body" }, /* Error */ 143 { MALFORMED_COMMENT, "adjacent hyphens within comment" }, /* Error */ 144 { BAD_COMMENT_CHARS, "expecting -- or >" }, /* Error */ 145 { BAD_CDATA_CONTENT, "'<' + '/' + letter not allowed here" }, /* Error */ 146 { INCONSISTENT_NAMESPACE, "HTML namespace doesn't match content" }, /* Error */ 147 { SPACE_PRECEDING_XMLDECL, "removing whitespace preceding XML Declaration" }, /* Error */ 148 { MALFORMED_DOCTYPE, "discarding malformed <!DOCTYPE>" }, /* Error */ 149 { BAD_XML_COMMENT, "XML comments can't contain --" }, /* Error (but deprecated) */ 150 { DTYPE_NOT_UPPER_CASE, "SYSTEM, PUBLIC, W3C, DTD, EN must be upper case" }, /* Error (but deprecated) */ 151 { ENCODING_IO_CONFLICT, "Output encoding does not work with standard output" }, /* Error (but deprecated) */ 152 153 /* ReportFatal */ 154 { SUSPECTED_MISSING_QUOTE, "missing quote mark for attribute value" }, /* Error? (not really sometimes) */ 155 { DUPLICATE_FRAMESET, "repeated FRAMESET element" }, /* Error */ 156 { UNKNOWN_ELEMENT, "%s is not recognized!" }, /* Error */ 157 { UNEXPECTED_ENDTAG, "unexpected </%s>" }, /* Error */ 158 159 #if SUPPORT_ACCESSIBILITY_CHECKS 160 161 /* ReportAccess */ 162 /* 163 List of error/warning messages. The error code corresponds to 164 the check that is listed in the AERT (HTML specifications). 165 */ 166 { IMG_MISSING_ALT, "[1.1.1.1]: <img> missing 'alt' text." }, /* Access */ 167 { IMG_ALT_SUSPICIOUS_FILENAME, "[1.1.1.2]: suspicious 'alt' text (filename)." }, /* Access */ 168 { IMG_ALT_SUSPICIOUS_FILE_SIZE, "[1.1.1.3]: suspicious 'alt' text (file size)." }, /* Access */ 169 { IMG_ALT_SUSPICIOUS_PLACEHOLDER, "[1.1.1.4]: suspicious 'alt' text (placeholder)." }, /* Access */ 170 { IMG_ALT_SUSPICIOUS_TOO_LONG, "[1.1.1.10]: suspicious 'alt' text (too long)." }, /* Access */ 171 { IMG_MISSING_LONGDESC_DLINK, "[1.1.2.1]: <img> missing 'longdesc' and d-link." }, /* Access */ 172 { IMG_MISSING_DLINK, "[1.1.2.2]: <img> missing d-link." }, /* Access */ 173 { IMG_MISSING_LONGDESC, "[1.1.2.3]: <img> missing 'longdesc'." }, /* Access */ 174 { IMG_BUTTON_MISSING_ALT, "[1.1.3.1]: <img> (button) missing 'alt' text." }, /* Access */ 175 { APPLET_MISSING_ALT, "[1.1.4.1]: <applet> missing alternate content." }, /* Access */ 176 { OBJECT_MISSING_ALT, "[1.1.5.1]: <object> missing alternate content." }, /* Access */ 177 { AUDIO_MISSING_TEXT_WAV, "[1.1.6.1]: audio missing text transcript (wav)." }, /* Access */ 178 { AUDIO_MISSING_TEXT_AU, "[1.1.6.2]: audio missing text transcript (au)." }, /* Access */ 179 { AUDIO_MISSING_TEXT_AIFF, "[1.1.6.3]: audio missing text transcript (aiff)." }, /* Access */ 180 { AUDIO_MISSING_TEXT_SND, "[1.1.6.4]: audio missing text transcript (snd)." }, /* Access */ 181 { AUDIO_MISSING_TEXT_RA, "[1.1.6.5]: audio missing text transcript (ra)." }, /* Access */ 182 { AUDIO_MISSING_TEXT_RM, "[1.1.6.6]: audio missing text transcript (rm)." }, /* Access */ 183 { FRAME_MISSING_LONGDESC, "[1.1.8.1]: <frame> may require 'longdesc'." }, /* Access */ 184 { AREA_MISSING_ALT, "[1.1.9.1]: <area> missing 'alt' text." }, /* Access */ 185 { SCRIPT_MISSING_NOSCRIPT, "[1.1.10.1]: <script> missing <noscript> section." }, /* Access */ 186 { ASCII_REQUIRES_DESCRIPTION, "[1.1.12.1]: ascii art requires description." }, /* Access */ 187 { IMG_MAP_SERVER_REQUIRES_TEXT_LINKS, "[1.2.1.1]: image map (server-side) requires text links." }, /* Access */ 188 { MULTIMEDIA_REQUIRES_TEXT, "[1.4.1.1]: multimedia requires synchronized text equivalents." }, /* Access */ 189 { IMG_MAP_CLIENT_MISSING_TEXT_LINKS, "[1.5.1.1]: image map (client-side) missing text links." }, /* Access */ 190 { INFORMATION_NOT_CONVEYED_IMAGE, "[2.1.1.1]: ensure information not conveyed through color alone (image)." }, /* Access */ 191 { INFORMATION_NOT_CONVEYED_APPLET, "[2.1.1.2]: ensure information not conveyed through color alone (applet)." }, /* Access */ 192 { INFORMATION_NOT_CONVEYED_OBJECT, "[2.1.1.3]: ensure information not conveyed through color alone (object)." }, /* Access */ 193 { INFORMATION_NOT_CONVEYED_SCRIPT, "[2.1.1.4]: ensure information not conveyed through color alone (script)." }, /* Access */ 194 { INFORMATION_NOT_CONVEYED_INPUT, "[2.1.1.5]: ensure information not conveyed through color alone (input)." }, /* Access */ 195 { COLOR_CONTRAST_TEXT, "[2.2.1.1]: poor color contrast (text)." }, /* Access */ 196 { COLOR_CONTRAST_LINK, "[2.2.1.2]: poor color contrast (link)." }, /* Access */ 197 { COLOR_CONTRAST_ACTIVE_LINK, "[2.2.1.3]: poor color contrast (active link)." }, /* Access */ 198 { COLOR_CONTRAST_VISITED_LINK, "[2.2.1.4]: poor color contrast (visited link)." }, /* Access */ 199 { DOCTYPE_MISSING, "[3.2.1.1]: <doctype> missing." }, /* Access */ 200 { STYLE_SHEET_CONTROL_PRESENTATION, "[3.3.1.1]: use style sheets to control presentation." }, /* Access */ 201 { HEADERS_IMPROPERLY_NESTED, "[3.5.1.1]: headers improperly nested." }, /* Access */ 202 { POTENTIAL_HEADER_BOLD, "[3.5.2.1]: potential header (bold)." }, /* Access */ 203 { POTENTIAL_HEADER_ITALICS, "[3.5.2.2]: potential header (italics)." }, /* Access */ 204 { POTENTIAL_HEADER_UNDERLINE, "[3.5.2.3]: potential header (underline)." }, /* Access */ 205 { HEADER_USED_FORMAT_TEXT, "[3.5.3.1]: header used to format text." }, /* Access */ 206 { LIST_USAGE_INVALID_UL, "[3.6.1.1]: list usage invalid <ul>." }, /* Access */ 207 { LIST_USAGE_INVALID_OL, "[3.6.1.2]: list usage invalid <ol>." }, /* Access */ 208 { LIST_USAGE_INVALID_LI, "[3.6.1.4]: list usage invalid <li>." }, /* Access */ 209 { INDICATE_CHANGES_IN_LANGUAGE, "[4.1.1.1]: indicate changes in language." }, /* Access */ 210 { LANGUAGE_NOT_IDENTIFIED, "[4.3.1.1]: language not identified." }, /* Access */ 211 { LANGUAGE_INVALID, "[4.3.1.2]: language attribute invalid." }, /* Access */ 212 { DATA_TABLE_MISSING_HEADERS, "[5.1.2.1]: data <table> missing row/column headers (all)." }, /* Access */ 213 { DATA_TABLE_MISSING_HEADERS_COLUMN, "[5.1.2.2]: data <table> missing row/column headers (1 col)." }, /* Access */ 214 { DATA_TABLE_MISSING_HEADERS_ROW, "[5.1.2.3]: data <table> missing row/column headers (1 row)." }, /* Access */ 215 { DATA_TABLE_REQUIRE_MARKUP_COLUMN_HEADERS, "[5.2.1.1]: data <table> may require markup (column headers)." }, /* Access */ 216 { DATA_TABLE_REQUIRE_MARKUP_ROW_HEADERS, "[5.2.1.2]: data <table> may require markup (row headers)." }, /* Access */ 217 { LAYOUT_TABLES_LINEARIZE_PROPERLY, "[5.3.1.1]: verify layout tables linearize properly." }, /* Access */ 218 { LAYOUT_TABLE_INVALID_MARKUP, "[5.4.1.1]: invalid markup used in layout <table>." }, /* Access */ 219 { TABLE_MISSING_SUMMARY, "[5.5.1.1]: <table> missing summary." }, /* Access */ 220 { TABLE_SUMMARY_INVALID_NULL, "[5.5.1.2]: <table> summary invalid (null)." }, /* Access */ 221 { TABLE_SUMMARY_INVALID_SPACES, "[5.5.1.3]: <table> summary invalid (spaces)." }, /* Access */ 222 { TABLE_SUMMARY_INVALID_PLACEHOLDER, "[5.5.1.6]: <table> summary invalid (placeholder text)." }, /* Access */ 223 { TABLE_MISSING_CAPTION, "[5.5.2.1]: <table> missing <caption>." }, /* Access */ 224 { TABLE_MAY_REQUIRE_HEADER_ABBR, "[5.6.1.1]: <table> may require header abbreviations." }, /* Access */ 225 { TABLE_MAY_REQUIRE_HEADER_ABBR_NULL, "[5.6.1.2]: <table> header abbreviations invalid (null)." }, /* Access */ 226 { TABLE_MAY_REQUIRE_HEADER_ABBR_SPACES, "[5.6.1.3]: <table> header abbreviations invalid (spaces)." }, /* Access */ 227 { STYLESHEETS_REQUIRE_TESTING_LINK, "[6.1.1.1]: style sheets require testing (link)." }, /* Access */ 228 { STYLESHEETS_REQUIRE_TESTING_STYLE_ELEMENT, "[6.1.1.2]: style sheets require testing (style element)." }, /* Access */ 229 { STYLESHEETS_REQUIRE_TESTING_STYLE_ATTR, "[6.1.1.3]: style sheets require testing (style attribute)." }, /* Access */ 230 { FRAME_SRC_INVALID, "[6.2.1.1]: <frame> source invalid." }, /* Access */ 231 { TEXT_EQUIVALENTS_REQUIRE_UPDATING_APPLET, "[6.2.2.1]: text equivalents require updating (applet)." }, /* Access */ 232 { TEXT_EQUIVALENTS_REQUIRE_UPDATING_SCRIPT, "[6.2.2.2]: text equivalents require updating (script)." }, /* Access */ 233 { TEXT_EQUIVALENTS_REQUIRE_UPDATING_OBJECT, "[6.2.2.3]: text equivalents require updating (object)." }, /* Access */ 234 { PROGRAMMATIC_OBJECTS_REQUIRE_TESTING_SCRIPT, "[6.3.1.1]: programmatic objects require testing (script)." }, /* Access */ 235 { PROGRAMMATIC_OBJECTS_REQUIRE_TESTING_OBJECT, "[6.3.1.2]: programmatic objects require testing (object)." }, /* Access */ 236 { PROGRAMMATIC_OBJECTS_REQUIRE_TESTING_EMBED, "[6.3.1.3]: programmatic objects require testing (embed)." }, /* Access */ 237 { PROGRAMMATIC_OBJECTS_REQUIRE_TESTING_APPLET, "[6.3.1.4]: programmatic objects require testing (applet)." }, /* Access */ 238 { FRAME_MISSING_NOFRAMES, "[6.5.1.1]: <frameset> missing <noframes> section." }, /* Access */ 239 { NOFRAMES_INVALID_NO_VALUE, "[6.5.1.2]: <noframes> section invalid (no value)." }, /* Access */ 240 { NOFRAMES_INVALID_CONTENT, "[6.5.1.3]: <noframes> section invalid (content)." }, /* Access */ 241 { NOFRAMES_INVALID_LINK, "[6.5.1.4]: <noframes> section invalid (link)." }, /* Access */ 242 { REMOVE_FLICKER_SCRIPT, "[7.1.1.1]: remove flicker (script)." }, /* Access */ 243 { REMOVE_FLICKER_OBJECT, "[7.1.1.2]: remove flicker (object)." }, /* Access */ 244 { REMOVE_FLICKER_EMBED, "[7.1.1.3]: remove flicker (embed)." }, /* Access */ 245 { REMOVE_FLICKER_APPLET, "[7.1.1.4]: remove flicker (applet)." }, /* Access */ 246 { REMOVE_FLICKER_ANIMATED_GIF, "[7.1.1.5]: remove flicker (animated gif)." }, /* Access */ 247 { REMOVE_BLINK_MARQUEE, "[7.2.1.1]: remove blink/marquee." }, /* Access */ 248 { REMOVE_AUTO_REFRESH, "[7.4.1.1]: remove auto-refresh." }, /* Access */ 249 { REMOVE_AUTO_REDIRECT, "[7.5.1.1]: remove auto-redirect." }, /* Access */ 250 { ENSURE_PROGRAMMATIC_OBJECTS_ACCESSIBLE_SCRIPT, "[8.1.1.1]: ensure programmatic objects are accessible (script)." }, /* Access */ 251 { ENSURE_PROGRAMMATIC_OBJECTS_ACCESSIBLE_OBJECT, "[8.1.1.2]: ensure programmatic objects are accessible (object)." }, /* Access */ 252 { ENSURE_PROGRAMMATIC_OBJECTS_ACCESSIBLE_APPLET, "[8.1.1.3]: ensure programmatic objects are accessible (applet)." }, /* Access */ 253 { ENSURE_PROGRAMMATIC_OBJECTS_ACCESSIBLE_EMBED, "[8.1.1.4]: ensure programmatic objects are accessible (embed)." }, /* Access */ 254 { IMAGE_MAP_SERVER_SIDE_REQUIRES_CONVERSION, "[9.1.1.1]: image map (server-side) requires conversion." }, /* Access */ 255 { SCRIPT_NOT_KEYBOARD_ACCESSIBLE_ON_MOUSE_DOWN, "[9.3.1.1]: <script> not keyboard accessible (onMouseDown)." }, /* Access */ 256 { SCRIPT_NOT_KEYBOARD_ACCESSIBLE_ON_MOUSE_UP, "[9.3.1.2]: <script> not keyboard accessible (onMouseUp)." }, /* Access */ 257 { SCRIPT_NOT_KEYBOARD_ACCESSIBLE_ON_CLICK, "[9.3.1.3]: <script> not keyboard accessible (onClick)." }, /* Access */ 258 { SCRIPT_NOT_KEYBOARD_ACCESSIBLE_ON_MOUSE_OVER, "[9.3.1.4]: <script> not keyboard accessible (onMouseOver)." }, /* Access */ 259 { SCRIPT_NOT_KEYBOARD_ACCESSIBLE_ON_MOUSE_OUT, "[9.3.1.5]: <script> not keyboard accessible (onMouseOut)." }, /* Access */ 260 { SCRIPT_NOT_KEYBOARD_ACCESSIBLE_ON_MOUSE_MOVE, "[9.3.1.6]: <script> not keyboard accessible (onMouseMove)." }, /* Access */ 261 { NEW_WINDOWS_REQUIRE_WARNING_NEW, "[10.1.1.1]: new windows require warning (_new)." }, /* Access */ 262 { NEW_WINDOWS_REQUIRE_WARNING_BLANK, "[10.1.1.2]: new windows require warning (_blank)." }, /* Access */ 263 { FORM_CONTROL_REQUIRES_DEFAULT_TEXT, "[10.4.1.1]: form control requires default text." }, /* Access */ 264 { FORM_CONTROL_DEFAULT_TEXT_INVALID_NULL, "[10.4.1.2]: form control default text invalid (null)." }, /* Access */ 265 { FORM_CONTROL_DEFAULT_TEXT_INVALID_SPACES, "[10.4.1.3]: form control default text invalid (spaces)." }, /* Access */ 266 { REPLACE_DEPRECATED_HTML_APPLET, "[11.2.1.1]: replace deprecated html <applet>." }, /* Access */ 267 { REPLACE_DEPRECATED_HTML_BASEFONT, "[11.2.1.2]: replace deprecated html <basefont>." }, /* Access */ 268 { REPLACE_DEPRECATED_HTML_CENTER, "[11.2.1.3]: replace deprecated html <center>." }, /* Access */ 269 { REPLACE_DEPRECATED_HTML_DIR, "[11.2.1.4]: replace deprecated html <dir>." }, /* Access */ 270 { REPLACE_DEPRECATED_HTML_FONT, "[11.2.1.5]: replace deprecated html <font>." }, /* Access */ 271 { REPLACE_DEPRECATED_HTML_ISINDEX, "[11.2.1.6]: replace deprecated html <isindex>." }, /* Access */ 272 { REPLACE_DEPRECATED_HTML_MENU, "[11.2.1.7]: replace deprecated html <menu>." }, /* Access */ 273 { REPLACE_DEPRECATED_HTML_S, "[11.2.1.8]: replace deprecated html <s>." }, /* Access */ 274 { REPLACE_DEPRECATED_HTML_STRIKE, "[11.2.1.9]: replace deprecated html <strike>." }, /* Access */ 275 { REPLACE_DEPRECATED_HTML_U, "[11.2.1.10]: replace deprecated html <u>." }, /* Access */ 276 { FRAME_MISSING_TITLE, "[12.1.1.1]: <frame> missing title." }, /* Access */ 277 { FRAME_TITLE_INVALID_NULL, "[12.1.1.2]: <frame> title invalid (null)." }, /* Access */ 278 { FRAME_TITLE_INVALID_SPACES, "[12.1.1.3]: <frame> title invalid (spaces)." }, /* Access */ 279 { ASSOCIATE_LABELS_EXPLICITLY, "[12.4.1.1]: associate labels explicitly with form controls." }, /* Access */ 280 { ASSOCIATE_LABELS_EXPLICITLY_FOR, "[12.4.1.2]: associate labels explicitly with form controls (for)." }, /* Access */ 281 { ASSOCIATE_LABELS_EXPLICITLY_ID, "[12.4.1.3]: associate labels explicitly with form controls (id)." }, /* Access */ 282 { LINK_TEXT_NOT_MEANINGFUL, "[13.1.1.1]: link text not meaningful." }, /* Access */ 283 { LINK_TEXT_MISSING, "[13.1.1.2]: link text missing." }, /* Access */ 284 { LINK_TEXT_TOO_LONG, "[13.1.1.3]: link text too long." }, /* Access */ 285 { LINK_TEXT_NOT_MEANINGFUL_CLICK_HERE, "[13.1.1.4]: link text not meaningful (click here)." }, /* Access */ 286 { METADATA_MISSING, "[13.2.1.1]: Metadata missing." }, /* Access */ 287 { METADATA_MISSING_LINK, "[13.2.1.2]: Metadata missing (link element)." }, /* Access */ 288 { METADATA_MISSING_REDIRECT_AUTOREFRESH, "[13.2.1.3]: Metadata missing (redirect/auto-refresh)." }, /* Access */ 289 { SKIPOVER_ASCII_ART, "[13.10.1.1]: skip over ascii art." }, /* Access */ 290 291 #endif /* SUPPORT_ACCESSIBILITY_CHECKS */ 292 293 /* must be last */ 294 { 0, NULL } 295 }; 296 297 static ctmbstr GetFormatFromCode(uint code) 298 { 299 uint i; 300 301 for (i = 0; msgFormat[i].fmt; ++i) 302 if (msgFormat[i].code == code) 303 return msgFormat[i].fmt; 304 305 return NULL; 306 } 307 308 /* 309 Documentation of configuration options 310 */ 311 312 /* Cross references */ 313 static const TidyOptionId TidyXmlDeclLinks[] = 314 { TidyCharEncoding, TidyOutCharEncoding, TidyUnknownOption }; 315 static const TidyOptionId TidyJoinClassesLinks[] = 316 { TidyJoinStyles, TidyDuplicateAttrs, TidyUnknownOption }; 317 static const TidyOptionId TidyJoinStylesLinks[] = 318 { TidyJoinClasses, TidyDuplicateAttrs, TidyUnknownOption }; 319 static const TidyOptionId TidyDuplicateAttrsLinks[] = 320 { TidyJoinClasses, TidyJoinStyles, TidyUnknownOption }; 321 static const TidyOptionId TidyIndentContentLinks[] = 322 { TidyIndentSpaces, TidyUnknownOption }; 323 static const TidyOptionId TidyIndentSpacesLinks[] = 324 { TidyIndentContent, TidyUnknownOption }; 325 static const TidyOptionId TidyWrapAttValsLinks[] = 326 { TidyWrapScriptlets, TidyUnknownOption }; 327 static const TidyOptionId TidyWrapScriptletsLinks[] = 328 { TidyWrapAttVals, TidyUnknownOption }; 329 static const TidyOptionId TidyCharEncodingLinks[] = 330 { TidyInCharEncoding, TidyOutCharEncoding, TidyUnknownOption }; 331 static const TidyOptionId TidyInCharEncodingLinks[] = 332 { TidyCharEncoding, TidyUnknownOption }; 333 static const TidyOptionId TidyOutCharEncodingLinks[] = 334 { TidyCharEncoding, TidyUnknownOption }; 335 static const TidyOptionId TidyErrFileLinks[] = 336 { TidyOutFile, TidyUnknownOption }; 337 static const TidyOptionId TidyOutFileLinks[] = 338 { TidyErrFile, TidyUnknownOption }; 339 static const TidyOptionId TidyBlockTagsLinks[] = 340 { TidyEmptyTags, TidyInlineTags, TidyPreTags, TidyUnknownOption }; 341 static const TidyOptionId TidyEmptyTagsLinks[] = 342 { TidyBlockTags, TidyInlineTags, TidyPreTags, TidyUnknownOption }; 343 static const TidyOptionId TidyInlineTagsLinks[] = 344 { TidyBlockTags, TidyEmptyTags, TidyPreTags, TidyUnknownOption }; 345 static const TidyOptionId TidyPreTagsLinks[] = 346 { TidyBlockTags, TidyEmptyTags, TidyInlineTags, TidyUnknownOption }; 347 static const TidyOptionId TidyMergeDivsLinks[] = 348 { TidyMakeClean, TidyUnknownOption }; 349 static const TidyOptionId TidyAsciiCharsLinks[] = 350 { TidyMakeClean, TidyUnknownOption }; 351 static const TidyOptionId TidyNumEntitiesLinks[] = 352 { TidyDoctype, TidyUnknownOption }; 353 354 /* Documentation of options */ 355 static const TidyOptionDoc option_docs[] = 356 { 357 {TidyXmlDecl, 358 "This option specifies if Tidy should add the XML declaration when " 359 "outputting XML or XHTML. Note that if the input already includes an " 360 "&lt;?xml ... ?&gt; declaration then this option will be ignored. " 361 "If the encoding for the output is different from \"ascii\", one of the " 362 "utf encodings or \"raw\", the declaration is always added as required by " 363 "the XML standard. " 364 , TidyXmlDeclLinks 365 }, 366 {TidyXmlSpace, 367 "This option specifies if Tidy should add xml:space=\"preserve\" to " 368 "elements such as &lt;PRE&gt;, &lt;STYLE&gt; and &lt;SCRIPT&gt; when " 369 "generating XML. This is needed if the whitespace in such elements is to " 370 "be parsed appropriately without having access to the DTD. " 371 }, 372 {TidyAltText, 373 "This option specifies the default \"alt=\" text Tidy uses for " 374 "&lt;IMG&gt; attributes. This feature is dangerous as it suppresses " 375 "further accessibility warnings. You are responsible for making your " 376 "documents accessible to people who can not see the images! " 377 }, 378 {TidyXmlPIs, 379 "This option specifies if Tidy should change the parsing of processing " 380 "instructions to require ?&gt; as the terminator rather than &gt;. This " 381 "option is automatically set if the input is in XML. " 382 }, 383 {TidyMakeBare, 384 "This option specifies if Tidy should strip Microsoft specific HTML " 385 "from Word 2000 documents, and output spaces rather than non-breaking " 386 "spaces where they exist in the input. " 387 }, 388 {TidyCSSPrefix, 389 "This option specifies the prefix that Tidy uses for styles rules. By " 390 "default, \"c\" will be used. " 391 }, 392 {TidyMakeClean, 393 "This option specifies if Tidy " 394 "should strip out surplus presentational tags and attributes replacing " 395 "them by style rules and structural markup as appropriate. It works well " 396 "on the HTML saved by Microsoft Office products. " 397 }, 398 {TidyDoctype, 399 "This option specifies the DOCTYPE declaration generated by Tidy. If set " 400 "to \"omit\" the output won't contain a DOCTYPE declaration. If set to " 401 "\"auto\" (the default) Tidy will use an educated guess based upon the " 402 "contents of the document. If set to \"strict\", Tidy will set the DOCTYPE " 403 "to the strict DTD. If set to \"loose\", the DOCTYPE is set to the loose " 404 "(transitional) DTD. Alternatively, you can supply a string for the formal " 405 "public identifier (FPI).<br />" 406 "<br />" 407 "For example: <br />" 408 "doctype: \"-//ACME//DTD HTML 3.14159//EN\"<br />" 409 "<br />" 410 "If you specify the FPI for an XHTML document, Tidy will set the " 411 "system identifier to the empty string. For an HTML document, Tidy adds a " 412 "system identifier only if one was already present in order to preserve " 413 "the processing mode of some browsers. Tidy leaves the DOCTYPE for " 414 "generic XML documents unchanged. <code>--doctype omit</code> implies " 415 "<code>--numeric-entities yes</code>. " 416 }, 417 {TidyDropEmptyParas, 418 "This option specifies if Tidy should discard empty paragraphs. " 419 }, 420 {TidyDropFontTags, 421 "This option specifies if Tidy should discard &lt;FONT&gt; and " 422 "&lt;CENTER&gt; tags without creating the corresponding style rules. This " 423 "option can be set independently of the clean option. " 424 }, 425 {TidyDropPropAttrs, 426 "This option specifies if Tidy should strip out proprietary attributes, " 427 "such as MS data binding attributes. " 428 }, 429 {TidyEncloseBlockText, 430 "This option specifies if Tidy should insert a &lt;P&gt; element to " 431 "enclose any text it finds in any element that allows mixed content for " 432 "HTML transitional but not HTML strict. " 433 }, 434 {TidyEncloseBodyText, 435 "This option specifies if Tidy should enclose any text it finds in the " 436 "body element within a &lt;P&gt; element. This is useful when you want to " 437 "take existing HTML and use it with a style sheet. " 438 }, 439 {TidyEscapeCdata, 440 "This option specifies if Tidy should convert &lt;![CDATA[]]&gt; " 441 "sections to normal text. " 442 }, 443 {TidyFixComments, 444 "This option specifies if Tidy should replace unexpected hyphens with " 445 "\"=\" characters when it comes across adjacent hyphens. The default is " 446 "yes. This option is provided for users of Cold Fusion which uses the " 447 "comment syntax: &lt;!--- ---&gt; " 448 }, 449 {TidyFixUri, 450 "This option specifies if Tidy should check attribute values that carry " 451 "URIs for illegal characters and if such are found, escape them as HTML 4 " 452 "recommends. " 453 }, 454 {TidyHideComments, 455 "This option specifies if Tidy should print out comments. " 456 }, 457 {TidyHideEndTags, 458 "This option specifies if Tidy should omit optional end-tags when " 459 "generating the pretty printed markup. This option is ignored if you are " 460 "outputting to XML. " 461 }, 462 {TidyIndentCdata, 463 "This option specifies if Tidy should indent &lt;![CDATA[]]&gt; sections. " 464 }, 465 {TidyXmlTags, 466 "This option specifies if Tidy should use the XML parser rather than the " 467 "error correcting HTML parser. " 468 }, 469 {TidyJoinClasses, 470 "This option specifies if Tidy should combine class names to generate " 471 "a single new class name, if multiple class assignments are detected on " 472 "an element. " 473 , TidyJoinClassesLinks 474 }, 475 {TidyJoinStyles, 476 "This option specifies if Tidy should combine styles to generate a single " 477 "new style, if multiple style values are detected on an element. " 478 , TidyJoinStylesLinks 479 }, 480 {TidyLogicalEmphasis, 481 "This option specifies if Tidy should replace any occurrence of &lt;I&gt; " 482 "by &lt;EM&gt; and any occurrence of &lt;B&gt; by &lt;STRONG&gt;. In both " 483 "cases, the attributes are preserved unchanged. This option can be set " 484 "independently of the clean and drop-font-tags options. " 485 }, 486 {TidyLowerLiterals, 487 "This option specifies if Tidy should convert the value of an attribute " 488 "that takes a list of predefined values to lower case. This is required " 489 "for XHTML documents. " 490 }, 491 {TidyMergeDivs, 492 "Can be used to modify behavior of -c (--clean yes) option. " 493 "This option specifies if Tidy should merge nested &lt;div&gt; such as " 494 "\"&lt;div&gt;&lt;div&gt;...&lt;/div&gt;&lt;/div&gt;\". If set to " 495 "\"auto\", the attributes of the inner &lt;div&gt; are moved to the " 496 "outer one. As well, nested &lt;div&gt; with ID attributes are not " 497 "merged. If set to \"yes\", the attributes of the inner &lt;div&gt; " 498 "are discarded with the exception of \"class\" and \"style\". " 499 ,TidyMergeDivsLinks 500 }, 501 #if SUPPORT_ASIAN_ENCODINGS 502 {TidyNCR, 503 "This option specifies if Tidy should allow numeric character references. " 504 }, 505 #endif 506 {TidyBlockTags, 507 "This option specifies new block-level tags. This option takes a space or " 508 "comma separated list of tag names. Unless you declare new tags, Tidy will " 509 "refuse to generate a tidied file if the input includes previously unknown " 510 "tags. Note you can't change the content model for elements such as " 511 "&lt;TABLE&gt;, &lt;UL&gt;, &lt;OL&gt; and &lt;DL&gt;. " 512 ,TidyBlockTagsLinks 513 }, 514 {TidyEmptyTags, 515 "This option specifies new empty inline tags. This option takes a space " 516 "or comma separated list of tag names. Unless you declare new tags, Tidy " 517 "will refuse to generate a tidied file if the input includes previously " 518 "unknown tags. Remember to also declare empty tags as either inline or " 519 "blocklevel. " 520 ,TidyEmptyTagsLinks 521 }, 522 {TidyInlineTags, 523 "This option specifies new non-empty inline tags. This option takes a " 524 "space or comma separated list of tag names. Unless you declare new tags, " 525 "Tidy will refuse to generate a tidied file if the input includes " 526 "previously unknown tags. " 527 ,TidyInlineTagsLinks 528 }, 529 { TidyPreTags, 530 "This option specifies " 531 "new tags that are to be processed in exactly the same way as HTML's " 532 "&lt;PRE&gt; element. This option takes a space or comma separated list " 533 "of tag names. Unless you declare new tags, Tidy will refuse to generate " 534 "a tidied file if the input includes previously unknown tags. Note you " 535 "can not as yet add new CDATA elements (similar to &lt;SCRIPT&gt;). " 536 ,TidyPreTagsLinks 537 }, 538 {TidyNumEntities, 539 "This option specifies if Tidy should output entities other than the " 540 "built-in HTML entities (&amp;amp;, &amp;lt;, &amp;gt; and &amp;quot;) in " 541 "the numeric rather than the named entity form. " 542 ,TidyNumEntitiesLinks 543 }, 544 {TidyHtmlOut, 545 "This option specifies if Tidy should generate pretty printed output, " 546 "writing it as HTML. " 547 }, 548 {TidyXhtmlOut, 549 "This option specifies if Tidy should generate pretty printed output, " 550 "writing it as extensible HTML. " 551 "This option causes Tidy to set the DOCTYPE and default namespace as " 552 "appropriate to XHTML. If a DOCTYPE or namespace is given they will " 553 "checked for consistency with the content of the document. In the case of " 554 "an inconsistency, the corrected values will appear in the output. For " 555 "XHTML, entities can be written as named or numeric entities according to " 556 "the setting of the \"numeric-entities\" option. The original case of tags " 557 "and attributes will be preserved, regardless of other options. " 558 }, 559 {TidyXmlOut, 560 "This option specifies if Tidy should pretty print output, writing it as " 561 "well-formed XML. Any entities not defined in XML 1.0 will be written as " 562 "numeric entities to allow them to be parsed by a XML parser. The original " 563 "case of tags and attributes will be preserved, regardless of other " 564 "options. " 565 }, 566 {TidyQuoteAmpersand, 567 "This option specifies if Tidy should output unadorned &amp; characters as " 568 "&amp;amp;. " 569 }, 570 {TidyQuoteMarks, 571 "This option specifies if Tidy should output &quot; characters as " 572 "&amp;quot; as is preferred by some editing environments. The apostrophe " 573 "character ' is written out as &amp;#39; since many web browsers don't yet " 574 "support &amp;apos;. " 575 }, 576 {TidyQuoteNbsp, 577 "This option specifies if Tidy should output non-breaking space characters " 578 "as entities, rather than as the Unicode character value 160 (decimal). " 579 }, 580 {TidyDuplicateAttrs, 581 "This option specifies if Tidy should keep the first or last attribute, if " 582 "an attribute is repeated, e.g. has two align attributes. " 583 , TidyDuplicateAttrsLinks 584 }, 585 {TidyReplaceColor, 586 "This option specifies if Tidy should replace numeric values in color " 587 "attributes by HTML/XHTML color names where defined, e.g. replace " 588 "\"#ffffff\" with \"white\". " 589 }, 590 {TidyBodyOnly, 591 "This option specifies if Tidy should print only the contents of the " 592 "body tag as an HTML fragment. Useful for incorporating existing whole " 593 "pages as a portion of another page. " 594 }, 595 {TidyUpperCaseAttrs, 596 "This option specifies if Tidy should output attribute names in upper " 597 "case. The default is no, which results in lower case attribute names, " 598 "except for XML input, where the original case is preserved. " 599 }, 600 {TidyUpperCaseTags, 601 "This option specifies if Tidy should output tag names in upper case. " 602 "The default is no, which results in lower case tag names, except for XML " 603 "input, where the original case is preserved. " 604 }, 605 {TidyWord2000, 606 "This option specifies if Tidy should go to great pains to strip out all " 607 "the surplus stuff Microsoft Word 2000 inserts when you save Word " 608 "documents as \"Web pages\". Doesn't handle embedded images or VML. " 609 "You should consider using Word's \"Save As: Web Page, Filtered\". " 610 }, 611 {TidyAccessibilityCheckLevel, 612 "This option specifies what level of accessibility checking, if any, " 613 "that Tidy should do. Level 0 is equivalent to Tidy Classic's " 614 "accessibility checking. " 615 "For more information on Tidy's accessibility checking, visit the " 616 "<a href=\"http://www.aprompt.ca/Tidy/accessibilitychecks.html\" " 617 ">Adaptive Technology Resource Centre at the University of Toronto</a>. " 618 }, 619 {TidyShowErrors, 620 "This option specifies the number Tidy uses to determine if further errors " 621 "should be shown. If set to 0, then no errors are shown. " 622 }, 623 {TidyShowWarnings, 624 "This option specifies if Tidy should suppress warnings. This can be " 625 "useful when a few errors are hidden in a flurry of warnings. " 626 }, 627 {TidyBreakBeforeBR, 628 "This option specifies if Tidy should output a line break before each " 629 "&lt;BR&gt; element. " 630 }, 631 {TidyIndentContent, 632 "This option specifies if Tidy should indent block-level tags. If set to " 633 "\"auto\", this option causes Tidy to decide whether or not to indent the " 634 "content of tags such as TITLE, H1-H6, LI, TD, TD, or P depending on " 635 "whether or not the content includes a block-level element. You are " 636 "advised to avoid setting indent to yes as this can expose layout bugs in " 637 "some browsers. " 638 ,TidyIndentContentLinks 639 }, 640 {TidyIndentAttributes, 641 "This option specifies if Tidy should begin each attribute on a new line. " 642 }, 643 {TidyIndentSpaces, 644 "This option specifies the number of spaces Tidy uses to indent content, " 645 "when indentation is enabled. " 646 ,TidyIndentSpacesLinks 647 }, 648 {TidyLiteralAttribs, 649 "This option specifies if Tidy should ensure that whitespace characters " 650 "within attribute values are passed through unchanged. " 651 }, 652 {TidyShowMarkup, 653 "This option specifies if Tidy should generate a pretty printed version " 654 "of the markup. Note that Tidy won't generate a pretty printed version if " 655 "it finds significant errors (see force-output). " 656 }, 657 #if SUPPORT_ASIAN_ENCODINGS 658 {TidyPunctWrap, 659 "This option specifies if Tidy should line wrap after some Unicode or " 660 "Chinese punctuation characters. " 661 }, 662 #endif 663 {TidyBurstSlides, 664 "Currently not used. Tidy Classic only. " 665 }, 666 {TidyTabSize, 667 "This option specifies the number of columns that Tidy uses between " 668 "successive tab stops. It is used to map tabs to spaces when reading the " 669 "input. Tidy never outputs tabs. " 670 }, 671 {TidyVertSpace, 672 "This option specifies if Tidy should add some empty lines for " 673 "readability. " 674 }, 675 {TidyWrapLen, 676 "This option specifies the right margin Tidy uses for line wrapping. Tidy " 677 "tries to wrap lines so that they do not exceed this length. Set wrap to " 678 "zero if you want to disable line wrapping. " 679 }, 680 {TidyWrapAsp, 681 "This option specifies if Tidy should line wrap text contained within ASP " 682 "pseudo elements, which look like: &lt;% ... %&gt;. " 683 }, 684 {TidyWrapAttVals, 685 "This option specifies if Tidy should line wrap attribute values, for " 686 "easier editing. This option can be set independently of " 687 "wrap-script-literals. " 688 ,TidyWrapAttValsLinks 689 }, 690 {TidyWrapJste, 691 "This option specifies if Tidy should line wrap text contained within " 692 "JSTE pseudo elements, which look like: &lt;# ... #&gt;. " 693 }, 694 {TidyWrapPhp, 695 "This option specifies if Tidy should line wrap text contained within PHP " 696 "pseudo elements, which look like: &lt;?php ... ?&gt;. " 697 }, 698 {TidyWrapScriptlets, 699 "This option specifies if Tidy should line wrap string literals that " 700 "appear in script attributes. Tidy wraps long script string literals by " 701 "inserting a backslash character before the line break. " 702 ,TidyWrapScriptletsLinks 703 }, 704 {TidyWrapSection, 705 "This option specifies if Tidy should line wrap text contained within " 706 "&lt;![ ... ]&gt; section tags. " 707 }, 708 {TidyAsciiChars, 709 "Can be used to modify behavior of -c (--clean yes) option. If set " 710 "to \"yes\" when using -c, &amp;emdash;, &amp;rdquo;, and other named " 711 "character entities are downgraded to their closest ascii equivalents. " 712 ,TidyAsciiCharsLinks 713 }, 714 {TidyCharEncoding, 715 "This option specifies the character encoding Tidy uses for both the input " 716 "and output. For ascii, Tidy will accept Latin-1 (ISO-8859-1) character " 717 "values, but will use entities for all characters whose value &gt; 127. " 718 "For raw, Tidy will output values above 127 without translating them into " 719 "entities. For latin1, characters above 255 will be written as entities. " 720 "For utf8, Tidy assumes that both input and output is encoded as UTF-8. " 721 "You can use iso2022 for files encoded using the ISO-2022 family of " 722 "encodings e.g. ISO-2022-JP. For mac and win1252, Tidy will accept vendor " 723 "specific character values, but will use entities for all characters whose " 724 "value &gt; 127. " 725 ,TidyCharEncodingLinks 726 }, 727 {TidyInCharEncoding, 728 "This option specifies the character encoding Tidy uses for the input. See " 729 "char-encoding for more info. " 730 ,TidyInCharEncodingLinks 731 }, 732 #if SUPPORT_ASIAN_ENCODINGS 733 {TidyLanguage, 734 "Currently not used, but this option specifies the language Tidy uses " 735 "(for instance \"en\"). " 736 }, 737 #endif 738 #if SUPPORT_UTF16_ENCODINGS 739 {TidyOutputBOM, 740 "This option specifies if Tidy should write a Unicode Byte Order Mark " 741 "character (BOM; also known as Zero Width No-Break Space; has value of " 742 "U+FEFF) to the beginning of the output; only for UTF-8 and UTF-16 output " 743 "encodings. If set to \"auto\", this option causes Tidy to write a BOM to " 744 "the output only if a BOM was present at the beginning of the input. A BOM " 745 "is always written for XML/XHTML output using UTF-16 output encodings. " 746 }, 747 #endif 748 {TidyOutCharEncoding, 749 "This option specifies the character encoding Tidy uses for the output. " 750 "See char-encoding for more info. May only be different from " 751 "input-encoding for Latin encodings (ascii, latin0, latin1, mac, win1252, " 752 "ibm858). " 753 ,TidyOutCharEncodingLinks 754 }, 755 {TidyNewline, 756 "The default is appropriate to the current platform: CRLF on PC-DOS, " 757 "MS-Windows and OS/2, CR on Classic Mac OS, and LF everywhere else " 758 "(Unix and Linux). " 759 }, 760 {TidyErrFile, 761 "This option specifies the error file Tidy uses for errors and warnings. " 762 "Normally errors and warnings are output to \"stderr\". " 763 ,TidyErrFileLinks 764 }, 765 {TidyFixBackslash, 766 "This option specifies if Tidy should replace backslash characters " 767 "\"<code>\\</code>\" in URLs by forward slashes \"<code>/</code>\". " 768 }, 769 {TidyForceOutput, 770 "This option specifies if Tidy should produce output even if errors are " 771 "encountered. Use this option with care - if Tidy reports an error, this " 772 "means Tidy was not able to, or is not sure how to, fix the error, so the " 773 "resulting output may not reflect your intention. " 774 }, 775 {TidyEmacs, 776 "This option specifies if Tidy should change the format for reporting " 777 "errors and warnings to a format that is more easily parsed by GNU Emacs. " 778 }, 779 {TidyEmacsFile, 780 "Used internally. " 781 }, 782 {TidyKeepFileTimes, 783 "This option specifies if Tidy should keep the original modification time " 784 "of files that Tidy modifies in place. The default is no. Setting the " 785 "option to yes allows you to tidy files without causing these files to be " 786 "uploaded to a web server when using a tool such as SiteCopy. Note this " 787 "feature is not supported on some platforms. " 788 }, 789 {TidyOutFile, 790 "This option specifies the output file Tidy uses for markup. Normally " 791 "markup is written to \"stdout\". " 792 ,TidyOutFileLinks 793 }, 794 {TidyQuiet, 795 "This option specifies if Tidy should output the summary of the numbers " 796 "of errors and warnings, or the welcome or informational messages. " 797 }, 798 {TidySlideStyle, 799 "Currently not used. Tidy Classic only. " 800 }, 801 {TidyMark, 802 "This option specifies if Tidy should add a meta element to the document " 803 "head to indicate that the document has been tidied. Tidy won't add a meta " 804 "element if one is already present. " 805 }, 806 {TidyWriteBack, 807 "This option specifies if Tidy should write back the tidied markup to the " 808 "same file it read from. You are advised to keep copies of important files " 809 "before tidying them, as on rare occasions the result may not be what you " 810 "expect. " 811 }, 812 {N_TIDY_OPTIONS, 813 NULL 814 } 815 }; 816 817 const TidyOptionDoc* tidyOptGetDocDesc( TidyOptionId optId ) 818 { 819 uint i = 0; 820 821 while( option_docs[i].opt != N_TIDY_OPTIONS ) 822 { 823 if ( option_docs[i].opt == optId ) 824 return &option_docs[i]; 825 ++i; 826 } 827 return NULL; 828 } 829 830 831 static char* LevelPrefix( TidyReportLevel level, char* buf, size_t count ) 832 { 833 *buf = 0; 834 switch ( level ) 835 { 836 case TidyInfo: 837 tmbstrncpy( buf, "Info: ", count ); 838 break; 839 case TidyWarning: 840 tmbstrncpy( buf, "Warning: ", count ); 841 break; 842 case TidyConfig: 843 tmbstrncpy( buf, "Config: ", count ); 844 break; 845 case TidyAccess: 846 tmbstrncpy( buf, "Access: ", count ); 847 break; 848 case TidyError: 849 tmbstrncpy( buf, "Error: ", count ); 850 break; 851 case TidyBadDocument: 852 tmbstrncpy( buf, "Document: ", count ); 853 break; 854 case TidyFatal: 855 tmbstrncpy( buf, "panic: ", count ); 856 break; 857 } 858 return buf + tmbstrlen( buf ); 859 } 860 861 /* Updates document message counts and 862 ** compares counts to options to see if message 863 ** display should go forward. 864 */ 865 static Bool UpdateCount( TidyDocImpl* doc, TidyReportLevel level ) 866 { 867 /* keep quiet after <ShowErrors> errors */ 868 Bool go = ( doc->errors < cfg(doc, TidyShowErrors) ); 869 870 switch ( level ) 871 { 872 case TidyInfo: 873 doc->infoMessages++; 874 break; 875 case TidyWarning: 876 doc->warnings++; 877 go = go && cfgBool( doc, TidyShowWarnings ); 878 break; 879 case TidyConfig: 880 doc->optionErrors++; 881 break; 882 case TidyAccess: 883 doc->accessErrors++; 884 break; 885 case TidyError: 886 doc->errors++; 887 break; 888 case TidyBadDocument: 889 doc->docErrors++; 890 break; 891 case TidyFatal: 892 /* Ack! */; 893 break; 894 } 895 896 return go; 897 } 898 899 static char* ReportPosition(TidyDocImpl* doc, int line, int col, char* buf, size_t count) 900 { 901 *buf = 0; 902 903 /* Change formatting to be parsable by GNU Emacs */ 904 if ( cfgBool(doc, TidyEmacs) && cfgStr(doc, TidyEmacsFile) ) 905 tmbsnprintf(buf, count, "%s:%d:%d: ", 906 cfgStr(doc, TidyEmacsFile), line, col); 907 else /* traditional format */ 908 tmbsnprintf(buf, count, "line %d column %d - ", line, col); 909 return buf + tmbstrlen( buf ); 910 } 911 912 /* General message writing routine. 913 ** Each message is a single warning, error, etc. 914 ** 915 ** This routine will keep track of counts and, 916 ** if the caller has set a filter, it will be 917 ** called. The new preferred way of handling 918 ** Tidy diagnostics output is either a) define 919 ** a new output sink or b) install a message 920 ** filter routine. 921 */ 922 923 static void messagePos( TidyDocImpl* doc, TidyReportLevel level, 924 int line, int col, ctmbstr msg, va_list args ) 925 #ifdef __GNUC__ 926 __attribute__((format(printf, 5, 0))) 927 #endif 928 ; 929 static void messagePos( TidyDocImpl* doc, TidyReportLevel level, 930 int line, int col, ctmbstr msg, va_list args ) 931 { 932 char messageBuf[ 2048 ]; 933 Bool go = UpdateCount( doc, level ); 934 935 if ( go ) 936 { 937 tmbvsnprintf(messageBuf, sizeof(messageBuf), msg, args); 938 if ( doc->mssgFilt ) 939 { 940 TidyDoc tdoc = tidyImplToDoc( doc ); 941 go = doc->mssgFilt( tdoc, level, line, col, messageBuf ); 942 } 943 } 944 945 if ( go ) 946 { 947 char buf[ 64 ]; 948 const char *cp; 949 if ( line > 0 && col > 0 ) 950 { 951 ReportPosition(doc, line, col, buf, sizeof(buf)); 952 for ( cp = buf; *cp; ++cp ) 953 WriteChar( *cp, doc->errout ); 954 } 955 956 LevelPrefix( level, buf, sizeof(buf) ); 957 for ( cp = buf; *cp; ++cp ) 958 WriteChar( *cp, doc->errout ); 959 960 for ( cp = messageBuf; *cp; ++cp ) 961 WriteChar( *cp, doc->errout ); 962 WriteChar( '\n', doc->errout ); 963 } 964 } 965 966 void message( TidyDocImpl* doc, TidyReportLevel level, ctmbstr msg, ... ) 967 { 968 va_list args; 969 va_start( args, msg ); 970 messagePos( doc, level, 0, 0, msg, args ); 971 va_end( args ); 972 } 973 974 975 void messageLexer( TidyDocImpl* doc, TidyReportLevel level, ctmbstr msg, ... ) 976 { 977 int line = ( doc->lexer ? doc->lexer->lines : 0 ); 978 int col = ( doc->lexer ? doc->lexer->columns : 0 ); 979 980 va_list args; 981 va_start( args, msg ); 982 messagePos( doc, level, line, col, msg, args ); 983 va_end( args ); 984 } 985 986 void messageNode( TidyDocImpl* doc, TidyReportLevel level, Node* node, 987 ctmbstr msg, ... ) 988 { 989 int line = ( node ? node->line : 990 ( doc->lexer ? doc->lexer->lines : 0 ) ); 991 int col = ( node ? node->column : 992 ( doc->lexer ? doc->lexer->columns : 0 ) ); 993 994 va_list args; 995 va_start( args, msg ); 996 messagePos( doc, level, line, col, msg, args ); 997 va_end( args ); 998 } 999 1000 void tidy_out( TidyDocImpl* doc, ctmbstr msg, ... ) 1001 { 1002 if ( !cfgBool(doc, TidyQuiet) ) 1003 { 1004 ctmbstr cp; 1005 char buf[ 2048 ]; 1006 1007 va_list args; 1008 va_start( args, msg ); 1009 tmbvsnprintf(buf, sizeof(buf), msg, args); 1010 va_end( args ); 1011 1012 for ( cp=buf; *cp; ++cp ) 1013 WriteChar( *cp, doc->errout ); 1014 } 1015 } 1016 1017 void ShowVersion( TidyDocImpl* doc ) 1018 { 1019 ctmbstr platform = "", helper = ""; 1020 1021 #ifdef PLATFORM_NAME 1022 platform = PLATFORM_NAME; 1023 helper = " for "; 1024 #endif 1025 1026 tidy_out( doc, "\nHTML Tidy%s%s (release date: %s; built on %s, at %s)\n" 1027 "See http://tidy.sourceforge.net/ for details.\n", 1028 helper, platform, release_date, __DATE__, __TIME__ ); 1029 } 1030 1031 void FileError( TidyDocImpl* doc, ctmbstr file, TidyReportLevel level ) 1032 { 1033 message( doc, level, "Can't open \"%s\"\n", file ); 1034 } 1035 1036 static char* TagToString(Node* tag, char* buf, size_t count) 1037 { 1038 *buf = 0; 1039 if (tag) 1040 { 1041 if (nodeIsElement(tag)) 1042 tmbsnprintf(buf, count, "<%s>", tag->element); 1043 else if (tag->type == EndTag) 1044 tmbsnprintf(buf, count, "</%s>", tag->element); 1045 else if (tag->type == DocTypeTag) 1046 tmbsnprintf(buf, count, "<!DOCTYPE>"); 1047 else if (tag->type == TextNode) 1048 tmbsnprintf(buf, count, "plain text"); 1049 else if (tag->type == XmlDecl) 1050 tmbsnprintf(buf, count, "XML declaration"); 1051 else if (tag->element) 1052 tmbsnprintf(buf, count, "%s", tag->element); 1053 } 1054 return buf + tmbstrlen(buf); 1055 } 1056 1057 /* lexer is not defined when this is called */ 1058 void ReportUnknownOption( TidyDocImpl* doc, ctmbstr option ) 1059 { 1060 assert( option != NULL ); 1061 message( doc, TidyConfig, "unknown option: %s", option ); 1062 } 1063 1064 /* lexer is not defined when this is called */ 1065 void ReportBadArgument( TidyDocImpl* doc, ctmbstr option ) 1066 { 1067 assert( option != NULL ); 1068 message( doc, TidyConfig, 1069 "missing or malformed argument for option: %s", option ); 1070 } 1071 1072 static void NtoS(int n, tmbstr str) 1073 { 1074 tmbchar buf[40]; 1075 int i; 1076 1077 for (i = 0;; ++i) 1078 { 1079 buf[i] = (tmbchar)( (n % 10) + '' ); 1080 1081 n = n / 10; 1082 1083 if (n == 0) 1084 break; 1085 } 1086 1087 n = i; 1088 1089 while (i >= 0) 1090 { 1091 str[n-i] = buf[i]; 1092 --i; 1093 } 1094 1095 str[n+1] = '\0'; 1096 } 1097 1098 void ReportEncodingWarning(TidyDocImpl* doc, uint code, uint encoding) 1099 { 1100 switch(code) 1101 { 1102 case ENCODING_MISMATCH: 1103 messageLexer(doc, TidyWarning, GetFormatFromCode(code), 1104 CharEncodingName(doc->docIn->encoding), 1105 CharEncodingName(encoding)); 1106 doc->badChars |= BC_ENCODING_MISMATCH; 1107 break; 1108 } 1109 } 1110 1111 void ReportEncodingError(TidyDocImpl* doc, uint code, uint c, Bool discarded) 1112 { 1113 char buf[ 32 ] = {'\0'}; 1114 1115 ctmbstr action = discarded ? "discarding" : "replacing"; 1116 ctmbstr fmt = GetFormatFromCode(code); 1117 1118 /* An encoding mismatch is currently treated as a non-fatal error */ 1119 switch (code) 1120 { 1121 case VENDOR_SPECIFIC_CHARS: 1122 NtoS(c, buf); 1123 doc->badChars |= BC_VENDOR_SPECIFIC_CHARS; 1124 break; 1125 1126 case INVALID_SGML_CHARS: 1127 NtoS(c, buf); 1128 doc->badChars |= BC_INVALID_SGML_CHARS; 1129 break; 1130 1131 case INVALID_UTF8: 1132 tmbsnprintf(buf, sizeof(buf), "U+%04X", c); 1133 doc->badChars |= BC_INVALID_UTF8; 1134 break; 1135 1136 #if SUPPORT_UTF16_ENCODINGS 1137 case INVALID_UTF16: 1138 tmbsnprintf(buf, sizeof(buf), "U+%04X", c); 1139 doc->badChars |= BC_INVALID_UTF16; 1140 break; 1141 #endif 1142 1143 case INVALID_NCR: 1144 NtoS(c, buf); 1145 doc->badChars |= BC_INVALID_NCR; 1146 break; 1147 } 1148 1149 if (fmt) 1150 messageLexer( doc, TidyWarning, fmt, action, buf ); 1151 } 1152 1153 void ReportEntityError( TidyDocImpl* doc, uint code, ctmbstr entity, 1154 int ARG_UNUSED(c) ) 1155 { 1156 ctmbstr entityname = ( entity ? entity : "NULL" ); 1157 ctmbstr fmt = GetFormatFromCode(code); 1158 1159 if (fmt) 1160 messageLexer( doc, TidyWarning, fmt, entityname ); 1161 } 1162 1163 void ReportAttrError(TidyDocImpl* doc, Node *node, AttVal *av, uint code) 1164 { 1165 char const *name = "NULL", *value = "NULL"; 1166 char tagdesc[64]; 1167 ctmbstr fmt = GetFormatFromCode(code); 1168 1169 assert( fmt != NULL ); 1170 1171 TagToString(node, tagdesc, sizeof(tagdesc)); 1172 1173 if (av) 1174 { 1175 if (av->attribute) 1176 name = av->attribute; 1177 if (av->value) 1178 value = av->value; 1179 } 1180 1181 switch (code) 1182 { 1183 case UNKNOWN_ATTRIBUTE: 1184 case INSERTING_ATTRIBUTE: 1185 case MISSING_ATTR_VALUE: 1186 case XML_ATTRIBUTE_VALUE: 1187 case PROPRIETARY_ATTRIBUTE: 1188 case JOINING_ATTRIBUTE: 1189 messageNode(doc, TidyWarning, node, fmt, tagdesc, name); 1190 break; 1191 1192 case BAD_ATTRIBUTE_VALUE: 1193 case BAD_ATTRIBUTE_VALUE_REPLACED: 1194 case INVALID_ATTRIBUTE: 1195 messageNode(doc, TidyWarning, node, fmt, tagdesc, name, value); 1196 break; 1197 1198 case UNEXPECTED_QUOTEMARK: 1199 case MISSING_QUOTEMARK: 1200 case ID_NAME_MISMATCH: 1201 case BACKSLASH_IN_URI: 1202 case FIXED_BACKSLASH: 1203 case ILLEGAL_URI_REFERENCE: 1204 case ESCAPED_ILLEGAL_URI: 1205 case NEWLINE_IN_URI: 1206 case UNEXPECTED_GT: 1207 case INVALID_XML_ID: 1208 case UNEXPECTED_EQUALSIGN: 1209 messageNode(doc, TidyWarning, node, fmt, tagdesc); 1210 break; 1211 1212 case XML_ID_SYNTAX: 1213 case PROPRIETARY_ATTR_VALUE: 1214 case ANCHOR_NOT_UNIQUE: 1215 case ATTR_VALUE_NOT_LCASE: 1216 messageNode(doc, TidyWarning, node, fmt, tagdesc, value); 1217 break; 1218 1219 1220 case MISSING_IMAGEMAP: /* this is not used anywhere */ 1221 messageNode(doc, TidyWarning, node, fmt, tagdesc); 1222 doc->badAccess |= MISSING_IMAGE_MAP; 1223 break; 1224 1225 case REPEATED_ATTRIBUTE: 1226 messageNode(doc, TidyWarning, node, fmt, tagdesc, value, name); 1227 break; 1228 1229 case UNEXPECTED_END_OF_FILE_ATTR: 1230 /* on end of file adjust reported position to end of input */ 1231 doc->lexer->lines = doc->docIn->curline; 1232 doc->lexer->columns = doc->docIn->curcol; 1233 messageLexer(doc, TidyWarning, fmt, tagdesc); 1234 break; 1235 } 1236 } 1237 1238 void ReportMissingAttr( TidyDocImpl* doc, Node* node, ctmbstr name ) 1239 { 1240 char tagdesc[ 64 ]; 1241 ctmbstr fmt = GetFormatFromCode(MISSING_ATTRIBUTE); 1242 1243 assert( fmt != NULL ); 1244 TagToString(node, tagdesc, sizeof(tagdesc)); 1245 messageNode( doc, TidyWarning, node, fmt, tagdesc, name ); 1246 } 1247 1248 #if SUPPORT_ACCESSIBILITY_CHECKS 1249 1250 /********************************************************* 1251 * Accessibility 1252 * 1253 * DisplayHTMLTableAlgorithm() 1254 * 1255 * If the table does contain 2 or more logical levels of 1256 * row or column headers, the HTML 4 table algorithm 1257 * to show the author how the headers are currently associated 1258 * with the cells. 1259 *********************************************************/ 1260 1261 void DisplayHTMLTableAlgorithm( TidyDocImpl* doc ) 1262 { 1263 tidy_out(doc, " \n"); 1264 tidy_out(doc, " - First, search left from the cell's position to find row header cells.\n"); 1265 tidy_out(doc, " - Then search upwards to find column header cells.\n"); 1266 tidy_out(doc, " - The search in a given direction stops when the edge of the table is\n"); 1267 tidy_out(doc, " reached or when a data cell is found after a header cell.\n"); 1268 tidy_out(doc, " - Row headers are inserted into the list in the order they appear in\n"); 1269 tidy_out(doc, " the table. \n"); 1270 tidy_out(doc, " - For left-to-right tables, headers are inserted from left to right.\n"); 1271 tidy_out(doc, " - Column headers are inserted after row headers, in \n"); 1272 tidy_out(doc, " the order they appear in the table, from top to bottom. \n"); 1273 tidy_out(doc, " - If a header cell has the headers attribute set, then the headers \n"); 1274 tidy_out(doc, " referenced by this attribute are inserted into the list and the \n"); 1275 tidy_out(doc, " search stops for the current direction.\n"); 1276 tidy_out(doc, " TD cells that set the axis attribute are also treated as header cells.\n"); 1277 tidy_out(doc, " \n"); 1278 } 1279 1280 void ReportAccessWarning( TidyDocImpl* doc, Node* node, uint code ) 1281 { 1282 ctmbstr fmt = GetFormatFromCode(code); 1283 doc->badAccess = yes; 1284 messageNode( doc, TidyAccess, node, fmt ); 1285 } 1286 1287 void ReportAccessError( TidyDocImpl* doc, Node* node, uint code ) 1288 { 1289 ctmbstr fmt = GetFormatFromCode(code); 1290 doc->badAccess = yes; 1291 messageNode( doc, TidyAccess, node, fmt ); 1292 } 1293 1294 #endif /* SUPPORT_ACCESSIBILITY_CHECKS */ 1295 1296 void ReportWarning(TidyDocImpl* doc, Node *element, Node *node, uint code) 1297 { 1298 Node* rpt = (element ? element : node); 1299 ctmbstr fmt = GetFormatFromCode(code); 1300 char nodedesc[256] = { 0 }; 1301 char elemdesc[256] = { 0 }; 1302 1303 assert( fmt != NULL ); 1304 1305 TagToString(node, nodedesc, sizeof(nodedesc)); 1306 1307 switch (code) 1308 { 1309 case NESTED_QUOTATION: 1310 messageNode(doc, TidyWarning, rpt, fmt); 1311 break; 1312 1313 case OBSOLETE_ELEMENT: 1314 TagToString(element, elemdesc, sizeof(elemdesc)); 1315 messageNode(doc, TidyWarning, rpt, fmt, elemdesc, nodedesc); 1316 break; 1317 1318 case NESTED_EMPHASIS: 1319 messageNode(doc, TidyWarning, rpt, fmt, nodedesc); 1320 break; 1321 case COERCE_TO_ENDTAG_WARN: 1322 messageNode(doc, TidyWarning, rpt, fmt, node->element, node->element); 1323 break; 1324 } 1325 } 1326 1327 void ReportNotice(TidyDocImpl* doc, Node *element, Node *node, uint code) 1328 { 1329 Node* rpt = ( element ? element : node ); 1330 ctmbstr fmt = GetFormatFromCode(code); 1331 char nodedesc[256] = { 0 }; 1332 char elemdesc[256] = { 0 }; 1333 1334 assert( fmt != NULL ); 1335 1336 TagToString(node, nodedesc, sizeof(nodedesc)); 1337 1338 switch (code) 1339 { 1340 case TRIM_EMPTY_ELEMENT: 1341 TagToString(element, elemdesc, sizeof(nodedesc)); 1342 messageNode(doc, TidyWarning, element, fmt, elemdesc); 1343 break; 1344 1345 case REPLACING_ELEMENT: 1346 TagToString(element, elemdesc, sizeof(elemdesc)); 1347 messageNode(doc, TidyWarning, rpt, fmt, elemdesc, nodedesc); 1348 break; 1349 } 1350 } 1351 1352 void ReportError(TidyDocImpl* doc, Node *element, Node *node, uint code) 1353 { 1354 char nodedesc[ 256 ] = {0}; 1355 char elemdesc[ 256 ] = {0}; 1356 Node* rpt = ( element ? element : node ); 1357 ctmbstr fmt = GetFormatFromCode(code); 1358 1359 assert( fmt != NULL ); 1360 1361 TagToString(node, nodedesc, sizeof(nodedesc)); 1362 1363 switch ( code ) 1364 { 1365 case MISSING_STARTTAG: 1366 case UNEXPECTED_ENDTAG: 1367 case TOO_MANY_ELEMENTS: 1368 case INSERTING_TAG: 1369 messageNode(doc, TidyWarning, node, fmt, node->element); 1370 break; 1371 1372 case USING_BR_INPLACE_OF: 1373 case CANT_BE_NESTED: 1374 case PROPRIETARY_ELEMENT: 1375 case UNESCAPED_ELEMENT: 1376 case NOFRAMES_CONTENT: 1377 messageNode(doc, TidyWarning, node, fmt, nodedesc); 1378 break; 1379 1380 case MISSING_TITLE_ELEMENT: 1381 case INCONSISTENT_VERSION: 1382 case MALFORMED_DOCTYPE: 1383 case CONTENT_AFTER_BODY: 1384 case MALFORMED_COMMENT: 1385 case BAD_COMMENT_CHARS: 1386 case BAD_XML_COMMENT: 1387 case BAD_CDATA_CONTENT: 1388 case INCONSISTENT_NAMESPACE: 1389 case DOCTYPE_AFTER_TAGS: 1390 case DTYPE_NOT_UPPER_CASE: 1391 messageNode(doc, TidyWarning, rpt, fmt); 1392 break; 1393 1394 case COERCE_TO_ENDTAG: 1395 case NON_MATCHING_ENDTAG: 1396 messageNode(doc, TidyWarning, rpt, fmt, node->element, node->element); 1397 break; 1398 1399 case UNEXPECTED_ENDTAG_IN: 1400 case TOO_MANY_ELEMENTS_IN: 1401 messageNode(doc, TidyWarning, node, fmt, node->element, element->element); 1402 break; 1403 1404 case ENCODING_IO_CONFLICT: 1405 case MISSING_DOCTYPE: 1406 case SPACE_PRECEDING_XMLDECL: 1407 messageNode(doc, TidyWarning, node, fmt); 1408 break; 1409 1410 case TRIM_EMPTY_ELEMENT: 1411 case ILLEGAL_NESTING: 1412 case UNEXPECTED_END_OF_FILE: 1413 case ELEMENT_NOT_EMPTY: 1414 TagToString(element, elemdesc, sizeof(elemdesc)); 1415 messageNode(doc, TidyWarning, element, fmt, elemdesc); 1416 break; 1417 1418 1419 case MISSING_ENDTAG_FOR: 1420 messageNode(doc, TidyWarning, rpt, fmt, element->element); 1421 break; 1422 1423 case MISSING_ENDTAG_BEFORE: 1424 messageNode(doc, TidyWarning, rpt, fmt, element->element, nodedesc); 1425 break; 1426 1427 case DISCARDING_UNEXPECTED: 1428 /* Force error if in a bad form */ 1429 messageNode(doc, doc->badForm ? TidyError : TidyWarning, node, fmt, nodedesc); 1430 break; 1431 1432 case TAG_NOT_ALLOWED_IN: 1433 messageNode(doc, TidyWarning, rpt, fmt, nodedesc, element->element); 1434 break; 1435 1436 case REPLACING_UNEX_ELEMENT: 1437 TagToString(element, elemdesc, sizeof(elemdesc)); 1438 messageNode(doc, TidyWarning, rpt, fmt, elemdesc, nodedesc); 1439 break; 1440 } 1441 } 1442 1443 void ReportFatal( TidyDocImpl* doc, Node *element, Node *node, uint code) 1444 { 1445 char nodedesc[ 256 ] = {0}; 1446 Node* rpt = ( element ? element : node ); 1447 ctmbstr fmt = GetFormatFromCode(code); 1448 1449 switch ( code ) 1450 { 1451 case SUSPECTED_MISSING_QUOTE: 1452 case DUPLICATE_FRAMESET: 1453 messageNode(doc, TidyError, rpt, fmt); 1454 break; 1455 1456 case UNKNOWN_ELEMENT: 1457 TagToString(node, nodedesc, sizeof(nodedesc)); 1458 messageNode( doc, TidyError, node, fmt, nodedesc ); 1459 break; 1460 1461 case UNEXPECTED_ENDTAG_IN: 1462 messageNode(doc, TidyError, node, fmt, node->element, element->element); 1463 break; 1464 1465 case UNEXPECTED_ENDTAG: /* generated by XML docs */ 1466 messageNode(doc, TidyError, node, fmt, node->element); 1467 break; 1468 } 1469 } 1470 1471 void ErrorSummary( TidyDocImpl* doc ) 1472 { 1473 /* adjust badAccess to that its NULL if frames are ok */ 1474 ctmbstr encnam = "specified"; 1475 int charenc = cfg( doc, TidyCharEncoding ); 1476 if ( charenc == WIN1252 ) 1477 encnam = "Windows-1252"; 1478 else if ( charenc == MACROMAN ) 1479 encnam = "MacRoman"; 1480 else if ( charenc == IBM858 ) 1481 encnam = "ibm858"; 1482 else if ( charenc == LATIN0 ) 1483 encnam = "latin0"; 1484 1485 if ( doc->badAccess & (USING_FRAMES | USING_NOFRAMES) ) 1486 { 1487 if (!((doc->badAccess & USING_FRAMES) && !(doc->badAccess & USING_NOFRAMES))) 1488 doc->badAccess &= ~(USING_FRAMES | USING_NOFRAMES); 1489 } 1490 1491 if (doc->badChars) 1492 { 1493 #if 0 1494 if ( doc->badChars & WINDOWS_CHARS ) 1495 { 1496 tidy_out(doc, "Characters codes for the Microsoft Windows fonts in the range\n"); 1497 tidy_out(doc, "128 - 159 may not be recognized on other platforms. You are\n"); 1498 tidy_out(doc, "instead recommended to use named entities, e.g. &trade; rather\n"); 1499 tidy_out(doc, "than Windows character code 153 (0x2122 in Unicode). Note that\n"); 1500 tidy_out(doc, "as of February 1998 few browsers support the new entities.\n\n"); 1501 } 1502 #endif 1503 if (doc->badChars & BC_VENDOR_SPECIFIC_CHARS) 1504 { 1505 1506 tidy_out(doc, "It is unlikely that vendor-specific, system-dependent encodings\n"); 1507 tidy_out(doc, "work widely enough on the World Wide Web; you should avoid using the \n"); 1508 tidy_out(doc, "%s", encnam ); 1509 tidy_out(doc, " character encoding, instead you are recommended to\n" ); 1510 tidy_out(doc, "use named entities, e.g. &trade;.\n\n"); 1511 } 1512 if ((doc->badChars & BC_INVALID_SGML_CHARS) || (doc->badChars & BC_INVALID_NCR)) 1513 { 1514 tidy_out(doc, "Character codes 128 to 159 (U+0080 to U+009F) are not allowed in HTML;\n"); 1515 tidy_out(doc, "even if they were, they would likely be unprintable control characters.\n"); 1516 tidy_out(doc, "Tidy assumed you wanted to refer to a character with the same byte value in the \n"); 1517 tidy_out(doc, "%s", encnam ); 1518 tidy_out(doc, " encoding and replaced that reference with the Unicode equivalent.\n\n" ); 1519 } 1520 if (doc->badChars & BC_INVALID_UTF8) 1521 { 1522 tidy_out(doc, "Character codes for UTF-8 must be in the range: U+0000 to U+10FFFF.\n"); 1523 tidy_out(doc, "The definition of UTF-8 in Annex D of ISO/IEC 10646-1:2000 also\n"); 1524 tidy_out(doc, "allows for the use of five- and six-byte sequences to encode\n"); 1525 tidy_out(doc, "characters that are outside the range of the Unicode character set;\n"); 1526 tidy_out(doc, "those five- and six-byte sequences are illegal for the use of\n"); 1527 tidy_out(doc, "UTF-8 as a transformation of Unicode characters. ISO/IEC 10646\n"); 1528 tidy_out(doc, "does not allow mapping of unpaired surrogates, nor U+FFFE and U+FFFF\n"); 1529 tidy_out(doc, "(but it does allow other noncharacters). For more information please refer to\n"); 1530 tidy_out(doc, "http://www.unicode.org/unicode and http://www.cl.cam.ac.uk/~mgk25/unicode.html\n\n"); 1531 } 1532 1533 #if SUPPORT_UTF16_ENCODINGS 1534 1535 if (doc->badChars & BC_INVALID_UTF16) 1536 { 1537 tidy_out(doc, "Character codes for UTF-16 must be in the range: U+0000 to U+10FFFF.\n"); 1538 tidy_out(doc, "The definition of UTF-16 in Annex C of ISO/IEC 10646-1:2000 does not allow the\n"); 1539 tidy_out(doc, "mapping of unpaired surrogates. For more information please refer to\n"); 1540 tidy_out(doc, "http://www.unicode.org/unicode and http://www.cl.cam.ac.uk/~mgk25/unicode.html\n\n"); 1541 } 1542 1543 #endif 1544 1545 if (doc->badChars & BC_INVALID_URI) 1546 { 1547 tidy_out(doc, "URIs must be properly escaped, they must not contain unescaped\n"); 1548 tidy_out(doc, "characters below U+0021 including the space character and not\n"); 1549 tidy_out(doc, "above U+007E. Tidy escapes the URI for you as recommended by\n"); 1550 tidy_out(doc, "HTML 4.01 section B.2.1 and XML 1.0 section 4.2.2. Some user agents\n"); 1551 tidy_out(doc, "use another algorithm to escape such URIs and some server-sided\n"); 1552 tidy_out(doc, "scripts depend on that. If you want to depend on that, you must\n"); 1553 tidy_out(doc, "escape the URI by your own. For more information please refer to\n"); 1554 tidy_out(doc, "http://www.w3.org/International/O-URL-and-ident.html\n\n"); 1555 } 1556 } 1557 1558 if (doc->badForm) 1559 { 1560 tidy_out(doc, "You may need to move one or both of the <form> and </form>\n"); 1561 tidy_out(doc, "tags. HTML elements should be properly nested and form elements\n"); 1562 tidy_out(doc, "are no exception. For instance you should not place the <form>\n"); 1563 tidy_out(doc, "in one table cell and the </form> in another. If the <form> is\n"); 1564 tidy_out(doc, "placed before a table, the </form> cannot be placed inside the\n"); 1565 tidy_out(doc, "table! Note that one form can't be nested inside another!\n\n"); 1566 } 1567 1568 if (doc->badAccess) 1569 { 1570 if ( cfg(doc, TidyAccessibilityCheckLevel) > 0 ) 1571 { 1572 tidy_out(doc, "For further advice on how to make your pages accessible, see\n"); 1573 tidy_out(doc, "%s", ACCESS_URL ); 1574 tidy_out(doc, "and\n" ); 1575 tidy_out(doc, "%s", ATRC_ACCESS_URL ); 1576 tidy_out(doc, ".\n" ); 1577 tidy_out(doc, "You may also want to try \"http://www.cast.org/bobby/\" which is a free Web-based\n"); 1578 tidy_out(doc, "service for checking URLs for accessibility.\n\n"); 1579 } 1580 else 1581 { 1582 if (doc->badAccess & MISSING_SUMMARY) 1583 { 1584 tidy_out(doc, "The table summary attribute should be used to describe\n"); 1585 tidy_out(doc, "the table structure. It is very helpful for people using\n"); 1586 tidy_out(doc, "non-visual browsers. The scope and headers attributes for\n"); 1587 tidy_out(doc, "table cells are useful for specifying which headers apply\n"); 1588 tidy_out(doc, "to each table cell, enabling non-visual browsers to provide\n"); 1589 tidy_out(doc, "a meaningful context for each cell.\n\n"); 1590 } 1591 1592 if (doc->badAccess & MISSING_IMAGE_ALT) 1593 { 1594 tidy_out(doc, "The alt attribute should be used to give a short description\n"); 1595 tidy_out(doc, "of an image; longer descriptions should be given with the\n"); 1596 tidy_out(doc, "longdesc attribute which takes a URL linked to the description.\n"); 1597 tidy_out(doc, "These measures are needed for people using non-graphical browsers.\n\n"); 1598 } 1599 1600 if (doc->badAccess & MISSING_IMAGE_MAP) 1601 { 1602 tidy_out(doc, "Use client-side image maps in preference to server-side image\n"); 1603 tidy_out(doc, "maps as the latter are inaccessible to people using non-\n"); 1604 tidy_out(doc, "graphical browsers. In addition, client-side maps are easier\n"); 1605 tidy_out(doc, "to set up and provide immediate feedback to users.\n\n"); 1606 } 1607 1608 if (doc->badAccess & MISSING_LINK_ALT) 1609 { 1610 tidy_out(doc, "For hypertext links defined using a client-side image map, you\n"); 1611 tidy_out(doc, "need to use the alt attribute to provide a textual description\n"); 1612 tidy_out(doc, "of the link for people using non-graphical browsers.\n\n"); 1613 } 1614 1615 if ((doc->badAccess & USING_FRAMES) && !(doc->badAccess & USING_NOFRAMES)) 1616 { 1617 tidy_out(doc, "Pages designed using frames presents problems for\n"); 1618 tidy_out(doc, "people who are either blind or using a browser that\n"); 1619 tidy_out(doc, "doesn't support frames. A frames-based page should always\n"); 1620 tidy_out(doc, "include an alternative layout inside a NOFRAMES element.\n\n"); 1621 } 1622 1623 tidy_out(doc, "For further advice on how to make your pages accessible\n"); 1624 tidy_out(doc, "see " ); 1625 tidy_out(doc, ACCESS_URL ); 1626 tidy_out(doc, ". You may also want to try\n" ); 1627 tidy_out(doc, "\"http://www.cast.org/bobby/\" which is a free Web-based\n"); 1628 tidy_out(doc, "service for checking URLs for accessibility.\n\n"); 1629 } 1630 } 1631 1632 if (doc->badLayout) 1633 { 1634 if (doc->badLayout & USING_LAYER) 1635 { 1636 tidy_out(doc, "The Cascading Style Sheets (CSS) Positioning mechanism\n"); 1637 tidy_out(doc, "is recommended in preference to the proprietary <LAYER>\n"); 1638 tidy_out(doc, "element due to limited vendor support for LAYER.\n\n"); 1639 } 1640 1641 if (doc->badLayout & USING_SPACER) 1642 { 1643 tidy_out(doc, "You are recommended to use CSS for controlling white\n"); 1644 tidy_out(doc, "space (e.g. for indentation, margins and line spacing).\n"); 1645 tidy_out(doc, "The proprietary <SPACER> element has limited vendor support.\n\n"); 1646 } 1647 1648 if (doc->badLayout & USING_FONT) 1649 { 1650 tidy_out(doc, "You are recommended to use CSS to specify the font and\n"); 1651 tidy_out(doc, "properties such as its size and color. This will reduce\n"); 1652 tidy_out(doc, "the size of HTML files and make them easier to maintain\n"); 1653 tidy_out(doc, "compared with using <FONT> elements.\n\n"); 1654 } 1655 1656 if (doc->badLayout & USING_NOBR) 1657 { 1658 tidy_out(doc, "You are recommended to use CSS to control line wrapping.\n"); 1659 tidy_out(doc, "Use \"white-space: nowrap\" to inhibit wrapping in place\n"); 1660 tidy_out(doc, "of inserting <NOBR>...</NOBR> into the markup.\n\n"); 1661 } 1662 1663 if (doc->badLayout & USING_BODY) 1664 { 1665 tidy_out(doc, "You are recommended to use CSS to specify page and link colors\n"); 1666 } 1667 } 1668 } 1669 1670 void UnknownOption( TidyDocImpl* doc, char c ) 1671 { 1672 message( doc, TidyConfig, 1673 "unrecognized option -%c use -help to list options\n", c ); 1674 } 1675 1676 void UnknownFile( TidyDocImpl* doc, ctmbstr program, ctmbstr file ) 1677 { 1678 message( doc, TidyConfig, 1679 "%s: can't open file \"%s\"\n", program, file ); 1680 } 1681 1682 void NeedsAuthorIntervention( TidyDocImpl* doc ) 1683 { 1684 tidy_out(doc, "This document has errors that must be fixed before\n"); 1685 tidy_out(doc, "using HTML Tidy to generate a tidied up version.\n\n"); 1686 } 1687 1688 void GeneralInfo( TidyDocImpl* doc ) 1689 { 1690 tidy_out(doc, "To learn more about HTML Tidy see http://tidy.sourceforge.net\n"); 1691 tidy_out(doc, "Please send bug reports to html-tidy@w3.org\n"); 1692 tidy_out(doc, "HTML and CSS specifications are available from http://www.w3.org/\n"); 1693 tidy_out(doc, "Lobby your company to join W3C, see http://www.w3.org/Consortium\n"); 1694 } 1695 1696 #if SUPPORT_ACCESSIBILITY_CHECKS 1697 1698 void AccessibilityHelloMessage( TidyDocImpl* doc ) 1699 { 1700 tidy_out( doc, "\n" ); 1701 tidy_out( doc, "Accessibility Checks: Version 0.1\n" ); 1702 tidy_out( doc, "\n" ); 1703 } 1704 1705 #endif /* SUPPORT_ACCESSIBILITY_CHECKS */ 1706 1707 void HelloMessage( TidyDocImpl* doc, ctmbstr date, ctmbstr filename ) 1708 { 1709 tmbchar buf[ 2048 ]; 1710 ctmbstr platform = "", helper = ""; 1711 ctmbstr msgfmt = "\nHTML Tidy for %s (vers %s; built on %s, at %s)\n" 1712 "Parsing \"%s\"\n"; 1713 1714 #ifdef PLATFORM_NAME 1715 platform = PLATFORM_NAME; 1716 helper = " for "; 1717 #endif 1718 1719 if ( tmbstrcmp(filename, "stdin") == 0 ) 1720 { 1721 /* Filename will be ignored at end of varargs */ 1722 msgfmt = "\nHTML Tidy for %s (vers %s; built on %s, at %s)\n" 1723 "Parsing console input (stdin)\n"; 1724 } 1725 1726 tmbsnprintf(buf, sizeof(buf), msgfmt, helper, platform, 1727 date, __DATE__, __TIME__, filename); 1728 tidy_out( doc, buf ); 1729 } 1730 1731 void ReportMarkupVersion( TidyDocImpl* doc ) 1732 { 1733 if (doc->givenDoctype) 1734 { 1735 /* todo: deal with non-ASCII characters in FPI */ 1736 message(doc, TidyInfo, "Doctype given is \"%s\"", doc->givenDoctype); 1737 } 1738 1739 if ( ! cfgBool(doc, TidyXmlTags) ) 1740 { 1741 Bool isXhtml = doc->lexer->isvoyager; 1742 uint apparentVers; 1743 ctmbstr vers; 1744 1745 apparentVers = ApparentVersion( doc ); 1746 1747 vers = HTMLVersionNameFromCode( apparentVers, isXhtml ); 1748 1749 if (!vers) 1750 vers = "HTML Proprietary"; 1751 1752 message( doc, TidyInfo, "Document content looks like %s", vers ); 1753 } 1754 } 1755 1756 void ReportNumWarnings( TidyDocImpl* doc ) 1757 { 1758 if ( doc->warnings > 0 || doc->errors > 0 ) 1759 { 1760 tidy_out( doc, "%d %s, %d %s were found!", 1761 doc->warnings, doc->warnings == 1 ? "warning" : "warnings", 1762 doc->errors, doc->errors == 1 ? "error" : "errors" ); 1763 1764 if ( doc->errors > cfg(doc, TidyShowErrors) || 1765 !cfgBool(doc, TidyShowWarnings) ) 1766 tidy_out( doc, " Not all warnings/errors were shown.\n\n" ); 1767 else 1768 tidy_out( doc, "\n\n" ); 1769 } 1770 else 1771 tidy_out( doc, "No warnings or errors were found.\n\n" ); 1772 } 1773

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.