[Top]
predef::
Parser
Parser.HTML
|
Method Parser.HTML()->add_tags()
- Method
add_tags
-
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)
- Description
-
-
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.
to_do can be:
a function to be called. The function is on the form
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)
depending on what realm the function is called by. a string. 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. an array. 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. zero. If there is a tag/container/entity with the
given name in the parser, it's removed.
The callback function can return:
a string; 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. an array; 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. zero; this means "don't do anything", ie the
item that generated the callback is left as it is, and
the parser continues. one; 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 called object
- See also
-
-
tags , containers , entities
|