Open anatoly-scherbakov opened 4 months ago
As described in Process HTML section of the specification, it is described how expand() behaves on HTML documents with extractAllScripts option.
expand()
extractAllScripts
false
object
array
null
true
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_all()
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.
<script>
P. S. This will be handy for YAML-LD to expand_all() multiple documents in a stream.
As described in Process HTML section of the specification, it is described how
expand()
behaves on HTML documents withextractAllScripts
option.false
then it will return a JSON-LD document (might be anobject
, anarray
, or perhaps anull
);true
thenexpand()
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 whenextractAllScripts
istrue
;expand_all()
will not acceptextractAllScripts
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 acceptextractAllScripts
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.