HTML Tidy  5.9.15
The HTACG Tidy HTML Project
Configuration Options

Detailed Description

This module organizes all of Tidy's configuration options, including picklist management, option setting and retrieval, option file utilities, and so on.

Data Structures

struct  TidyOptionImpl
 This structure defines the internal representation of a Tidy option. More...
 
struct  PickListItem
 Structs of this type contain information needed in order to present picklists, relate picklist entries to public enum values, and parse strings that are accepted in order to assign the value. More...
 
struct  TidyConfigImpl
 This type is used to define a structure for keeping track of the values for each option. More...
 
struct  TidyOptionDoc
 Used to build a table of documentation cross-references. More...
 
union  TidyOptionValue
 Stored option values can be one of two internal types. More...
 

Macros

#define cfg(doc, id)   ((doc)->config.value[ (id) ].v)
 Access the raw, non-string uint value of the given option ID. More...
 
#define cfgAutoBool(doc, id)   ((TidyTriState) cfg(doc, id))
 Access the TidyTriState value of the given option ID. More...
 
#define cfgBool(doc, id)   ((Bool) cfg(doc, id))
 Access the Bool value of the given option ID. More...
 
#define cfgStr(doc, id)   ((ctmbstr) (doc)->config.value[ (id) ].p)
 Access the string value of the given option ID. More...
 
#define TIDY_PL_SIZE   16
 Determines the maximum number of items in an option's picklist. More...
 

Typedefs

typedef Bool() ParseProperty(TidyDocImpl *doc, const TidyOptionImpl *opt)
 This typedef describes a function that is used for parsing the input given for a particular Tidy option. More...
 
typedef const PickListItem PickListItems[TIDY_PL_SIZE]
 An array of PickListItems, fixed in size for in-code declarations. More...
 

Functions

TY_PRIVATE Bool TY_❪AdjustCharEncoding❫ (TidyDocImpl *doc, int encoding)
 Ensure that char encodings are self consistent. More...
 
TY_PRIVATE void TY_❪AdjustConfig❫ (TidyDocImpl *doc)
 Ensure that the configuration options are self consistent. More...
 
TY_PRIVATE int TY_❪CharEncodingId❫ (TidyDocImpl *doc, ctmbstr charenc)
 Returns the character encoding ID for the given character encoding string. More...
 
TY_PRIVATE ctmbstr TY_❪CharEncodingName❫ (int encoding)
 Returns the full name of the encoding for the given ID. More...
 
TY_PRIVATE ctmbstr TY_❪CharEncodingOptName❫ (int encoding)
 Returns the Tidy command line option name of the encoding for the given ID. More...
 
TY_PRIVATE Bool TY_❪ConfigDiffThanDefault❫ (TidyDocImpl *doc)
 Indicates whether or not the current configuration is completely default. More...
 
TY_PRIVATE Bool TY_❪ConfigDiffThanSnapshot❫ (TidyDocImpl *doc)
 Indicates whether or not the current configuration is different from the stored snapshot. More...
 
TY_PRIVATE void TY_❪CopyConfig❫ (TidyDocImpl *docTo, TidyDocImpl *docFrom)
 Copies the configuration from one document to another. More...
 
TY_PRIVATE void TY_❪DeclareListItem❫ (TidyDocImpl *doc, const TidyOptionImpl *opt, ctmbstr name)
 Coordinates Config update and list data. More...
 
TY_PRIVATE void TY_❪FreeConfig❫ (TidyDocImpl *doc)
 Frees the configuration memory for the given Tidy document. More...
 
TY_PRIVATE ctmbstr TY_❪getNextOptionPick❫ (const TidyOptionImpl *option, TidyIterator *iter)
 Gets the next picklist possibility provided by the iterator. More...
 
TY_PRIVATE const TidyOptionImpl * TY_❪getNextOption❫ (TidyDocImpl *doc, TidyIterator *iter)
 Gets the next option provided by the iterator. More...
 
TY_PRIVATE const Bool TY_❪getOptionIsList❫ (TidyOptionId optId)
 Given an option ID, indicates whether or not the option is a list. More...
 
TY_PRIVATE TidyIterator TY_❪getOptionList❫ (TidyDocImpl *doc)
 Initiates an iterator to cycle through all of the available options. More...
 
TY_PRIVATE TidyIterator TY_❪getOptionPickList❫ (const TidyOptionImpl *option)
 Initiates an iterator to cycle through all of the available picklist possibilities. More...
 
