Skip to content

Commit 8365bb7

Browse files
committed
figures in terms
1 parent dca1e12 commit 8365bb7

File tree

3 files changed

+78
-1
lines changed

3 files changed

+78
-1
lines changed

js/validate.mjs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,22 @@ class DefinitionNoteMatcher {
270270
}
271271
}
272272

273+
class DefinitionFigureMatcher {
274+
static match(element, logger) {
275+
if (element.localName !== "dd" || !element.classList.contains("figure"))
276+
return false;
277+
278+
// Must contain exactly one figure child
279+
const children = Array.from(element.children);
280+
if (children.length !== 1 || children[0].localName !== "figure") {
281+
logger.error(`Definition figure must contain a single figure element`, element);
282+
return true;
283+
}
284+
285+
return true;
286+
}
287+
}
288+
273289

274290
class UlMatcher {
275291
static match(element, logger) {
@@ -658,6 +674,12 @@ class InternalDefinitionsMatcher {
658674
count++;
659675
}
660676

677+
/* look for definition figure */
678+
679+
if (children.length > 0 && DefinitionFigureMatcher.match(children[0], logger)) {
680+
children.shift();
681+
}
682+
661683
}
662684

663685
return true;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<!doctype html>
2+
<html>
3+
<head itemscope="itemscope" itemtype="http://smpte.org/standards/documents">
4+
<meta charset="utf-8" />
5+
<meta http-equiv="x-ua-compatible" content="ie=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<script type="module" src="../../../../smpte.js"></script>
8+
<meta itemprop="test" content="invalid" />
9+
<meta itemprop="pubType" content="AG" />
10+
<meta itemprop="pubNumber" content="99" />
11+
<meta itemprop="pubState" content="draft" />
12+
<title>Title of the document</title>
13+
</head>
14+
<body>
15+
<section id="sec-scope">
16+
<p>This is the scope of the document.</p>
17+
</section>
18+
19+
<section id="sec-normative-references">
20+
<ul>
21+
<li>
22+
<cite id="bib-smpte-standards-operations-manual">SMPTE OM</cite></li>
23+
</ul>
24+
</section>
25+
26+
<section id="sec-terms-and-definitions">
27+
<ul id="terms-ext-defs">
28+
<li><a href="#bib-smpte-standards-operations-manual"></a></li>
29+
</ul>
30+
<dl id="terms-int-defs">
31+
<dt><dfn>Clear</dfn></dt>
32+
<dt>CLR</dt>
33+
<dd>When something is clean</dd>
34+
<dd><a href="#bib-smpte-standards-operations-manual"></a></dd>
35+
<dd class="note">The term shall not be used to refer to clarity of mind, see <a href="#figure-1"></a> and <a href="#figure-2"><</a>.</dd>
36+
<dd class="figure">
37+
<figure id="figure-1">
38+
<img src="../../../../doc/media/sample.png">
39+
<figcaption>This figure show an example</figcaption>
40+
</figure>
41+
<figure id="figure-2">
42+
<img src="../../../../doc/media/sample.png">
43+
<figcaption>This figure show an example</figcaption>
44+
</figure>
45+
</dd>
46+
</dl>
47+
</section>
48+
</body>
49+
</html>

test/resources/html/validation/terms-valid.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@
3232
<dt>CLR</dt>
3333
<dd>When something is clean</dd>
3434
<dd><a href="#bib-smpte-standards-operations-manual"></a></dd>
35-
<dd class="note">The term shall not be used to refer to clarity of mind.</dd>
35+
<dd class="note">The term shall not be used to refer to clarity of mind, see <a href="#figure-1"></a>.</dd>
36+
<dd class="figure">
37+
<figure id="figure-1">
38+
<img src="../../../../doc/media/sample.png">
39+
<figcaption>This figure show an example</figcaption>
40+
</figure>
41+
</dd>
3642
</dl>
3743
</section>
3844
</body>

0 commit comments

Comments
 (0)