void CheckIMG( TidyDocImpl* doc, Node *node ) { Bool HasAlt = TY_(AttrGetById)(node, TidyAttr_ALT) != NULL; Bool HasSrc = TY_(AttrGetById)(node, TidyAttr_SRC) != NULL; Bool HasUseMap = TY_(AttrGetById)(node, TidyAttr_USEMAP) != NULL; Bool HasIsMap = TY_(AttrGetById)(node, TidyAttr_ISMAP) != NULL; Bool HasDataFld = TY_(AttrGetById)(node, TidyAttr_DATAFLD) != NULL; TY_(CheckAttributes)(doc, node); if ( !HasAlt ) { if ( cfg(doc, TidyAccessibilityCheckLevel) <= 0 ) { doc->badAccess |= BA_MISSING_IMAGE_ALT; TY_(ReportMissingAttr)( doc, node, "alt" ); } if ( cfgStr(doc, TidyAltText) ) TY_(AddAttribute)( doc, node, "alt", cfgStr(doc, TidyAltText) ); } if ( !HasSrc && !HasDataFld ) TY_(ReportMissingAttr)( doc, node, "src" ); if ( cfg(doc, TidyAccessibilityCheckLevel) == 0 ) { if ( HasIsMap && !HasUseMap ) TY_(ReportAttrError)( doc, node, NULL, MISSING_IMAGEMAP); } }
/* Generates the string indicating the source document position for which ** Tidy has generated a message. */ static char* ReportPosition(TidyDocImpl* doc, int line, int col, char* buf, size_t count) { *buf = 0; /* Change formatting to be parsable by GNU Emacs */ if ( cfgBool(doc, TidyEmacs) && cfgStr(doc, TidyEmacsFile) ) TY_(tmbsnprintf)(buf, count, "%s:%d:%d: ", cfgStr(doc, TidyEmacsFile), line, col); else /* traditional format */ TY_(tmbsnprintf)(buf, count, tidyLocalizedString(LINE_COLUMN_STRING), line, col); return buf + TY_(tmbstrlen)( buf ); }
void CheckIMG( TidyDocImpl* doc, Node *node ) { Bool HasAlt = no; Bool HasSrc = no; Bool HasUseMap = no; Bool HasIsMap = no; Bool HasDataFld = no; AttVal *attval; for ( attval = node->attributes; attval != null; attval = attval->next ) { const Attribute* dict = CheckAttribute( doc, node, attval ); if ( dict ) { TidyAttrId id = dict->id; if ( id == TidyAttr_ALT ) HasAlt = yes; else if ( id == TidyAttr_SRC ) HasSrc = yes; else if ( id == TidyAttr_USEMAP ) HasUseMap = yes; else if ( id == TidyAttr_ISMAP ) HasIsMap = yes; else if ( id == TidyAttr_DATAFLD ) HasDataFld = yes; else if ( id == TidyAttr_WIDTH || id == TidyAttr_HEIGHT ) ConstrainVersion( doc, ~VERS_HTML20 ); } } if ( !HasAlt ) { if ( cfg(doc, TidyAccessibilityCheckLevel) == 0 ) { doc->badAccess |= MISSING_IMAGE_ALT; ReportMissingAttr( doc, node, "alt" ); } if ( cfgStr(doc, TidyAltText) ) AddAttribute( doc, node, "alt", cfgStr(doc, TidyAltText) ); } if ( !HasSrc && !HasDataFld ) ReportMissingAttr( doc, node, "src" ); if ( cfg(doc, TidyAccessibilityCheckLevel) == 0 ) { if ( HasIsMap && !HasUseMap ) ReportMissingAttr( doc, node, "ismap" ); } }
static void ReparseTagType( TidyDocImpl* doc, TidyOptionId optId ) { ctmbstr tagdecl = cfgStr( doc, optId ); tmbstr dupdecl = tmbstrdup( tagdecl ); ParseConfigValue( doc, optId, dupdecl ); MemFree( dupdecl ); }
ctmbstr TIDY_CALL tidyOptGetValue( TidyDoc tdoc, TidyOptionId optId ) { TidyDocImpl* impl = tidyDocToImpl( tdoc ); ctmbstr optval = NULL; if ( impl ) optval = cfgStr( impl, optId ); return optval; }
/* Coordinates Config update and Tags data */ static void DeclareUserTag( TidyDocImpl* doc, TidyOptionId optId, UserTagType tagType, ctmbstr name ) { ctmbstr prvval = cfgStr( doc, optId ); tmbstr catval = NULL; ctmbstr theval = name; if ( prvval ) { uint len = tmbstrlen(name) + tmbstrlen(prvval) + 3; catval = tmbstrndup( prvval, len ); tmbstrcat( catval, ", " ); tmbstrcat( catval, name ); theval = catval; } DefineTag( doc, tagType, name ); SetOptionValue( doc, optId, theval ); if ( catval ) MemFree( catval ); }