TY_PRIVATE const TidyOptionImpl * TY_❪getOption❫ (TidyOptionId optId)
 Given an option ID, return an instance of an option. More...
 
TY_PRIVATE ctmbstr TY_❪GetPickListLabelForPick❫ (TidyOptionId optId, uint pick)
 Gets the picklist label for a given value. More...
 
TY_PRIVATE void TY_❪InitConfig❫ (TidyDocImpl *doc)
 Initialize the configuration for the given Tidy document. More...
 
TY_PRIVATE const TidyOptionImpl * TY_❪lookupOption❫ (ctmbstr optnam)
 Given an option name, return an instance of an option. More...
 
TY_PRIVATE const TidyOptionDocTY_❪OptGetDocDesc❫ (TidyOptionId optId)
 Returns the cross-reference information structure for optID, which is used for generating documentation. More...
 
TY_PRIVATE int TY_❪ParseConfigFileEnc❫ (TidyDocImpl *doc, ctmbstr cfgfil, ctmbstr charenc)
 Attempts to parse the given config file into the document, using the provided encoding. More...
 
TY_PRIVATE int TY_❪ParseConfigFile❫ (TidyDocImpl *doc, ctmbstr cfgfil)
 Attempts to parse the given config file into the document. More...
 
TY_PRIVATE Bool TY_❪ParseConfigOption❫ (TidyDocImpl *doc, ctmbstr optnam, ctmbstr optVal)
 Attempts to parse the provided value for the given option name. More...
 
TY_PRIVATE Bool TY_❪ParseConfigValue❫ (TidyDocImpl *doc, TidyOptionId optId, ctmbstr optVal)
 Attempts to parse the provided value for the given option id. More...
 
TY_PRIVATE void TY_❪ResetConfigToDefault❫ (TidyDocImpl *doc)
 Resets all options in the document to their default values. More...
 
TY_PRIVATE void TY_❪ResetConfigToSnapshot❫ (TidyDocImpl *doc)
 Restores all of the configuration values to their snapshotted values. More...
 
TY_PRIVATE Bool TY_❪ResetOptionToDefault❫ (TidyDocImpl *doc, TidyOptionId optId)
 Resets the given option to its default value. More...
 
TY_PRIVATE int TY_❪SaveConfigFile❫ (TidyDocImpl *doc, ctmbstr cfgfil)
 Saves the current configuration for options not having default values into the specified file. More...
 
TY_PRIVATE int TY_❪SaveConfigSink❫ (TidyDocImpl *doc, TidyOutputSink *sink)
 Writes the current configuration for options not having default values into the specified sink. More...
 
TY_PRIVATE Bool TY_❪SetOptionBool❫ (TidyDocImpl *doc, TidyOptionId optId, Bool val)
 Sets the bool value for the given option Id. More...
 
TY_PRIVATE Bool TY_❪SetOptionInt❫ (TidyDocImpl *doc, TidyOptionId optId, ulong val)
 Sets the integer value for the given option Id. More...
 
TY_PRIVATE void TY_❪TakeConfigSnapshot❫ (TidyDocImpl *doc)
 Stores a snapshot of all of the configuration values that can be restored later. More...
 

Data Structure Documentation

◆ _tidy_option

struct _tidy_option

This structure defines the internal representation of a Tidy option.

The TidyOptionImpl type implements the _tidy_option structure.

Data Fields
TidyConfigCategory category The category of the option.
ulong dflt Default value for TidyInteger and TidyBoolean.
TidyOptionId id The unique identifier for this option.
ctmbstr name The name of the option.
ParseProperty * parser Function to parse input; read-only if NULL.
ctmbstr pdflt Default value for TidyString.
PickListItems * pickList The picklist of possible values for this option.
TidyOptionType type The date type for the option.

◆ PickListItem

struct PickListItem

Structs of this type contain information needed in order to present picklists, relate picklist entries to public enum values, and parse strings that are accepted in order to assign the value.

Data Fields
ctmbstr inputs[10] String values that can select this value.
ctmbstr label PickList label for this item.
const int value The option value represented by this label.

◆ TidyConfigImpl

struct TidyConfigImpl

This type is used to define a structure for keeping track of the values for each option.

