Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expand(..., extractAllScripts) and typing #592

Open
anatoly-scherbakov opened this issue Feb 19, 2024 · 0 comments
Open

expand(..., extractAllScripts) and typing #592

anatoly-scherbakov opened this issue Feb 19, 2024 · 0 comments

Comments

@anatoly-scherbakov
Copy link

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 false then it will return a JSON-LD document (might be an object, an array, or perhaps a null);
  • If the option is true then expand() returns necessarily an array.

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 when extractAllScripts is true;
  • expand_all() will not accept extractAllScripts option 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant