Method Parser.HTML()->add_container()

Method add_container

Parser.HTML add_tag(string name, mixed to_do)
Parser.HTML add_container(string name, mixed to_do)
Parser.HTML add_entity(string entity, mixed to_do)
Parser.HTML add_quote_tag(string name, mixed to_do, string end)
Parser.HTML add_tags(mapping(string:mixed) tags)
Parser.HTML add_containers(mapping(string:mixed) containers)
Parser.HTML add_entities(mapping(string:mixed) entities)


Registers the actions to take when parsing various things. Tags, containers, entities are as usual. add_quote_tag() adds a special kind of tag that reads any data until the next occurrence of the end string immediately before a tag end.

Parameter to_do

This argument can be any of the following.


The function will be called as a callback function. It will get the following arguments, depending on the type of callback.

 mixed tag_callback(Parser.HTML parser,mapping args,mixed ... extra)
 mixed container_callback(Parser.HTML parser,mapping args,string content,mixed ... extra)
 mixed entity_callback(Parser.HTML parser,mixed ... extra)
 mixed quote_tag_callback(Parser.HTML parser,string content,mixed ... extra)


This tag/container/entity is then replaced by the string. The string is normally not reparsed, i.e. it's equivalent to writing a function that returns the string in an array (but a lot faster). If reparse_strings is set the string will be reparsed, though.


The first element is a function as above. It will receive the rest of the array as extra arguments. If extra arguments are given by set_extra(), they will appear after the ones in this array.


If there is a tag/container/entity with the given name in the parser, it's removed.

The callback function can return:


This string will be pushed on the parser stack and be parsed. Be careful not to return anything in this way that could lead to a infinite recursion.


The element(s) of the array is the result of the function. This will not be parsed. This is useful for avoiding infinite recursion. The array can be of any size, this means the empty array is the most effective to return if you don't care about the result. If the parser is operating in mixed_mode, the array can contain anything. Otherwise only strings are allowed.


This means "don't do anything", ie the item that generated the callback is left as it is, and the parser continues.


Reparse the last item again. This is useful to parse a tag as a container, or vice versa: just add or remove callbacks for the tag and return this to jump to the right callback.


Returns the object being called.

See also

tags, containers, entities