Data Fields
uint c Current char in input stream for reading options.
StreamIn * cfgIn Current input source for reading options.
uint defined_tags Tracks user-defined tags.
TidyOptionValue snapshot[N_TIDY_OPTIONS+1] Snapshot of values to be restored later.
TidyOptionValue value[N_TIDY_OPTIONS+1] Current config values.

◆ TidyOptionDoc

struct TidyOptionDoc

Used to build a table of documentation cross-references.

Data Fields
TidyOptionId const * links Cross references.

Last element must be 'TidyUnknownOption'.

TidyOptionId opt Identifier.

◆ TidyOptionValue

union TidyOptionValue

Stored option values can be one of two internal types.

Data Fields
char * p Value for TidyString.
ulong v Value for TidyInteger and TidyBoolean.

Macro Definition Documentation

◆ cfg

#define cfg (   doc,
  id 
)    ((doc)->config.value[ (id) ].v)

Access the raw, non-string uint value of the given option ID.

◆ cfgAutoBool

#define cfgAutoBool (   doc,
  id 
)    ((TidyTriState) cfg(doc, id))

Access the TidyTriState value of the given option ID.

◆ cfgBool

#define cfgBool (   doc,
  id 
)    ((Bool) cfg(doc, id))

Access the Bool value of the given option ID.

◆ cfgStr

#define cfgStr (   doc,
  id 
)    ((ctmbstr) (doc)->config.value[ (id) ].p)

Access the string value of the given option ID.

◆ TIDY_PL_SIZE

#define TIDY_PL_SIZE   16

Determines the maximum number of items in an option's picklist.

PickLists may have up to 16 items. For some reason, this limit has been hard-coded into Tidy for some time. Feel free to increase this as needed.

Typedef Documentation

◆ ParseProperty

typedef Bool() ParseProperty(TidyDocImpl *doc, const TidyOptionImpl *opt)

This typedef describes a function that is used for parsing the input given for a particular Tidy option.

◆ PickListItems

typedef const PickListItem PickListItems[TIDY_PL_SIZE]

An array of PickListItems, fixed in size for in-code declarations.

Arrays must be populated in 0 to 10 order, as the option value is assigned based on this index and not on the structures' value field. It remains a best practice, however, to assign a public enum value with the proper index value.

Function Documentation

◆ TY_❪AdjustCharEncoding❫()

TY_PRIVATE Bool TY_❪AdjustCharEncoding❫ ( TidyDocImpl *  doc,
int  encoding 
)

Ensure that char encodings are self consistent.

Parameters
docThe Tidy document to adjust.
encodingThe encoding being applied.
Returns
A bool indicating success or failure.

◆ TY_❪AdjustConfig❫()

TY_PRIVATE void TY_❪AdjustConfig❫ ( TidyDocImpl *  doc)

Ensure that the configuration options are self consistent.

THIS PROCESS IS DESTRUCTIVE TO THE USER STATE. It examines certain user-specified options and changes other options as a result. This means that documented API functions such as tidyOptGetValue() won't return the user-set values after this is used. As a result, don't just use this function at every opportunity, but only where needed, which is ONLY prior to parsing a stream, and again prior to saving a stream (because we reset after parsing.)

Parameters
docThe Tidy document to adjust.

◆ TY_❪CharEncodingId❫()

TY_PRIVATE int TY_❪CharEncodingId❫ ( TidyDocImpl *  doc,
ctmbstr  charenc 
)

Returns the character encoding ID for the given character encoding string.

Parameters
docThe Tidy document.
charencThe name of the character encoding.
Returns
The Id of the character encoding.

◆ TY_❪CharEncodingName❫()

TY_PRIVATE ctmbstr TY_❪CharEncodingName❫ ( int  encoding)

Returns the full name of the encoding for the given ID.

Parameters
encodingThe Id of the encoding.
Returns
The name of the character encoding.

◆ TY_❪CharEncodingOptName❫()

TY_PRIVATE ctmbstr TY_❪CharEncodingOptName❫ ( int  encoding)

Returns the Tidy command line option name of the encoding for the given ID.

Parameters
encodingThe Id of the encoding.
Returns
The Tidy command line option representing the encoding.

◆ TY_❪ConfigDiffThanDefault❫()

TY_PRIVATE Bool TY_❪ConfigDiffThanDefault❫ ( TidyDocImpl *  doc)

Indicates whether or not the current configuration is completely default.

Parameters
docThe Tidy document.
Returns
The result.

