Implement TidyReportFilter2 using raw strings to support library localization.

This commit is contained in:
Jim Derry 2014-04-27 16:07:20 +08:00
parent 0cf6d99843
commit 5786a5afb5
4 changed files with 27 additions and 3 deletions

12
include/tidy.h Normal file → Executable file
View file

@ -619,10 +619,16 @@ TIDY_EXPORT void TIDY_CALL tidyPutByte( TidyOutputSink* sink, uint byteValue );
typedef Bool (TIDY_CALL *TidyReportFilter)( TidyDoc tdoc, TidyReportLevel lvl,
uint line, uint col, ctmbstr mssg );
typedef Bool (TIDY_CALL *TidyReportFilter2)( TidyDoc tdoc, TidyReportLevel lvl,
uint line, uint col, ctmbstr mssg, va_list args );
/** Give Tidy a filter callback to use */
TIDY_EXPORT Bool TIDY_CALL tidySetReportFilter( TidyDoc tdoc,
TidyReportFilter filtCallback );
TIDY_EXPORT Bool TIDY_CALL tidySetReportFilter2( TidyDoc tdoc,
TidyReportFilter2 filtCallback );
/** Set error sink to named file */
TIDY_EXPORT FILE* TIDY_CALL tidySetErrorFile( TidyDoc tdoc, ctmbstr errfilnam );
/** Set error sink to given buffer */
@ -852,7 +858,7 @@ TIDY_EXPORT uint TIDY_CALL tidyNodeColumn( TidyNode tnod );
/** @defgroup NodeIsElementName Deprecated node interrogation per TagId
**
** @deprecated The functions tidyNodeIs{ElementName} are deprecated and
** @deprecated The functions tidyNodeIs{ElementName} are deprecated and
** should be replaced by tidyNodeGetId.
** @{
*/
@ -954,7 +960,7 @@ TIDY_EXPORT Bool TIDY_CALL tidyAttrIsProp( TidyAttr tattr );
/** @defgroup AttrIsAttributeName Deprecated attribute interrogation per AttrId
**
** @deprecated The functions tidyAttrIs{AttributeName} are deprecated and
** @deprecated The functions tidyAttrIs{AttributeName} are deprecated and
** should be replaced by tidyAttrGetId.
** @{
*/
@ -1019,7 +1025,7 @@ TIDY_EXPORT TidyAttr TIDY_CALL tidyAttrGetById( TidyNode tnod, TidyAttrId attId
/** @defgroup AttrGetAttributeName Deprecated attribute retrieval per AttrId
**
** @deprecated The functions tidyAttrGet{AttributeName} are deprecated and
** @deprecated The functions tidyAttrGet{AttributeName} are deprecated and
** should be replaced by tidyAttrGetById.
** For instance, tidyAttrGetID( TidyNode tnod ) can be replaced by
** tidyAttrGetById( TidyNode tnod, TidyAttr_ID ). This avoids a potential

5
src/localize.c Normal file → Executable file
View file

@ -1034,6 +1034,11 @@ static void messagePos( TidyDocImpl* doc, TidyReportLevel level,
TidyDoc tdoc = tidyImplToDoc( doc );
go = doc->mssgFilt( tdoc, level, line, col, messageBuf );
}
if ( doc->mssgFilt2 )
{
TidyDoc tdoc = tidyImplToDoc( doc );
go = doc->mssgFilt2( tdoc, level, line, col, msg, args );
}
}
if ( go )

1
src/tidy-int.h Normal file → Executable file
View file

@ -48,6 +48,7 @@ struct _TidyDocImpl
StreamOut* docOut;
StreamOut* errout;
TidyReportFilter mssgFilt;
TidyReportFilter2 mssgFilt2;
TidyOptCallback pOptCallback;
/* Parse + Repair Results */

12
src/tidylib.c Normal file → Executable file
View file

@ -649,6 +649,18 @@ Bool TIDY_CALL tidySetReportFilter( TidyDoc tdoc, TidyReportFilter filt )
return no;
}
Bool TIDY_CALL tidySetReportFilter2( TidyDoc tdoc, TidyReportFilter2 filt )
{
TidyDocImpl* impl = tidyDocToImpl( tdoc );
if ( impl )
{
impl->mssgFilt2 = filt;
return yes;
}
return no;
}
#if 0 /* Not yet */
int tidySetContentOutputSink( TidyDoc tdoc, TidyOutputSink* outp )
{