- Add TidyReportFilter3, which removes translation strings completely from the equation. It would be a good idea to deprecate TidyReportFilter2, which is vulnerable to changing strings in Tidy source.
- Documentation reminders for future enum changes. - Documentation updates.
This commit is contained in:
parent
d505869910
commit
bf70824cc2
2649
console/tidy.c
2649
console/tidy.c
File diff suppressed because it is too large
Load diff
|
@ -645,6 +645,9 @@ typedef Bool (TIDY_CALL *TidyReportFilter)( TidyDoc tdoc, TidyReportLevel lvl,
|
|||
typedef Bool (TIDY_CALL *TidyReportFilter2)( TidyDoc tdoc, TidyReportLevel lvl,
|
||||
uint line, uint col, ctmbstr mssg, va_list args );
|
||||
|
||||
typedef Bool (TIDY_CALL *TidyReportFilter3)( TidyDoc tdoc, TidyReportLevel lvl,
|
||||
uint line, uint col, ctmbstr code, va_list args );
|
||||
|
||||
/** Give Tidy a filter callback to use */
|
||||
TIDY_EXPORT Bool TIDY_CALL tidySetReportFilter( TidyDoc tdoc,
|
||||
TidyReportFilter filtCallback );
|
||||
|
@ -652,6 +655,9 @@ TIDY_EXPORT Bool TIDY_CALL tidySetReportFilter( TidyDoc tdoc,
|
|||
TIDY_EXPORT Bool TIDY_CALL tidySetReportFilter2( TidyDoc tdoc,
|
||||
TidyReportFilter2 filtCallback );
|
||||
|
||||
TIDY_EXPORT Bool TIDY_CALL tidySetReportFilter3( TidyDoc tdoc,
|
||||
TidyReportFilter3 filtCallback );
|
||||
|
||||
/** Set error sink to named file */
|
||||
TIDY_EXPORT FILE* TIDY_CALL tidySetErrorFile( TidyDoc tdoc, ctmbstr errfilnam );
|
||||
/** Set error sink to given buffer */
|
||||
|
|
|
@ -118,6 +118,10 @@ struct _TidyAccessImpl
|
|||
|
||||
These accessErrorCodes are used throughout libtidy, and also
|
||||
have associated localized strings to describe them.
|
||||
|
||||
IMPORTANT: to maintain compatability with TidyMessageFilter3, if you add
|
||||
or remove keys from this enum, ALSO add/remove the corresponding key
|
||||
in language.c:tidyErrorFilterKeysStruct[]!
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
|
|
265
src/language.c
265
src/language.c
|
@ -229,6 +229,271 @@ static const tidyLocaleMapItem localeMappings[] = {
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
* Provides the mapping for LibTidy users to map between an opaque key
|
||||
* and an error message value. See `tidyErrorFilterKeys[]`, below.
|
||||
*/
|
||||
typedef struct tidyErrorFilterKeyItem {
|
||||
ctmbstr key;
|
||||
int value;
|
||||
} tidyErrorFilterKeyItem;
|
||||
|
||||
|
||||
/**
|
||||
* LibTidy users may want to use `TidyReportFilter3` to enable their own
|
||||
* localization lookup features. Because Tidy's errors codes are enums the
|
||||
* specific values can change over time. This table will ensure that LibTidy
|
||||
* users always have a static value available for use.
|
||||
*/
|
||||
static const tidyErrorFilterKeyItem tidyErrorFilterKeysStruct[] = {
|
||||
{ "CODES_TIDY_ERROR_FIRST", CODES_TIDY_ERROR_FIRST },
|
||||
{ "MISSING_SEMICOLON", MISSING_SEMICOLON },
|
||||
{ "MISSING_SEMICOLON_NCR", MISSING_SEMICOLON_NCR },
|
||||
{ "UNKNOWN_ENTITY", UNKNOWN_ENTITY },
|
||||
{ "UNESCAPED_AMPERSAND", UNESCAPED_AMPERSAND },
|
||||
{ "APOS_UNDEFINED", APOS_UNDEFINED },
|
||||
{ "MISSING_ENDTAG_FOR", MISSING_ENDTAG_FOR },
|
||||
{ "MISSING_ENDTAG_BEFORE", MISSING_ENDTAG_BEFORE },
|
||||
{ "DISCARDING_UNEXPECTED", DISCARDING_UNEXPECTED },
|
||||
{ "NESTED_EMPHASIS", NESTED_EMPHASIS },
|
||||
{ "NON_MATCHING_ENDTAG", NON_MATCHING_ENDTAG },
|
||||
{ "TAG_NOT_ALLOWED_IN", TAG_NOT_ALLOWED_IN },
|
||||
{ "MISSING_STARTTAG", MISSING_STARTTAG },
|
||||
{ "UNEXPECTED_ENDTAG", UNEXPECTED_ENDTAG },
|
||||
{ "USING_BR_INPLACE_OF", USING_BR_INPLACE_OF },
|
||||
{ "INSERTING_TAG", INSERTING_TAG },
|
||||
{ "SUSPECTED_MISSING_QUOTE", SUSPECTED_MISSING_QUOTE },
|
||||
{ "MISSING_TITLE_ELEMENT", MISSING_TITLE_ELEMENT },
|
||||
{ "DUPLICATE_FRAMESET", DUPLICATE_FRAMESET },
|
||||
{ "CANT_BE_NESTED", CANT_BE_NESTED },
|
||||
{ "OBSOLETE_ELEMENT", OBSOLETE_ELEMENT },
|
||||
{ "PROPRIETARY_ELEMENT", PROPRIETARY_ELEMENT },
|
||||
{ "UNKNOWN_ELEMENT", UNKNOWN_ELEMENT },
|
||||
{ "TRIM_EMPTY_ELEMENT", TRIM_EMPTY_ELEMENT },
|
||||
{ "COERCE_TO_ENDTAG", COERCE_TO_ENDTAG },
|
||||
{ "ILLEGAL_NESTING", ILLEGAL_NESTING },
|
||||
{ "NOFRAMES_CONTENT", NOFRAMES_CONTENT },
|
||||
{ "CONTENT_AFTER_BODY", CONTENT_AFTER_BODY },
|
||||
{ "INCONSISTENT_VERSION", INCONSISTENT_VERSION },
|
||||
{ "MALFORMED_COMMENT", MALFORMED_COMMENT },
|
||||
{ "BAD_COMMENT_CHARS", BAD_COMMENT_CHARS },
|
||||
{ "BAD_XML_COMMENT", BAD_XML_COMMENT },
|
||||
{ "BAD_CDATA_CONTENT", BAD_CDATA_CONTENT },
|
||||
{ "INCONSISTENT_NAMESPACE", INCONSISTENT_NAMESPACE },
|
||||
{ "DOCTYPE_AFTER_TAGS", DOCTYPE_AFTER_TAGS },
|
||||
{ "MALFORMED_DOCTYPE", MALFORMED_DOCTYPE },
|
||||
{ "UNEXPECTED_END_OF_FILE", UNEXPECTED_END_OF_FILE },
|
||||
{ "DTYPE_NOT_UPPER_CASE", DTYPE_NOT_UPPER_CASE },
|
||||
{ "TOO_MANY_ELEMENTS", TOO_MANY_ELEMENTS },
|
||||
{ "UNESCAPED_ELEMENT", UNESCAPED_ELEMENT },
|
||||
{ "NESTED_QUOTATION", NESTED_QUOTATION },
|
||||
{ "ELEMENT_NOT_EMPTY", ELEMENT_NOT_EMPTY },
|
||||
{ "ENCODING_IO_CONFLICT", ENCODING_IO_CONFLICT },
|
||||
{ "MIXED_CONTENT_IN_BLOCK", MIXED_CONTENT_IN_BLOCK },
|
||||
{ "MISSING_DOCTYPE", MISSING_DOCTYPE },
|
||||
{ "SPACE_PRECEDING_XMLDECL", SPACE_PRECEDING_XMLDECL },
|
||||
{ "TOO_MANY_ELEMENTS_IN", TOO_MANY_ELEMENTS_IN },
|
||||
{ "UNEXPECTED_ENDTAG_IN", UNEXPECTED_ENDTAG_IN },
|
||||
{ "REPLACING_ELEMENT", REPLACING_ELEMENT },
|
||||
{ "REPLACING_UNEX_ELEMENT", REPLACING_UNEX_ELEMENT },
|
||||
{ "COERCE_TO_ENDTAG_WARN", COERCE_TO_ENDTAG_WARN },
|
||||
{ "UNKNOWN_ATTRIBUTE", UNKNOWN_ATTRIBUTE },
|
||||
{ "INSERTING_ATTRIBUTE", INSERTING_ATTRIBUTE },
|
||||
{ "INSERTING_AUTO_ATTRIBUTE", INSERTING_AUTO_ATTRIBUTE },
|
||||
{ "MISSING_ATTR_VALUE", MISSING_ATTR_VALUE },
|
||||
{ "BAD_ATTRIBUTE_VALUE", BAD_ATTRIBUTE_VALUE },
|
||||
{ "UNEXPECTED_GT", UNEXPECTED_GT },
|
||||
{ "PROPRIETARY_ATTRIBUTE", PROPRIETARY_ATTRIBUTE },
|
||||
{ "PROPRIETARY_ATTR_VALUE", PROPRIETARY_ATTR_VALUE },
|
||||
{ "REPEATED_ATTRIBUTE", REPEATED_ATTRIBUTE },
|
||||
{ "MISSING_IMAGEMAP", MISSING_IMAGEMAP },
|
||||
{ "XML_ATTRIBUTE_VALUE", XML_ATTRIBUTE_VALUE },
|
||||
{ "UNEXPECTED_QUOTEMARK", UNEXPECTED_QUOTEMARK },
|
||||
{ "MISSING_QUOTEMARK", MISSING_QUOTEMARK },
|
||||
{ "ID_NAME_MISMATCH", ID_NAME_MISMATCH },
|
||||
{ "BACKSLASH_IN_URI", BACKSLASH_IN_URI },
|
||||
{ "FIXED_BACKSLASH", FIXED_BACKSLASH },
|
||||
{ "ILLEGAL_URI_REFERENCE", ILLEGAL_URI_REFERENCE },
|
||||
{ "ESCAPED_ILLEGAL_URI", ESCAPED_ILLEGAL_URI },
|
||||
{ "NEWLINE_IN_URI", NEWLINE_IN_URI },
|
||||
{ "ANCHOR_NOT_UNIQUE", ANCHOR_NOT_UNIQUE },
|
||||
{ "JOINING_ATTRIBUTE", JOINING_ATTRIBUTE },
|
||||
{ "UNEXPECTED_EQUALSIGN", UNEXPECTED_EQUALSIGN },
|
||||
{ "ATTR_VALUE_NOT_LCASE", ATTR_VALUE_NOT_LCASE },
|
||||
{ "XML_ID_SYNTAX", XML_ID_SYNTAX },
|
||||
{ "INVALID_ATTRIBUTE", INVALID_ATTRIBUTE },
|
||||
{ "BAD_ATTRIBUTE_VALUE_REPLACED", BAD_ATTRIBUTE_VALUE_REPLACED },
|
||||
{ "INVALID_XML_ID", INVALID_XML_ID },
|
||||
{ "UNEXPECTED_END_OF_FILE_ATTR", UNEXPECTED_END_OF_FILE_ATTR },
|
||||
{ "MISSING_ATTRIBUTE", MISSING_ATTRIBUTE },
|
||||
{ "WHITE_IN_URI", WHITE_IN_URI },
|
||||
{ "REMOVED_HTML5", REMOVED_HTML5 },
|
||||
{ "BAD_BODY_HTML5", BAD_BODY_HTML5 },
|
||||
{ "BAD_ALIGN_HTML5", BAD_ALIGN_HTML5 },
|
||||
{ "BAD_SUMMARY_HTML5", BAD_SUMMARY_HTML5 },
|
||||
{ "PREVIOUS_LOCATION", PREVIOUS_LOCATION },
|
||||
{ "VENDOR_SPECIFIC_CHARS", VENDOR_SPECIFIC_CHARS },
|
||||
{ "INVALID_SGML_CHARS", INVALID_SGML_CHARS },
|
||||
{ "INVALID_UTF8", INVALID_UTF8 },
|
||||
{ "INVALID_UTF16", INVALID_UTF16 },
|
||||
{ "ENCODING_MISMATCH", ENCODING_MISMATCH },
|
||||
{ "INVALID_URI", INVALID_URI },
|
||||
{ "INVALID_NCR", INVALID_NCR },
|
||||
{ "CODES_TIDY_ERROR_LAST", CODES_TIDY_ERROR_LAST },
|
||||
#if SUPPORT_ACCESSIBILITY_CHECKS
|
||||
{ "FIRST_ACCESS_ERR", FIRST_ACCESS_ERR },
|
||||
{ "IMG_MISSING_ALT", IMG_MISSING_ALT },
|
||||
{ "IMG_ALT_SUSPICIOUS_FILENAME", IMG_ALT_SUSPICIOUS_FILENAME },
|
||||
{ "IMG_ALT_SUSPICIOUS_FILE_SIZE", IMG_ALT_SUSPICIOUS_FILE_SIZE },
|
||||
{ "IMG_ALT_SUSPICIOUS_PLACEHOLDER", IMG_ALT_SUSPICIOUS_PLACEHOLDER },
|
||||
{ "IMG_ALT_SUSPICIOUS_TOO_LONG", IMG_ALT_SUSPICIOUS_TOO_LONG },
|
||||
{ "IMG_MISSING_ALT_BULLET", IMG_MISSING_ALT_BULLET },
|
||||
{ "IMG_MISSING_ALT_H_RULE", IMG_MISSING_ALT_H_RULE },
|
||||
{ "IMG_MISSING_LONGDESC_DLINK", IMG_MISSING_LONGDESC_DLINK },
|
||||
{ "IMG_MISSING_DLINK", IMG_MISSING_DLINK },
|
||||
{ "IMG_MISSING_LONGDESC", IMG_MISSING_LONGDESC },
|
||||
{ "LONGDESC_NOT_REQUIRED", LONGDESC_NOT_REQUIRED },
|
||||
{ "IMG_BUTTON_MISSING_ALT", IMG_BUTTON_MISSING_ALT },
|
||||
{ "APPLET_MISSING_ALT", APPLET_MISSING_ALT },
|
||||
{ "OBJECT_MISSING_ALT", OBJECT_MISSING_ALT },
|
||||
{ "AUDIO_MISSING_TEXT_WAV", AUDIO_MISSING_TEXT_WAV },
|
||||
{ "AUDIO_MISSING_TEXT_AU", AUDIO_MISSING_TEXT_AU },
|
||||
{ "AUDIO_MISSING_TEXT_AIFF", AUDIO_MISSING_TEXT_AIFF },
|
||||
{ "AUDIO_MISSING_TEXT_SND", AUDIO_MISSING_TEXT_SND },
|
||||
{ "AUDIO_MISSING_TEXT_RA", AUDIO_MISSING_TEXT_RA },
|
||||
{ "AUDIO_MISSING_TEXT_RM", AUDIO_MISSING_TEXT_RM },
|
||||
{ "FRAME_MISSING_LONGDESC", FRAME_MISSING_LONGDESC },
|
||||
{ "AREA_MISSING_ALT", AREA_MISSING_ALT },
|
||||
{ "SCRIPT_MISSING_NOSCRIPT", SCRIPT_MISSING_NOSCRIPT },
|
||||
{ "ASCII_REQUIRES_DESCRIPTION", ASCII_REQUIRES_DESCRIPTION },
|
||||
{ "IMG_MAP_SERVER_REQUIRES_TEXT_LINKS", IMG_MAP_SERVER_REQUIRES_TEXT_LINKS },
|
||||
{ "MULTIMEDIA_REQUIRES_TEXT", MULTIMEDIA_REQUIRES_TEXT },
|
||||
{ "IMG_MAP_CLIENT_MISSING_TEXT_LINKS", IMG_MAP_CLIENT_MISSING_TEXT_LINKS },
|
||||
{ "INFORMATION_NOT_CONVEYED_IMAGE", INFORMATION_NOT_CONVEYED_IMAGE },
|
||||
{ "INFORMATION_NOT_CONVEYED_APPLET", INFORMATION_NOT_CONVEYED_APPLET },
|
||||
{ "INFORMATION_NOT_CONVEYED_OBJECT", INFORMATION_NOT_CONVEYED_OBJECT },
|
||||
{ "INFORMATION_NOT_CONVEYED_SCRIPT", INFORMATION_NOT_CONVEYED_SCRIPT },
|
||||
{ "INFORMATION_NOT_CONVEYED_INPUT", INFORMATION_NOT_CONVEYED_INPUT },
|
||||
{ "COLOR_CONTRAST_TEXT", COLOR_CONTRAST_TEXT },
|
||||
{ "COLOR_CONTRAST_LINK", COLOR_CONTRAST_LINK },
|
||||
{ "COLOR_CONTRAST_ACTIVE_LINK", COLOR_CONTRAST_ACTIVE_LINK },
|
||||
{ "COLOR_CONTRAST_VISITED_LINK", COLOR_CONTRAST_VISITED_LINK },
|
||||
{ "DOCTYPE_MISSING", DOCTYPE_MISSING },
|
||||
{ "STYLE_SHEET_CONTROL_PRESENTATION", STYLE_SHEET_CONTROL_PRESENTATION },
|
||||
{ "HEADERS_IMPROPERLY_NESTED", HEADERS_IMPROPERLY_NESTED },
|
||||
{ "POTENTIAL_HEADER_BOLD", POTENTIAL_HEADER_BOLD },
|
||||
{ "POTENTIAL_HEADER_ITALICS", POTENTIAL_HEADER_ITALICS },
|
||||
{ "POTENTIAL_HEADER_UNDERLINE", POTENTIAL_HEADER_UNDERLINE },
|
||||
{ "HEADER_USED_FORMAT_TEXT", HEADER_USED_FORMAT_TEXT },
|
||||
{ "LIST_USAGE_INVALID_UL", LIST_USAGE_INVALID_UL },
|
||||
{ "LIST_USAGE_INVALID_OL", LIST_USAGE_INVALID_OL },
|
||||
{ "LIST_USAGE_INVALID_LI", LIST_USAGE_INVALID_LI },
|
||||
{ "INDICATE_CHANGES_IN_LANGUAGE", INDICATE_CHANGES_IN_LANGUAGE },
|
||||
{ "LANGUAGE_NOT_IDENTIFIED", LANGUAGE_NOT_IDENTIFIED },
|
||||
{ "LANGUAGE_INVALID", LANGUAGE_INVALID },
|
||||
{ "DATA_TABLE_MISSING_HEADERS", DATA_TABLE_MISSING_HEADERS },
|
||||
{ "DATA_TABLE_MISSING_HEADERS_COLUMN", DATA_TABLE_MISSING_HEADERS_COLUMN },
|
||||
{ "DATA_TABLE_MISSING_HEADERS_ROW", DATA_TABLE_MISSING_HEADERS_ROW },
|
||||
{ "DATA_TABLE_REQUIRE_MARKUP_COLUMN_HEADERS", DATA_TABLE_REQUIRE_MARKUP_COLUMN_HEADERS },
|
||||
{ "DATA_TABLE_REQUIRE_MARKUP_ROW_HEADERS", DATA_TABLE_REQUIRE_MARKUP_ROW_HEADERS },
|
||||
{ "LAYOUT_TABLES_LINEARIZE_PROPERLY", LAYOUT_TABLES_LINEARIZE_PROPERLY },
|
||||
{ "LAYOUT_TABLE_INVALID_MARKUP", LAYOUT_TABLE_INVALID_MARKUP },
|
||||
{ "TABLE_MISSING_SUMMARY", TABLE_MISSING_SUMMARY },
|
||||
{ "TABLE_SUMMARY_INVALID_NULL", TABLE_SUMMARY_INVALID_NULL },
|
||||
{ "TABLE_SUMMARY_INVALID_SPACES", TABLE_SUMMARY_INVALID_SPACES },
|
||||
{ "TABLE_SUMMARY_INVALID_PLACEHOLDER", TABLE_SUMMARY_INVALID_PLACEHOLDER },
|
||||
{ "TABLE_MISSING_CAPTION", TABLE_MISSING_CAPTION },
|
||||
{ "TABLE_MAY_REQUIRE_HEADER_ABBR", TABLE_MAY_REQUIRE_HEADER_ABBR },
|
||||
{ "TABLE_MAY_REQUIRE_HEADER_ABBR_NULL", TABLE_MAY_REQUIRE_HEADER_ABBR_NULL },
|
||||
{ "TABLE_MAY_REQUIRE_HEADER_ABBR_SPACES", TABLE_MAY_REQUIRE_HEADER_ABBR_SPACES },
|
||||
{ "STYLESHEETS_REQUIRE_TESTING_LINK", STYLESHEETS_REQUIRE_TESTING_LINK },
|
||||
{ "STYLESHEETS_REQUIRE_TESTING_STYLE_ELEMENT", STYLESHEETS_REQUIRE_TESTING_STYLE_ELEMENT },
|
||||
{ "STYLESHEETS_REQUIRE_TESTING_STYLE_ATTR", STYLESHEETS_REQUIRE_TESTING_STYLE_ATTR },
|
||||
{ "FRAME_SRC_INVALID", FRAME_SRC_INVALID },
|
||||
{ "TEXT_EQUIVALENTS_REQUIRE_UPDATING_APPLET", TEXT_EQUIVALENTS_REQUIRE_UPDATING_APPLET },
|
||||
{ "TEXT_EQUIVALENTS_REQUIRE_UPDATING_SCRIPT", TEXT_EQUIVALENTS_REQUIRE_UPDATING_SCRIPT },
|
||||
{ "TEXT_EQUIVALENTS_REQUIRE_UPDATING_OBJECT", TEXT_EQUIVALENTS_REQUIRE_UPDATING_OBJECT },
|
||||
{ "PROGRAMMATIC_OBJECTS_REQUIRE_TESTING_SCRIPT", PROGRAMMATIC_OBJECTS_REQUIRE_TESTING_SCRIPT },
|
||||
{ "PROGRAMMATIC_OBJECTS_REQUIRE_TESTING_OBJECT", PROGRAMMATIC_OBJECTS_REQUIRE_TESTING_OBJECT },
|
||||
{ "PROGRAMMATIC_OBJECTS_REQUIRE_TESTING_EMBED", PROGRAMMATIC_OBJECTS_REQUIRE_TESTING_EMBED },
|
||||
{ "PROGRAMMATIC_OBJECTS_REQUIRE_TESTING_APPLET", PROGRAMMATIC_OBJECTS_REQUIRE_TESTING_APPLET },
|
||||
{ "FRAME_MISSING_NOFRAMES", FRAME_MISSING_NOFRAMES },
|
||||
{ "NOFRAMES_INVALID_NO_VALUE", NOFRAMES_INVALID_NO_VALUE },
|
||||
{ "NOFRAMES_INVALID_CONTENT", NOFRAMES_INVALID_CONTENT },
|
||||
{ "NOFRAMES_INVALID_LINK", NOFRAMES_INVALID_LINK },
|
||||
{ "REMOVE_FLICKER_SCRIPT", REMOVE_FLICKER_SCRIPT },
|
||||
{ "REMOVE_FLICKER_OBJECT", REMOVE_FLICKER_OBJECT },
|
||||
{ "REMOVE_FLICKER_EMBED", REMOVE_FLICKER_EMBED },
|
||||
{ "REMOVE_FLICKER_APPLET", REMOVE_FLICKER_APPLET },
|
||||
{ "REMOVE_FLICKER_ANIMATED_GIF", REMOVE_FLICKER_ANIMATED_GIF },
|
||||
{ "REMOVE_BLINK_MARQUEE", REMOVE_BLINK_MARQUEE },
|
||||
{ "REMOVE_AUTO_REFRESH", REMOVE_AUTO_REFRESH },
|
||||
{ "REMOVE_AUTO_REDIRECT", REMOVE_AUTO_REDIRECT },
|
||||
{ "ENSURE_PROGRAMMATIC_OBJECTS_ACCESSIBLE_SCRIPT", ENSURE_PROGRAMMATIC_OBJECTS_ACCESSIBLE_SCRIPT },
|
||||
{ "ENSURE_PROGRAMMATIC_OBJECTS_ACCESSIBLE_OBJECT", ENSURE_PROGRAMMATIC_OBJECTS_ACCESSIBLE_OBJECT },
|
||||
{ "ENSURE_PROGRAMMATIC_OBJECTS_ACCESSIBLE_APPLET", ENSURE_PROGRAMMATIC_OBJECTS_ACCESSIBLE_APPLET },
|
||||
{ "ENSURE_PROGRAMMATIC_OBJECTS_ACCESSIBLE_EMBED", ENSURE_PROGRAMMATIC_OBJECTS_ACCESSIBLE_EMBED },
|
||||
{ "IMAGE_MAP_SERVER_SIDE_REQUIRES_CONVERSION", IMAGE_MAP_SERVER_SIDE_REQUIRES_CONVERSION },
|
||||
{ "SCRIPT_NOT_KEYBOARD_ACCESSIBLE_ON_MOUSE_DOWN", SCRIPT_NOT_KEYBOARD_ACCESSIBLE_ON_MOUSE_DOWN },
|
||||
{ "SCRIPT_NOT_KEYBOARD_ACCESSIBLE_ON_MOUSE_UP", SCRIPT_NOT_KEYBOARD_ACCESSIBLE_ON_MOUSE_UP },
|
||||
{ "SCRIPT_NOT_KEYBOARD_ACCESSIBLE_ON_CLICK", SCRIPT_NOT_KEYBOARD_ACCESSIBLE_ON_CLICK },
|
||||
{ "SCRIPT_NOT_KEYBOARD_ACCESSIBLE_ON_MOUSE_OVER", SCRIPT_NOT_KEYBOARD_ACCESSIBLE_ON_MOUSE_OVER },
|
||||
{ "SCRIPT_NOT_KEYBOARD_ACCESSIBLE_ON_MOUSE_OUT", SCRIPT_NOT_KEYBOARD_ACCESSIBLE_ON_MOUSE_OUT },
|
||||
{ "SCRIPT_NOT_KEYBOARD_ACCESSIBLE_ON_MOUSE_MOVE", SCRIPT_NOT_KEYBOARD_ACCESSIBLE_ON_MOUSE_MOVE },
|
||||
{ "NEW_WINDOWS_REQUIRE_WARNING_NEW", NEW_WINDOWS_REQUIRE_WARNING_NEW },
|
||||
{ "NEW_WINDOWS_REQUIRE_WARNING_BLANK", NEW_WINDOWS_REQUIRE_WARNING_BLANK },
|
||||
{ "LABEL_NEEDS_REPOSITIONING_BEFORE_INPUT", LABEL_NEEDS_REPOSITIONING_BEFORE_INPUT },
|
||||
{ "LABEL_NEEDS_REPOSITIONING_AFTER_INPUT", LABEL_NEEDS_REPOSITIONING_AFTER_INPUT },
|
||||
{ "FORM_CONTROL_REQUIRES_DEFAULT_TEXT", FORM_CONTROL_REQUIRES_DEFAULT_TEXT },
|
||||
{ "FORM_CONTROL_DEFAULT_TEXT_INVALID_NULL", FORM_CONTROL_DEFAULT_TEXT_INVALID_NULL },
|
||||
{ "FORM_CONTROL_DEFAULT_TEXT_INVALID_SPACES", FORM_CONTROL_DEFAULT_TEXT_INVALID_SPACES },
|
||||
{ "REPLACE_DEPRECATED_HTML_APPLET", REPLACE_DEPRECATED_HTML_APPLET },
|
||||
{ "REPLACE_DEPRECATED_HTML_BASEFONT", REPLACE_DEPRECATED_HTML_BASEFONT },
|
||||
{ "REPLACE_DEPRECATED_HTML_CENTER", REPLACE_DEPRECATED_HTML_CENTER },
|
||||
{ "REPLACE_DEPRECATED_HTML_DIR", REPLACE_DEPRECATED_HTML_DIR },
|
||||
{ "REPLACE_DEPRECATED_HTML_FONT", REPLACE_DEPRECATED_HTML_FONT },
|
||||
{ "REPLACE_DEPRECATED_HTML_ISINDEX", REPLACE_DEPRECATED_HTML_ISINDEX },
|
||||
{ "REPLACE_DEPRECATED_HTML_MENU", REPLACE_DEPRECATED_HTML_MENU },
|
||||
{ "REPLACE_DEPRECATED_HTML_S", REPLACE_DEPRECATED_HTML_S },
|
||||
{ "REPLACE_DEPRECATED_HTML_STRIKE", REPLACE_DEPRECATED_HTML_STRIKE },
|
||||
{ "REPLACE_DEPRECATED_HTML_U", REPLACE_DEPRECATED_HTML_U },
|
||||
{ "FRAME_MISSING_TITLE", FRAME_MISSING_TITLE },
|
||||
{ "FRAME_TITLE_INVALID_NULL", FRAME_TITLE_INVALID_NULL },
|
||||
{ "FRAME_TITLE_INVALID_SPACES", FRAME_TITLE_INVALID_SPACES },
|
||||
{ "ASSOCIATE_LABELS_EXPLICITLY", ASSOCIATE_LABELS_EXPLICITLY },
|
||||
{ "ASSOCIATE_LABELS_EXPLICITLY_FOR", ASSOCIATE_LABELS_EXPLICITLY_FOR },
|
||||
{ "ASSOCIATE_LABELS_EXPLICITLY_ID", ASSOCIATE_LABELS_EXPLICITLY_ID },
|
||||
{ "LINK_TEXT_NOT_MEANINGFUL", LINK_TEXT_NOT_MEANINGFUL },
|
||||
{ "LINK_TEXT_MISSING", LINK_TEXT_MISSING },
|
||||
{ "LINK_TEXT_TOO_LONG", LINK_TEXT_TOO_LONG },
|
||||
{ "LINK_TEXT_NOT_MEANINGFUL_CLICK_HERE", LINK_TEXT_NOT_MEANINGFUL_CLICK_HERE },
|
||||
{ "LINK_TEXT_NOT_MEANINGFUL_MORE", LINK_TEXT_NOT_MEANINGFUL_MORE },
|
||||
{ "LINK_TEXT_NOT_MEANINGFUL_FOLLOW_THIS", LINK_TEXT_NOT_MEANINGFUL_FOLLOW_THIS },
|
||||
{ "METADATA_MISSING", METADATA_MISSING },
|
||||
{ "METADATA_MISSING_LINK", METADATA_MISSING_LINK },
|
||||
{ "METADATA_MISSING_REDIRECT_AUTOREFRESH", METADATA_MISSING_REDIRECT_AUTOREFRESH },
|
||||
{ "SKIPOVER_ASCII_ART", SKIPOVER_ASCII_ART },
|
||||
{ "LAST_ACCESS_ERR", LAST_ACCESS_ERR },
|
||||
#endif
|
||||
{ NULL, 0 },
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Given an error code, return the string associated with it.
|
||||
*/
|
||||
ctmbstr tidyErrorCodeAsString(uint code)
|
||||
{
|
||||
uint i = 0;
|
||||
while (tidyErrorFilterKeysStruct[i].key) {
|
||||
if ( tidyErrorFilterKeysStruct[i].value == code )
|
||||
return tidyErrorFilterKeysStruct[i].key;
|
||||
i++;
|
||||
}
|
||||
return "UNDEFINED";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The real string lookup function.
|
||||
*/
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include "tidyplatform.h"
|
||||
|
||||
|
||||
|
||||
/** @name Exposed Data Structures */
|
||||
/** @{ */
|
||||
|
||||
|
@ -56,7 +55,6 @@ typedef struct languageDefinition {
|
|||
} languageDefinition;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The function getNextWindowsLanguage() returns pointers to this type;
|
||||
* it gives LibTidy implementors the ability to determine how Windows
|
||||
|
@ -75,11 +73,11 @@ typedef struct tidyLocaleMapItem {
|
|||
* comprehensive list of enums for which we provides strings
|
||||
* is as follows:
|
||||
* - `tidyMessageTypes` in this file, start == 4096.
|
||||
* - `accessErrorCodes` from `access.h`, start == 1000.
|
||||
* - `tidyErrorCodes` from `message.h`, start == 200.
|
||||
* - `accessErrorCodes` from `access.h`, start == CODES_TIDY_ERROR_LAST+1.
|
||||
* - `tidyMessagesMisc` from `message.h`, start == 2048.
|
||||
* - `TidyOptionId` from `tidyEnum.h`, start == 0 (important!).
|
||||
* - `TidyReportLevelKeys` from `tidyEnum.h`, start == 500.
|
||||
* - `TidyReportLevelKeys` from `tidyEnum.h`, start == 600.
|
||||
* - ...
|
||||
* You should never count on the value of a label being
|
||||
* constant. Accordingly feel free to arrange new enum
|
||||
|
@ -188,6 +186,18 @@ typedef enum
|
|||
} tidyMessageTypes;
|
||||
|
||||
|
||||
/**
|
||||
* LibTidy users may want to use `TidyReportFilter3` to enable their own
|
||||
* localization lookup features. Because Tidy's errors codes are enums the
|
||||
* specific values can change over time. This function returns a string
|
||||
* representing the enum value name that can be used as a lookup key
|
||||
* independent of changing string values (TidyReportFiler2 is vulnerable
|
||||
* to changing strings). `TidyReportFilter3` will return this general
|
||||
* string as the error message indicator.
|
||||
*/
|
||||
ctmbstr tidyErrorCodeAsString(uint code);
|
||||
|
||||
|
||||
/** @} */
|
||||
/** @name Localization Related Functions */
|
||||
/** @{ */
|
||||
|
|
|
@ -247,6 +247,14 @@ static void messagePos( TidyDocImpl* doc, TidyReportLevel level, uint code,
|
|||
TidyDoc tdoc = tidyImplToDoc( doc );
|
||||
go = go | doc->mssgFilt2( tdoc, level, line, col, tidyDefaultString(code), args_copy );
|
||||
}
|
||||
if ( doc->mssgFilt3 )
|
||||
{
|
||||
/* mssgFilt3 is intended to allow LibTidy users to localize
|
||||
messages via their own means by providing a key string and
|
||||
the parameters to fill it. */
|
||||
TidyDoc tdoc = tidyImplToDoc( doc );
|
||||
go = go | doc->mssgFilt3( tdoc, level, line, col, tidyErrorCodeAsString(code), args_copy );
|
||||
}
|
||||
}
|
||||
|
||||
if ( go )
|
||||
|
|
|
@ -63,6 +63,10 @@ void TY_(ReportFatal)(TidyDocImpl* doc, Node* element, Node* node, uint code);
|
|||
/**
|
||||
* These tidyErrorCodes are used throughout libtidy, and also
|
||||
* have associated localized strings to describe them.
|
||||
*
|
||||
* IMPORTANT: to maintain compatability with TidyMessageFilter3, if you add
|
||||
* or remove keys from this enum, ALSO add/remove the corresponding key
|
||||
* in language.c:tidyErrorFilterKeysStruct[]!
|
||||
*/
|
||||
typedef enum {
|
||||
/* This MUST be present and first. */
|
||||
|
|
|
@ -58,6 +58,7 @@ struct _TidyDocImpl
|
|||
StreamOut* errout;
|
||||
TidyReportFilter mssgFilt;
|
||||
TidyReportFilter2 mssgFilt2;
|
||||
TidyReportFilter3 mssgFilt3;
|
||||
TidyOptCallback pOptCallback;
|
||||
TidyPPProgress progressCallback;
|
||||
|
||||
|
|
|
@ -672,6 +672,22 @@ Bool TIDY_CALL tidySetReportFilter2( TidyDoc tdoc, TidyReportFilter2 filt
|
|||
return no;
|
||||
}
|
||||
|
||||
/* TidyReportFilter3 functions similar to TidyReportFilter, but provides the
|
||||
* string version of the internal enum name so that LibTidy users can use
|
||||
** the string as a lookup key for providing their own error localizations.
|
||||
** See the string definitions in language.h
|
||||
*/
|
||||
Bool TIDY_CALL tidySetReportFilter3( TidyDoc tdoc, TidyReportFilter3 filt )
|
||||
{
|
||||
TidyDocImpl* impl = tidyDocToImpl( tdoc );
|
||||
if ( impl )
|
||||
{
|
||||
impl->mssgFilt3 = filt;
|
||||
return yes;
|
||||
}
|
||||
return no;
|
||||
}
|
||||
|
||||
#if 0 /* Not yet */
|
||||
int tidySetContentOutputSink( TidyDoc tdoc, TidyOutputSink* outp )
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue