`expand(..., extractAllScripts)` and typing
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 106
- Forks
- 40
- PR merge metrics
- No merged PRs in 30d
Description
As described in Process HTML section of the specification, it is described how expand() behaves on HTML documents with extractAllScripts option.
- If that option is
falsethen it will return a JSON-LD document (might be anobject, anarray, or perhaps anull); - If the option is
truethenexpand()returns necessarily anarray.
This means that the output type of expand() deterministically depends on its input parameters.
What if we could split expand() into two separate functions?
expand()will behave as it is behaving now, but it will print a deprecation message whenextractAllScriptsistrue;expand_all()will not acceptextractAllScriptsoption and will always output an array. It will parse all scripts in a document.
Over time, expand() might be updated: it will no longer accept extractAllScripts option at all and it will only parse one <script> in the document.
P. S. This will be handy for YAML-LD to expand_all() multiple documents in a stream.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Process HTML section of the JSON-LD 1.1 API specification and compare the current expand() behavior for extractAllScripts=false and true. Review how a separate expand_all() API and the proposed deprecation are described, then define the API and typing changes needed for the two output shapes.
Written by the indexing model from the issue text.
Assessment
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100