◆ TY_❪ConfigDiffThanSnapshot❫()

TY_PRIVATE Bool TY_❪ConfigDiffThanSnapshot❫ ( TidyDocImpl *  doc)

Indicates whether or not the current configuration is different from the stored snapshot.

Parameters
docThe Tidy document.
Returns
The result.

◆ TY_❪CopyConfig❫()

TY_PRIVATE void TY_❪CopyConfig❫ ( TidyDocImpl *  docTo,
TidyDocImpl *  docFrom 
)

Copies the configuration from one document to another.

Parameters
docToThe destination Tidy document.
docFromThe source Tidy document.

◆ TY_❪DeclareListItem❫()

TY_PRIVATE void TY_❪DeclareListItem❫ ( TidyDocImpl *  doc,
const TidyOptionImpl *  opt,
ctmbstr  name 
)

Coordinates Config update and list data.

Parameters
docThe Tidy document.
optThe option the list item is intended for.
nameThe name of the new list item.

◆ TY_❪FreeConfig❫()

TY_PRIVATE void TY_❪FreeConfig❫ ( TidyDocImpl *  doc)

Frees the configuration memory for the given Tidy document.

Parameters
docThe Tidy document.

◆ TY_❪getNextOptionPick❫()

TY_PRIVATE ctmbstr TY_❪getNextOptionPick❫ ( const TidyOptionImpl *  option,
TidyIterator *  iter 
)

Gets the next picklist possibility provided by the iterator.

Parameters
optionThe instance of the option for which to iterate a picklist.
iterThe iterator token initialized by TY_(getOptionPickList)().
Returns
The next picklist entry.

◆ TY_❪getNextOption❫()

TY_PRIVATE const TidyOptionImpl* TY_❪getNextOption❫ ( TidyDocImpl *  doc,
TidyIterator *  iter 
)

Gets the next option provided by the iterator.

Parameters
docThe Tidy document to get options.
iterThe iterator token initialized by TY_(getOptionList)().
Returns
The instance of the next option.

◆ TY_❪getOptionIsList❫()

TY_PRIVATE const Bool TY_❪getOptionIsList❫ ( TidyOptionId  optId)

Given an option ID, indicates whether or not the option is a list.

Parameters
optIdThe option ID to check.
Returns
Returns yes if the option value is a list.

◆ TY_❪getOptionList❫()

TY_PRIVATE TidyIterator TY_❪getOptionList❫ ( TidyDocImpl *  doc)

Initiates an iterator to cycle through all of the available options.

Parameters
docThe Tidy document to get options.
Returns
An iterator token to be used with TY_(getNextOption)().

◆ TY_❪getOptionPickList❫()

TY_PRIVATE TidyIterator TY_❪getOptionPickList❫ ( const TidyOptionImpl *  option)

Initiates an iterator to cycle through all of the available picklist possibilities.

Parameters
optionAn instance of an option for which to iterate a picklist.
Returns
An iterator token to be used with TY_(getNextOptionPick)().

◆ TY_❪getOption❫()

TY_PRIVATE const TidyOptionImpl* TY_❪getOption❫ ( TidyOptionId  optId)

Given an option ID, return an instance of an option.

Parameters
optIdThe option ID to retrieve.
Returns
The instance of the requested option.

◆ TY_❪GetPickListLabelForPick❫()

TY_PRIVATE ctmbstr TY_❪GetPickListLabelForPick❫ ( TidyOptionId  optId,
uint  pick 
)

Gets the picklist label for a given value.

Parameters
optIdthe option id having a picklist to check.
pickthe picklist item to retrieve.
Returns
The label for the pick.

◆ TY_❪InitConfig❫()

TY_PRIVATE void TY_❪InitConfig❫ ( TidyDocImpl *  doc)

Initialize the configuration for the given Tidy document.

Parameters
docThe Tidy document.

◆ TY_❪lookupOption❫()

TY_PRIVATE const TidyOptionImpl* TY_❪lookupOption❫ ( ctmbstr  optnam)

Given an option name, return an instance of an option.

Parameters
optnamThe option name to retrieve.
Returns
The instance of the requested option.

◆ TY_❪OptGetDocDesc❫()

TY_PRIVATE const TidyOptionDoc* TY_❪OptGetDocDesc❫ ( TidyOptionId  optId)

Returns the cross-reference information structure for optID, which is used for generating documentation.

