You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Move HTML bits into a separate section, with callouts into the documentLoader algorithm to contain HTML-related processing. Also, removes processor levels describing this as a processor supporting "HTML script extraction".
of the first <adata-cite="HTML/scripting.html#the-script-element">script element</a> in <var>document</var>
5876
-
having an <adata-cite="HTML/semantics.html#attr-link-type">type attribute</a>
5877
-
of <code>application/ld+json</code> along with the value of the
5878
-
<adata-link-for="LoadDocumentOptions">profile</a> option, if found.</li>
5879
-
<li>If <var>source</var> is still undefined and the <adata-link-for="LoadDocumentOptions">extractAllScripts</a> option is not present, or <code>false</code>,
5880
-
set <var>source</var> to the <adata-cite="DOM#dom-node-textcontent">textContent</a>
5881
-
of the first <a>JSON-LD script element</a> in <var>document</var>.
5882
-
<p>If no such element is found,
5883
-
or the located element is not a <a>JSON-LD script element</a>,
5884
-
the <var>promise</var> is rejected with a <a>JsonLdError</a> whose code is set to <adata-link-for="JsonLdErrorCode">loading document failed</a>
using <var>source</var>, rejecting <var>promise</var>
5890
-
with a <a>JsonLdError</a> whose code set from the result, if an error is detected
5891
-
and processing is terminated.
5892
-
</li>
5893
-
<li>Otherwise, <var>source</var> is undefined.
5894
-
<ol>
5895
-
<li>If the <adata-link-for="LoadDocumentOptions">extractAllScripts</a> option is not present, or <code>false</code>,
5896
-
the <var>promise</var> is rejected with a <a>JsonLdError</a> whose code is set to <adata-link-for="JsonLdErrorCode">loading document failed</a>
5897
-
and processing is terminated.</li>
5898
-
<li>Otherwise, the <adata-link-for="LoadDocumentOptions">extractAllScripts</a> option is <code>true</code>.
5899
-
Set <var>document</var> to a new empty <a>array</a>.
5900
-
For each <a>JSON-LD script element</a> in <var>input</var>:
5901
-
<ol>
5902
-
<li>Set <var>source</var> to its <adata-cite="DOM#dom-node-textcontent">textContent</a>.</li>
5903
-
<li>Set <var>script content</var> to the result of the <ahref="#extract-script-content">Extract Script Content algorithm</a>,
5904
-
using <var>source</var>, rejecting <var>promise</var>
5905
-
with a <a>JsonLdError</a> whose code set from the result, if an error is detected
5906
-
and processing is terminated.</li>
5907
-
<li>If <var>script content</var> is an <a>array</a>, merge it to the end of <var>document</var>.</li>
5908
-
<li>Otherwise, append <var>script content</var> to <var>document</var>.</li>
5909
-
</ol>
5910
-
</li>
5911
-
</ol>
5912
-
</li>
5913
-
</ol>
5914
-
</li>
5915
5774
<li>Otherwise, the retrieved document's <a>Content-Type</a> is neither
5916
5775
<code>application/json</code>,
5917
5776
<code>application/ld+json</code>,
5918
-
<code>text/html</code>,
5919
5777
nor any other media type using a
5920
5778
<code>+json</code> suffix as defined in [[RFC6839]].
5921
5779
Reject the <var>promise</var> passing a <adata-link-for="JsonLdErrorCode">loading document failed</a> error.</li>
@@ -6003,6 +5861,113 @@ <h3>RemoteDocument</h3>
6003
5861
</section>
6004
5862
</section><!-- end of Remote Document and Context Retrieval -->
6005
5863
5864
+
<sectionclass="changed">
5865
+
<h2>HTML Content Algorithms</h2>
5866
+
<pclass="note">This section describes features available
5867
+
with a <adata-link-for="JsonLdOptions">documentLoader</a> supporting HTML script extraction.</p>
5868
+
<p>Implementations of a <adata-link-for="JsonLdOptions">documentLoader</a> MAY support extracting JSON-LD from
5869
+
<adata-cite="HTML/scripting.html#the-script-element">script elements</a> contained within an HTML [[HTML]] document.
5870
+
This section describes the normative behavior of such processors.
5871
+
Such a processor supports <dfn>HTML script extraction</dfn>.</p>
5872
+
5873
+
<sectionid="process-html"><h3>Process HTML</h3>
5874
+
<p>This sections describe an extension to the algorithm specified
5875
+
in <a>LoadDocumentCallback</a> to support extracting JSON-LD from HTML.</p>
5876
+
5877
+
<p><ahref="#LoadDocumentCallback-step-2">Step 2</a> is updated to add the following: A processor supporting <a>HTML script extraction</a> MUST include <code>text/html</code> at any preference level,
5878
+
unless <adata-link-for="LoadDocumentOptions">requestProfile</a> is `http://www.w3.org/ns/json-ld#context`.</p>
5879
+
5880
+
<p>After <ahref="#LoadDocumentCallback-step-5">step 5</a>, add the following processing step:
5881
+
Otherwise, if the retrieved resource's <a>Content-Type</a> is <code>text/html</code>:</p>
5882
+
<ol>
5883
+
<li>If the processor does not support <a>HTML script extraction</a>
5884
+
the <var>promise</var> is rejected with a <a>JsonLdError</a> whose code is set to <adata-link-for="JsonLdErrorCode">loading document failed</a>
5885
+
and processing is terminated.</li>
5886
+
<li>Set <var>documentUrl</var> to the the <adata-cite="HTML/urls-and-fetching.html#document-base-url">Document Base URL</a>
5887
+
of <adata-link-for="LoadDocumentCallback">url</a>, as defined in [[HTML]],
5888
+
using the existing <var>documentUrl</var> as the document's URL.
5889
+
<divclass="issue atrisk">
5890
+
The use of the <adata-cite="HTML/urls-and-fetching.html#document-base-url">Document Base URL</a>
5891
+
from [[HTML]] for setting the <a>base IRI</a> of the enclosed JSON-LD
5892
+
is an experimental feature, which may be changed in a future version of this specification.
5893
+
</div>
5894
+
</li>
5895
+
<li>If the <adata-link-for="LoadDocumentCallback">url</a> parameter
5896
+
contains a <adata-cite="RFC3986#section-3.5">fragment identifier</a>,
5897
+
set <var>source</var> to the <adata-cite="DOM#dom-node-textcontent">textContent</a>
5898
+
of the <adata-cite="HTML/scripting.html#the-script-element">script element</a> in <var>document</var>
5899
+
having an <adata-cite="HTML/dom.html#the-id-attribute">id attribute</a>
5900
+
that matches the fragment identifier, after decoding <adata-cite="RFC3986#section-2.1">percent encoded sequences</a>.
5901
+
<p>If no such element is found,
5902
+
or the located element is not a <a>JSON-LD script element</a>,
5903
+
the <var>promise</var> is rejected with a <a>JsonLdError</a> whose code is set to <adata-link-for="JsonLdErrorCode">loading document failed</a>
5904
+
and processing is terminated.</p>
5905
+
</li>
5906
+
<li>Otherwise, if the <adata-link-for="LoadDocumentOptions">profile</a>
5907
+
option is specified,
5908
+
set <var>source</var> to the result of transforming the
of the first <adata-cite="HTML/scripting.html#the-script-element">script element</a> in <var>document</var>
5911
+
having an <adata-cite="HTML/semantics.html#attr-link-type">type attribute</a>
5912
+
of <code>application/ld+json</code> along with the value of the
5913
+
<adata-link-for="LoadDocumentOptions">profile</a> option, if found.</li>
5914
+
<li>If <var>source</var> is still undefined and the <adata-link-for="LoadDocumentOptions">extractAllScripts</a> option is not present, or <code>false</code>,
5915
+
set <var>source</var> to the <adata-cite="DOM#dom-node-textcontent">textContent</a>
5916
+
of the first <a>JSON-LD script element</a> in <var>document</var>.
5917
+
<p>If no such element is found,
5918
+
or the located element is not a <a>JSON-LD script element</a>,
5919
+
the <var>promise</var> is rejected with a <a>JsonLdError</a> whose code is set to <adata-link-for="JsonLdErrorCode">loading document failed</a>
0 commit comments