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>
5871
-
having an <adata-cite="HTML/semantics.html#attr-link-type">type attribute</a>
5872
-
of <code>application/ld+json</code> along with the value of the
5873
-
<adata-link-for="LoadDocumentOptions">profile</a> option, if found.</li>
5874
-
<li>If <var>source</var> is still undefined and the <adata-link-for="LoadDocumentOptions">extractAllScripts</a> option is not present, or <code>false</code>,
5875
-
set <var>source</var> to the <adata-cite="DOM#dom-node-textcontent">textContent</a>
5876
-
of the first <a>JSON-LD script element</a> in <var>document</var>.
5877
-
<p>If no such element is found,
5878
-
or the located element is not a <a>JSON-LD script element</a>,
5879
-
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>
5885
-
with a <a>JsonLdError</a> whose code set from the result, if an error is detected
5886
-
and processing is terminated.
5887
-
</li>
5888
-
<li>Otherwise, <var>source</var> is undefined.
5889
-
<ol>
5890
-
<li>If the <adata-link-for="LoadDocumentOptions">extractAllScripts</a> option is not present, or <code>false</code>,
5891
-
the <var>promise</var> is rejected with a <a>JsonLdError</a> whose code is set to <adata-link-for="JsonLdErrorCode">loading document failed</a>
5892
-
and processing is terminated.</li>
5893
-
<li>Otherwise, the <adata-link-for="LoadDocumentOptions">extractAllScripts</a> option is <code>true</code>.
5894
-
Set <var>document</var> to a new empty <a>array</a>.
5895
-
For each <a>JSON-LD script element</a> in <var>input</var>:
5896
-
<ol>
5897
-
<li>Set <var>source</var> to its <adata-cite="DOM#dom-node-textcontent">textContent</a>.</li>
5898
-
<li>Set <var>script content</var> to the result of the <ahref="#extract-script-content">Extract Script Content algorithm</a>,
5899
-
using <var>source</var>, rejecting <var>promise</var>
5900
-
with a <a>JsonLdError</a> whose code set from the result, if an error is detected
5901
-
and processing is terminated.</li>
5902
-
<li>If <var>script content</var> is an <a>array</a>, merge it to the end of <var>document</var>.</li>
5903
-
<li>Otherwise, append <var>script content</var> to <var>document</var>.</li>
5904
-
</ol>
5905
-
</li>
5906
-
</ol>
5907
-
</li>
5908
-
</ol>
5909
-
</li>
5910
5774
<li>Otherwise, the retrieved document's <a>Content-Type</a> is neither
5911
5775
<code>application/json</code>,
5912
5776
<code>application/ld+json</code>,
5913
-
<code>text/html</code>,
5914
5777
nor any other media type using a
5915
5778
<code>+json</code> suffix as defined in [[RFC6839]].
5916
5779
Reject the <var>promise</var> passing a <adata-link-for="JsonLdErrorCode">loading document failed</a> error.</li>
@@ -5998,6 +5861,108 @@ <h3>RemoteDocument</h3>
5998
5861
</section>
5999
5862
</section><!-- end of Remote Document and Context Retrieval -->
6000
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
+
</li>
5890
+
<li>If the <adata-link-for="LoadDocumentCallback">url</a> parameter
5891
+
contains a <adata-cite="RFC3986#section-3.5">fragment identifier</a>,
5892
+
set <var>source</var> to the <adata-cite="DOM#dom-node-textcontent">textContent</a>
5893
+
of the <adata-cite="HTML/scripting.html#the-script-element">script element</a> in <var>document</var>
5894
+
having an <adata-cite="HTML/dom.html#the-id-attribute">id attribute</a>
5895
+
that matches the fragment identifier, after decoding <adata-cite="RFC3986#section-2.1">percent encoded sequences</a>.
5896
+
<p>If no such element is found,
5897
+
or the located element is not a <a>JSON-LD script element</a>,
5898
+
the <var>promise</var> is rejected with a <a>JsonLdError</a> whose code is set to <adata-link-for="JsonLdErrorCode">loading document failed</a>
5899
+
and processing is terminated.</p>
5900
+
</li>
5901
+
<li>Otherwise, if the <adata-link-for="LoadDocumentOptions">profile</a>
5902
+
option is specified,
5903
+
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>
5906
+
having an <adata-cite="HTML/semantics.html#attr-link-type">type attribute</a>
5907
+
of <code>application/ld+json</code> along with the value of the
5908
+
<adata-link-for="LoadDocumentOptions">profile</a> option, if found.</li>
5909
+
<li>If <var>source</var> is still undefined and the <adata-link-for="LoadDocumentOptions">extractAllScripts</a> option is not present, or <code>false</code>,
5910
+
set <var>source</var> to the <adata-cite="DOM#dom-node-textcontent">textContent</a>
5911
+
of the first <a>JSON-LD script element</a> in <var>document</var>.
5912
+
<p>If no such element is found,
5913
+
or the located element is not a <a>JSON-LD script element</a>,
5914
+
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