Parameters
optIdThe option ID to get cross-reference information for.
Returns
Cross reference information.

◆ TY_❪ParseConfigFileEnc❫()

TY_PRIVATE int TY_❪ParseConfigFileEnc❫ ( TidyDocImpl *  doc,
ctmbstr  cfgfil,
ctmbstr  charenc 
)

Attempts to parse the given config file into the document, using the provided encoding.

Parameters
docThe Tidy document.
cfgfilThe file to load.
charencThe name of the encoding to use for reading the file.
Returns
a file system error code.

◆ TY_❪ParseConfigFile❫()

TY_PRIVATE int TY_❪ParseConfigFile❫ ( TidyDocImpl *  doc,
ctmbstr  cfgfil 
)

Attempts to parse the given config file into the document.

Parameters
docThe Tidy document.
cfgfilThe file to load.
Returns
a file system error code.

◆ TY_❪ParseConfigOption❫()

TY_PRIVATE Bool TY_❪ParseConfigOption❫ ( TidyDocImpl *  doc,
ctmbstr  optnam,
ctmbstr  optVal 
)

Attempts to parse the provided value for the given option name.

Returns false if unknown option, missing parameter, or the option doesn't use the parameter.

Parameters
docThe Tidy document.
optnamThe name of the option to be set.
optValThe string value to attempt to parse.
Returns
Success or failure.

◆ TY_❪ParseConfigValue❫()

TY_PRIVATE Bool TY_❪ParseConfigValue❫ ( TidyDocImpl *  doc,
TidyOptionId  optId,
ctmbstr  optVal 
)

Attempts to parse the provided value for the given option id.

Returns false if unknown option, missing parameter, or the option doesn't use the parameter.

Parameters
docThe Tidy document.
optIdThe ID of the option to be set.
optValThe string value to attempt to parse.
Returns
Success or failure.

◆ TY_❪ResetConfigToDefault❫()

TY_PRIVATE void TY_❪ResetConfigToDefault❫ ( TidyDocImpl *  doc)

Resets all options in the document to their default values.

Parameters
docThe Tidy document.

◆ TY_❪ResetConfigToSnapshot❫()

TY_PRIVATE void TY_❪ResetConfigToSnapshot❫ ( TidyDocImpl *  doc)

Restores all of the configuration values to their snapshotted values.

Parameters
docThe Tidy document.

◆ TY_❪ResetOptionToDefault❫()

TY_PRIVATE Bool TY_❪ResetOptionToDefault❫ ( TidyDocImpl *  doc,
TidyOptionId  optId 
)

Resets the given option to its default value.

Parameters
docThe Tidy document.
optIdThe option ID to set.
Returns
Success or failure.

◆ TY_❪SaveConfigFile❫()

TY_PRIVATE int TY_❪SaveConfigFile❫ ( TidyDocImpl *  doc,
ctmbstr  cfgfil 
)

Saves the current configuration for options not having default values into the specified file.

Parameters
docThe Tidy document.
cfgfilThe file to save.
Returns
a file system error code.

◆ TY_❪SaveConfigSink❫()

TY_PRIVATE int TY_❪SaveConfigSink❫ ( TidyDocImpl *  doc,
TidyOutputSink sink 
)

Writes the current configuration for options not having default values into the specified sink.

Parameters
docThe Tidy document.
sinkThe sink to save into.
Returns
a file system error code.

◆ TY_❪SetOptionBool❫()

TY_PRIVATE Bool TY_❪SetOptionBool❫ ( TidyDocImpl *  doc,
TidyOptionId  optId,
Bool  val 
)

Sets the bool value for the given option Id.

Parameters
docThe Tidy document.
optIdThe option ID to set.
valThe value to set.
Returns
Success or failure.

◆ TY_❪SetOptionInt❫()

TY_PRIVATE Bool TY_❪SetOptionInt❫ ( TidyDocImpl *  doc,
TidyOptionId  optId,
ulong  val 
)

Sets the integer value for the given option Id.

Parameters
docThe Tidy document.
optIdThe option ID to set.
valThe value to set.
Returns
Success or failure.

◆ TY_❪TakeConfigSnapshot❫()

TY_PRIVATE void TY_❪TakeConfigSnapshot❫ ( TidyDocImpl *  doc)

Stores a snapshot of all of the configuration values that can be restored later.

Parameters
docThe Tidy document.