Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions doc/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -665,15 +665,20 @@ <h4>Terms and definitions section</h4>
<li>The <code>dd</code> elements following the <code>dt</code> element(s) shall appear in the following
order — each group is optional, but if present, it shall appear in this sequence:
<ol>
<li><strong>Definition:</strong> the first <code>dd</code> element shall be the definition of the term. This element is required.</li>
<li><strong>Definition:</strong> the first <code>dd</code> element shall be the definition of the term. This element is required.
References to other defined terms and <code>dfn</code> elements are permitted using <code>&lt;a&gt;</code> elements without an
<code>href</code> attribute. Citations to clauses or external references (i.e. <code>&lt;a href="#bib-HTML-5"&gt;</code>) are not permitted.</li>
<li><strong>Deprecated:</strong> the next <code>dd</code> element, if present, shall have a <code>class</code>
attribute containing <code>deprecated</code>, indicating the term is deprecated. At most one such element is permitted.</li>
<li><strong>Examples:</strong> the next <code>dd</code> element(s), if present, shall each have a <code>class</code>
attribute containing <code>example</code>.</li>
<li><strong>Notes:</strong> the next <code>dd</code> element(s), if present, shall each have a <code>class</code>
attribute containing <code>note</code>.</li>
<li><strong>Source:</strong> the last <code>dd</code> element, if present, shall contain a single reference to a
bibliographic entry and serves as the source of the definition.</li>
attribute containing <code>note</code>. References to defined terms, clauses, and external references are all permitted.</li>
<li><strong>Source:</strong> the last <code>dd</code> element, if present, shall have a <code>class</code>
attribute containing <code>source</code> and serves as the source of the definition. At most one such element
is permitted. It shall contain a reference to a bibliographic entry and may contain additional text. If any
changes are made to the original terminological entry, this shall be indicated, along with a description of
what has been modified.</li>
</ol>
</li>
</ul>
Expand All @@ -693,7 +698,7 @@ <h4>Terms and definitions section</h4>
&lt;dd class="deprecated"&gt;deprecated term&lt;/dd&gt;
&lt;dd class="example"&gt;An example of a key number is 12345.&lt;/dd&gt;
&lt;dd class="note"&gt;Key number shall not be confused with key frame.&lt;/dd&gt;
&lt;dd&gt;&lt;a href=&quot;#bib-key-number-spec&quot;&gt;&lt;/a&gt;&lt;/dd&gt;
&lt;dd class="source"&gt;&lt;a href=&quot;#bib-key-number-spec&quot;&gt;&lt;/a&gt;, modified — definition has been updated.&lt;/dd&gt;
&lt;/dl&gt;
&lt;/section&gt;
</pre>
Expand Down
17 changes: 9 additions & 8 deletions js/validate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,14 @@ class DdMatcher {

class DefinitionMatcher {
static match(element, logger) {
if (element.localName !== "dd" || element.classList.contains("note"))
if (element.localName !== "dd" || element.classList.contains("note") || element.classList.contains("source"))
return false;

for (const child of element.children) {
if (!AnyPhrasingMatcher.match(child, logger)) {
logger.error(`Definition contains non-phrasing element`, child);
} else if (child.localName === "a" && child.hasAttribute("href")) {
logger.error(`Definition body must not contain anchor with href; use dd.source instead`, child);
}
}

Expand All @@ -303,14 +305,11 @@ class DefinitionMatcher {

class DefinitionSourceMatcher {
static match(element, logger) {
if (element.localName !== "dd" || element.classList.contains("note"))
if (element.localName !== "dd" || !element.classList.contains("source"))
return false;

const aMatcher = new TerminalPhrasingMatcher("a");

if (element.childElementCount !== 1 || !aMatcher.match(element.firstElementChild, logger)) {
return false;
}
if (!Array.from(element.children).some(c => c.localName === "a" && c.hasAttribute("href")))
logger.error(`Source entry must contain at least one anchor with an href`, element);

return true;
}
Expand Down Expand Up @@ -730,7 +729,7 @@ class InternalDefinitionsMatcher {

if (count === 0) {
const next = children[0];
logger.error(`Out of order or unrecognized element in definition${next ? `: ${next.localName}${next.className ? `.${next.className}` : ""}` : ""}<br>Required order is: definition, deprecated, example, note, source`, element);
logger.error(`Out of order or unrecognized element in definition${next ? `: ${next.localName}${next.className ? `.${next.className}` : ""}` : ""}<br>Required order is: definition, deprecated, example, note, source`, next || element);
break;
}

Expand Down Expand Up @@ -770,6 +769,8 @@ class InternalDefinitionsMatcher {

if (children.length > 0 && DefinitionSourceMatcher.match(children[0], logger)) {
children.shift();
if (children.length > 0 && DefinitionSourceMatcher.match(children[0], logger))
logger.error(`Only one dd.source is permitted per term`, children[0]);
}

}
Expand Down
12 changes: 4 additions & 8 deletions smpte.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ are permitted provided that the following conditions are met:
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
this list of conditions and the following dissclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors
Expand Down Expand Up @@ -1489,14 +1489,10 @@ function formatTermsAndDefinitions(docMetadata) {
return;

for (const element of section.children) {
if (element.localName === "dd" &&
element.childNodes.length === 1 &&
element.firstChild.nodeType === Node.ELEMENT_NODE &&
element.firstChild.localName === "a") {
const anchor = element.firstChild;
if (element.localName === "dd" && element.classList.contains("source")) {
element.classList.add("term-source");
element.insertBefore(document.createTextNode("[SOURCE: "), anchor);
element.insertBefore(document.createTextNode("]"), anchor.nextSibling);
element.insertBefore(document.createTextNode("[SOURCE: "), element.firstChild);
element.appendChild(document.createTextNode("]"));
}
}
}
Expand Down
42 changes: 42 additions & 0 deletions test/resources/html/validation/terms-note-to-entry-2-invalid.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!doctype html>
<html>
<head itemscope="itemscope" itemtype="http://smpte.org/standards/documents">
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script type="module" src="../../../../smpte.js"></script>
<meta itemprop="test" content="invalid" />
<meta itemprop="pubType" content="AG" />
<meta itemprop="pubNumber" content="99" />
<meta itemprop="pubState" content="draft" />
<title>Title of the document</title>
</head>
<body>
<section id="sec-scope">
<p>This is the scope of the document.</p>
</section>

<section id="sec-normative-references">
<ul>
<li>
<cite id="bib-smpte-standards-operations-manual">SMPTE OM</cite></li>
</ul>
</section>

<section id="sec-terms-and-definitions">
<ul id="terms-ext-defs">
<li><a href="#bib-smpte-standards-operations-manual"></a></li>
</ul>
<dl id="terms-int-defs">
<dt><dfn>Clear</dfn></dt>
<dt>CLR</dt>
<dd>something that is clean</dd>
<dd class="note">The term shall not be used to refer to clarity of mind.</dd>
<dd class="note">The term is not intended to be used ever.</dd>
<dd class="source"><a href="#bib-smpte-standards-operations-manual"></a></dd>
<dt><dfn>Medium</dfn></dt>
<dd>something that is not large as defined in <a href="#bib-smpte-standards-operations-manual"></a></dd>
</dl>
</section>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@
<dd>something that is clean</dd>
<dd class="note">The term shall not be used to refer to clarity of mind.</dd>
<dd class="note">The term is not intended to be used ever.</dd>
<dd><a href="#bib-smpte-standards-operations-manual"></a></dd>
<dd class="source"><a href="#bib-smpte-standards-operations-manual"></a></dd>
<dt><dfn>Medium</dfn></dt>
<dd>something that is not large as defined in <a href="#bib-smpte-standards-operations-manual"></a></dd>
</dl>
<dd class="source"><a href="#bib-smpte-standards-operations-manual"></a> - changes meaning based on context</dd>
</section>
</body>
</html>
2 changes: 1 addition & 1 deletion test/resources/html/validation/terms-valid.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<dt>CLR</dt>
<dd>When something is clean</dd>
<dd class="note">The term shall not be used to refer to clarity of mind.</dd>
<dd><a href="#bib-smpte-standards-operations-manual"></a></dd>
<dd class="source"><a href="#bib-smpte-standards-operations-manual"></a></dd>
</dl>
</section>
</body>
Expand Down
Loading