70-parser-engine.php
Table of Contents
- add_parser() : mixed
- Registers a new parser.
- parse_page_source() : string
- Parses the specified page source using the parser specified in the settings into HTML.
Functions
add_parser()
Registers a new parser.
add_parser(string $name, callable $parser_code, callable $hash_generator) : mixed
Parameters
- $name : string
-
The name of the new parser to register.
- $parser_code : callable
-
The function to register as a new parser.
- $hash_generator : callable
-
A function that should take a single argument of the input source text, and return a unique hash for that content. The return value is used as the filename for cache entries, so should be safe to use as such.
Return values
mixed —parse_page_source()
Parses the specified page source using the parser specified in the settings into HTML.
parse_page_source(string $source[, bool $untrusted = false ][, bool $use_cache = true ]) : string
The specified parser may (though it's unlikely) render it to other things.
Parameters
- $source : string
-
The source to render.
- $untrusted : bool = false
-
Whether the source string is 'untrusted' - i.e. a user comment. Untrusted source disallows HTML and protects against XSS attacks.
- $use_cache : bool = true
-
Whether to use the on-disk cache. Has no effect if parser caching is disabled in peppermint.json, or the source string is too small.
Return values
string —The source rendered to HTML.