functions-htmlawed.php
Table of Contents
Functions
- htmLawed() : mixed
- htmLawed.php – Filter/sanitize HTM text with PHP.
- hl_attrval() : mixed
- Validate attribute value and possibly change to a default value if invalid.
- hl_bal() : mixed
- hl_cmtcd() : string
- Handle comment/CDATA section.
- hl_ent() : string
- Handle entity.
- hl_prot() : string
- Handle URL to convert to relative/absolute type, block scheme, or add anti-spam text.
- hl_regex() : int
- Check regex pattern for PHP error.
- hl_spec() : array<string|int, mixed>
- Parse $spec htmLawed argument as array.
- hl_tag() : string
- Handle tag text with </> limiters.
- hl_tag2() : mixed
- Transform deprecated element, with any attribute, into a new element.
- hl_tidy() : mixed
- Tidy/beautify HTM by adding newline and other spaces (padding), or compact by removing unnecessary spaces.
- hl_version() : mixed
- Report version.
Functions
htmLawed()
htmLawed.php – Filter/sanitize HTM text with PHP.
htmLawed(mixed $t[, mixed $C = 1 ][, mixed $S = array() ]) : mixed
Use: $out = htmLawed($in, $config, $spec) See htmLawed_README.
Code overview in htmLawed_README §5.6. Familiarity with HTML standards and documentation on htmLawed configuration required to understand code.
A PHP Labware internal utility - bioinformatics.org/phplabware.
Parameters
- $t : mixed
- $C : mixed = 1
- $S : mixed = array()
Tags
hl_attrval()
Validate attribute value and possibly change to a default value if invalid.
hl_attrval(string $attr, string $value, array<string|int, mixed> $ruleAr) : mixed
Parameters
- $attr : string
-
Attribute name.
- $value : string
-
Attribute value; may be string of multiple separated values.
- $ruleAr : array<string|int, mixed>
-
Array of rules derived from $spec.
Return values
mixed —0 if invalid $value, or string with validated value or value reset to a default.
hl_bal()
hl_bal(mixed $t[, mixed $act = 1 ][, mixed $parentEle = 'div' ]) : mixed
Parameters
- $t : mixed
- $act : mixed = 1
- $parentEle : mixed = 'div'
hl_cmtcd()
Handle comment/CDATA section.
hl_cmtcd(array<string|int, mixed> $t) : string
Filter/sanitize as per $config and disguise special characters.
Parameters
- $t : array<string|int, mixed>
-
Array result of preg_replace, with potential comment/CDATA.
Return values
string —Sanitized comment/CDATA with disguised special characters.
hl_ent()
Handle entity.
hl_ent(array<string|int, mixed> $t) : string
As needed, convert between named and hexadecimal form, or neutralize by changing '&' to '&'.
Parameters
- $t : array<string|int, mixed>
-
Array result of preg_replace, with potential entity.
Return values
string —Neutralized or converted entity.
hl_prot()
Handle URL to convert to relative/absolute type, block scheme, or add anti-spam text.
hl_prot(mixed $url[, mixed $attr = null ]) : string
Parameters
- $url : mixed
-
URL string, or array with URL value (if $attr is null).
- $attr : mixed = null
-
Attribute name string, or null (if $url is array).
Return values
string —With URL after any conversion/obfuscation.
hl_regex()
Check regex pattern for PHP error.
hl_regex(string $t) : int
Parameters
- $t : string
-
Pattern including limiters/modifiers.
Return values
int —0 or 1 if pattern is invalid or valid, respectively.
hl_spec()
Parse $spec htmLawed argument as array.
hl_spec(string $t) : array<string|int, mixed>
See documentation on $spec specification.
Parameters
- $t : string
-
Value of $spec.
Return values
array<string|int, mixed> —Multidimensional array of form: tag -> attribute -> rule.
hl_tag()
Handle tag text with </> limiters.
hl_tag(array<string|int, mixed> $t) : string
Also handles attributes in opening tags.
Parameters
- $t : array<string|int, mixed>
-
Result of preg_replace call.
Return values
string —Tag, with any attribute string, or text with </> neutralized into entities, or empty.
hl_tag2()
Transform deprecated element, with any attribute, into a new element.
hl_tag2(string &$ele, string &$attrStr[, int $act = 1 ]) : mixed
Parameters
- $ele : string
-
Deprecated element.
- $attrStr : string
-
Attribute string of element.
- $act : int = 1
-
No transformation if 2.
Return values
mixed —New attribute string (may be empty) or 0.
hl_tidy()
Tidy/beautify HTM by adding newline and other spaces (padding), or compact by removing unnecessary spaces.
hl_tidy(string $t, mixed $format, string $parentEle) : mixed
Parameters
- $t : string
-
HTM.
- $format : mixed
-
-1 (compact) or string (type of padding).
- $parentEle : string
-
Parent element of $t.
Return values
mixed —Transformed attribute string (may be empty) or 0.
hl_version()
Report version.
hl_version() : mixed