Description:
We need to implement a built-in validator and equality function for Z89 (HTML fragment) in Wikifunctions.
Why this is needed:
Now that Z89 is a supported type, function outputs may include HTML fragments. In order for the platform to properly support:
- Validation of function outputs (e.g., during evaluation or editing)
- Comparison of outputs for test cases and equality checks
- Safe internal usage of Z89 values in other built-ins or orchestrator logic
...we need native support for:
Validation: Ensure that a Z89K1 value is a valid string (and optionally contains only allowed HTML elements.)
Equality: Allow comparison of two Z89 values based on normalized HTML (e.g., ignoring whitespace differences or ordering of attributes).
Update, 15 June 2025
- For the validator, we decided to just create a placeholder for now (Z189 with implementation Z289), and that's been done.
Equality function creation steps:
- Choose a ZID for the equality function
- possibly Z877, because the other equality functions have double digits, this is the next double digit number after string equality, Z866, and there's nothing more obvious
- In function-schemata:
- Define the equality function
- Define the built-in implementation (Z977)
- Update dependencies.js
- In the orchestrator:
- Write the orchestrator code for the implementation, in builtins.js
- Add the ZIDs to the relevant lists in builtins.js
- Add tests
Next quarter work
- equality function now just checks 1.Z89K1 === 2.Z89K2. But with html two html strings can be valid but differently indented. This needs some work in the future.
// this equals <strong><i>equal</i></strong> // this <strong> <i>equal</i> </strong>
- validator is an builtin empty validator. might need more work.