diff --git a/include/tidy.h b/include/tidy.h index 94e823b..c701890 100644 --- a/include/tidy.h +++ b/include/tidy.h @@ -708,10 +708,16 @@ TIDY_EXPORT ctmbstr TIDY_CALL tidyOptGetName( TidyOption opt ); /** Get datatype of given Option ** @param opt An instance of a TidyOption to query. - ** @result the TidyOptionType of the given option. + ** @result The TidyOptionType of the given option. */ TIDY_EXPORT TidyOptionType TIDY_CALL tidyOptGetType( TidyOption opt ); +/** Indicates that an option takes a list of items. + ** @param opt An instance of a TidyOption to query. + ** @result A bool indicating whether or not the option accepts a list. + */ +TIDY_EXPORT Bool TIDY_CALL tidyOptionIsList( TidyOption opt ); + /** Is Option read-only? Some options (mainly internal use only options) are ** read-only. ** @deprecated This is no longer a valid test for the public API; instead diff --git a/src/config.c b/src/config.c index 1c987f3..084a0c6 100644 --- a/src/config.c +++ b/src/config.c @@ -342,6 +342,11 @@ const TidyOptionImpl* TY_(getOption)( TidyOptionId optId ) return NULL; } +const Bool TY_(getOptionIsList)( TidyOptionId optId ) +{ + const TidyOptionImpl* option = TY_(getOption)( optId ); + return option->parser == ParseList; +} static void FreeOptionValue( TidyDocImpl* doc, const TidyOptionImpl* option, TidyOptionValue* value ) { diff --git a/src/config.h b/src/config.h index 2cf958c..41e1b4f 100644 --- a/src/config.h +++ b/src/config.h @@ -149,6 +149,11 @@ const TidyOptionImpl* TY_(lookupOption)( ctmbstr optnam ); */ const TidyOptionImpl* TY_(getOption)( TidyOptionId optId ); +/** Given an option ID, indicates whether or not the option is a list. + ** @param optId The option ID to check. + ** @returns Returns yes if the option value is a list. + */ +const Bool TY_(getOptionIsList)( TidyOptionId optId ); /** Initiates an iterator to cycle through all of the available options. ** @param doc The Tidy document to get options. diff --git a/src/tidylib.c b/src/tidylib.c index 1a90322..df729db 100644 --- a/src/tidylib.c +++ b/src/tidylib.c @@ -357,6 +357,13 @@ TidyOptionType TIDY_CALL tidyOptGetType( TidyOption topt ) return option->type; return (TidyOptionType) -1; } +Bool TIDY_CALL tidyOptionIsList( TidyOption opt ) +{ + const TidyOptionImpl* option = tidyOptionToImpl( opt ); + if ( option ) + return TY_(getOptionIsList)( option->id ); + return no; +} TidyConfigCategory TIDY_CALL tidyOptGetCategory( TidyOption topt ) { const TidyOptionImpl* option = tidyOptionToImpl( topt );