Skip to content

- Addresses #320 #324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/localize.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ static struct _msgfmt

/* attribute name */
{ INSERTING_ATTRIBUTE, "%s inserting \"%s\" attribute" }, /* Warning in CheckLINK, Error otherwise */
{ INSERTING_AUTO_ATTRIBUTE, "%s inserting \"%s\" attribute using value \"%s\"" }, /* Warning */
{ MISSING_ATTR_VALUE, "%s attribute \"%s\" lacks value" }, /* Warning in CheckUrl, Error otherwise */
{ UNKNOWN_ATTRIBUTE, "%s unknown attribute \"%s\"" }, /* Error */
{ PROPRIETARY_ATTRIBUTE, "%s proprietary attribute \"%s\"" }, /* Error */
Expand Down Expand Up @@ -400,9 +401,11 @@ static const TidyOptionDoc option_docs[] =
},
{TidyAltText,
"This option specifies the default <code>alt=</code> text Tidy uses for "
"<code>&lt;img&gt;</code> attributes. "
"<code>&lt;img&gt;</code> attributes when the <code>alt=</code> attribute "
"is missing. "
"<br/>"
"Use with care, as this feature suppresses further accessibility warnings. "
"Use with care, as it is your responsibility to make your documents accessible "
"to people who cannot see the images. "
},
{TidyXmlPIs,
"This option specifies if Tidy should change the parsing of processing "
Expand Down Expand Up @@ -1549,6 +1552,7 @@ void TY_(ReportAttrError)(TidyDocImpl* doc, Node *node, AttVal *av, uint code)
case BAD_ATTRIBUTE_VALUE:
case BAD_ATTRIBUTE_VALUE_REPLACED:
case INVALID_ATTRIBUTE:
case INSERTING_AUTO_ATTRIBUTE:
messageNode(doc, TidyWarning, node, fmt, tagdesc, name, value);
break;

Expand Down
39 changes: 20 additions & 19 deletions src/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,25 +120,26 @@ void TY_(ReportFatal)(TidyDocImpl* doc, Node* element, Node* node, uint code);

#define UNKNOWN_ATTRIBUTE 48
#define INSERTING_ATTRIBUTE 49
#define MISSING_ATTR_VALUE 50
#define BAD_ATTRIBUTE_VALUE 51
#define UNEXPECTED_GT 52
#define PROPRIETARY_ATTRIBUTE 53
#define PROPRIETARY_ATTR_VALUE 54
#define REPEATED_ATTRIBUTE 55
#define MISSING_IMAGEMAP 56
#define XML_ATTRIBUTE_VALUE 57
#define UNEXPECTED_QUOTEMARK 58
#define MISSING_QUOTEMARK 59
#define ID_NAME_MISMATCH 60

#define BACKSLASH_IN_URI 61
#define FIXED_BACKSLASH 62
#define ILLEGAL_URI_REFERENCE 63
#define ESCAPED_ILLEGAL_URI 64

#define NEWLINE_IN_URI 65
#define ANCHOR_NOT_UNIQUE 66
#define INSERTING_AUTO_ATTRIBUTE 50
#define MISSING_ATTR_VALUE 51
#define BAD_ATTRIBUTE_VALUE 52
#define UNEXPECTED_GT 53
#define PROPRIETARY_ATTRIBUTE 54
#define PROPRIETARY_ATTR_VALUE 55
#define REPEATED_ATTRIBUTE 56
#define MISSING_IMAGEMAP 57
#define XML_ATTRIBUTE_VALUE 58
#define UNEXPECTED_QUOTEMARK 59
#define MISSING_QUOTEMARK 60
#define ID_NAME_MISMATCH 61

#define BACKSLASH_IN_URI 62
#define FIXED_BACKSLASH 63
#define ILLEGAL_URI_REFERENCE 64
#define ESCAPED_ILLEGAL_URI 65

#define NEWLINE_IN_URI 66
#define ANCHOR_NOT_UNIQUE 67

#define JOINING_ATTRIBUTE 68
#define UNEXPECTED_EQUALSIGN 69
Expand Down
9 changes: 6 additions & 3 deletions src/tags.c
Original file line number Diff line number Diff line change
Expand Up @@ -852,14 +852,17 @@ void CheckIMG( TidyDocImpl* doc, Node *node )

if ( !HasAlt )
{
if ( cfg(doc, TidyAccessibilityCheckLevel) == 0 )
ctmbstr alttext = cfgStr(doc, TidyAltText);
if ( ( cfg(doc, TidyAccessibilityCheckLevel) == 0 ) && ( !alttext ) )
{
doc->badAccess |= BA_MISSING_IMAGE_ALT;
TY_(ReportMissingAttr)( doc, node, "alt" );
}

if ( cfgStr(doc, TidyAltText) )
TY_(AddAttribute)( doc, node, "alt", cfgStr(doc, TidyAltText) );
if ( alttext ) {
AttVal *attval = TY_(AddAttribute)( doc, node, "alt", alttext );
TY_(ReportAttrError)( doc, node, attval, INSERTING_AUTO_ATTRIBUTE);
}
}

if ( !HasSrc && !HasDataFld )
Expand Down