Method Parser.HTML()->_set_data_callback()


Method _set_data_callback

Parser.HTML _set_tag_callback(function(:void)|string|array to_call)
Parser.HTML _set_entity_callback(function(:void)|string|array to_call)
Parser.HTML _set_data_callback(function(:void)|string|array to_call)

Description

These functions set up the parser object to call the given callbacks upon tags, entities and/or data. The callbacks will only be called if there isn't another tag/container/entity handler for these.

The callback function will be called with the parser object as first argument, and the active string as second. Note that no parsing of the contents has been done. Both endtags and normal tags are called; there is no container parsing.

The return values from the callbacks are handled in the same way as the return values from callbacks registered with add_tag and similar functions.

The data callback will be called as seldom as possible with the longest possible string, as long as it doesn't get called out of order with any other callback. It will never be called with a zero length string.

If a string or array is given instead of a function, it will act as the return value from the function. Arrays or empty strings is probably preferable to avoid recursion.

Returns

Returns the object being called.