Skip to content

Commit 69284f5

Browse files
committed
swp to DOI for refs
1 parent 296b925 commit 69284f5

3 files changed

Lines changed: 42 additions & 3 deletions

File tree

doc/main.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -564,14 +564,16 @@ <h4>Normative references section</h4>
564564
<li>The <code>cite</code> element shall contain an <code>id</code> attribute with value prefixed by
565565
<code>bib-</code>.</li>
566566
<li>Each <code>li</code> element may contain additional title information.
567+
567568
<li>Each <code>li</code> element may contain one <code>a</code> element that contains a location where the reference can
568569
be retrieved.</li>
570+
<li>Each <code>li</code> element may contain one <code>span</code> element with a <code>class="doi"</code> attribute that contains the DOI of the document. Using this will also create a DOI resolver URL.</li>
569571
</ul>
570572
<p>Undated references should be used, since they point to the most most up-to-date edition of a document.</p>
571573

572574
<p>Dated references shall be used when referencing a specific element of the document, e.g., a table. They should also be used when past and future editions of the document are likely to be inadequate. </p>
573575

574-
<p class="note">DOI links should be used for both the most recent and specific editions of a SMPTE document. SMPTE HO can provide guidance for specific DOIs available.</p>
576+
<p class="note">The DOI <code>span</code> element should be used, and not the <code>a</code> element, for both the most recent and specific editions of a SMPTE document. SMPTE HO can provide guidance for specific DOIs available.</p>
575577

576578
<div class="example">
577579
<pre>&lt;section id=&quot;sec-normative-references&quot;&gt;
@@ -583,12 +585,12 @@ <h4>Normative references section</h4>
583585
&lt;li&gt;
584586
&lt;cite id=&quot;bib-SMPTE-st429-18&quot;&gt;SMPTE ST 429-18&lt;/cite&gt;, D-Cinema Packaging — Immersive Audio Track
585587
File
586-
&lt;a&gt;https://doi.org/10.5594/SMPTE.ST429-18/&lt;/a&gt;&lt;/li&gt;
588+
&lt;span class=&quot;doi&quot;&gt;10.5594/SMPTE.ST429-18/&lt;/span&gt;&lt;/li&gt;
587589
&lt;/li&gt;
588590
&lt;li&gt;
589591
&lt;cite id=&quot;bib-SMPTE-st429-18-2023&quot;&gt;SMPTE ST 429-18:2023&lt;/cite&gt;, D-Cinema Packaging — Immersive
590592
Audio Track File (2023 Edition)
591-
&lt;a&gt;https://doi.org/10.5594/SMPTE.ST429-18.2023/&lt;/a&gt;&lt;/li&gt;
593+
&lt;span class=&quot;doi&quot;&gt;10.5594/SMPTE.ST429-18.2023/&lt;/span&gt;&lt;/li&gt;
592594
&lt;/li&gt;
593595
&lt;/ul&gt;
594596
&lt;/section&gt;</pre>
@@ -2398,6 +2400,7 @@ <h3>Sample Workflow </h3>
23982400
<a>https://doc.smpte-doc.org/ag-16/main/</a></li>
23992401
<li><cite id="bib-smpte-gh-om">SMPTE GitHub Operating Manual</cite>
24002402
<a>https://github.com/SMPTE/github-operating-manual</a></li>
2403+
24012404
</ul>
24022405
</section>
24032406

js/validate.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ class ReferenceMatcher {
543543

544544
let aCount = 0;
545545
let citeCount = 0;
546+
let doiCount = 0;
546547

547548
for (const child of element.children) {
548549
if (child.localName === "a") {
@@ -551,6 +552,8 @@ class ReferenceMatcher {
551552
if (child.id === null)
552553
logger.error(`All cite element must have an id attribute`, child);
553554
citeCount++;
555+
} else if (child.matches("span.doi")) {
556+
doiCount++;
554557
}
555558
}
556559

@@ -560,6 +563,9 @@ class ReferenceMatcher {
560563
if (citeCount !== 1)
561564
logger.error(`Reference element must contain exactly one cite element`, element);
562565

566+
if (doiCount > 1)
567+
logger.error(`Reference element must contain at most one DOI`, element);
568+
563569
return true;
564570
}
565571
}

smpte.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,21 @@ function insertNormativeReferences(docMetadata) {
453453

454454
h2.innerText = "Normative references";
455455

456+
/* style DOIs */
457+
458+
for (const doi of sec.querySelectorAll("ul span.doi")) {
459+
doi.parentNode.insertBefore(document.createElement("br"), doi);
460+
doi.parentNode.insertBefore(document.createTextNode("doi:\u00a0"), doi);
461+
462+
const prefix = "https://doi.org/";
463+
const url = prefix + doi.textContent.trim();
464+
465+
const label = document.createTextNode("url:\u00a0");
466+
const link = document.createElement("a");
467+
link.textContent = url;
468+
doi.parentNode.insertBefore(link, label.nextSibling);
469+
}
470+
456471
/* style URLs */
457472

458473
for(const u of sec.querySelectorAll("ul a")) {
@@ -542,6 +557,21 @@ function insertBibliography(docMetadata) {
542557

543558
h2.innerText = "Bibliography";
544559

560+
/* style DOIs */
561+
562+
for (const doi of sec.querySelectorAll("ul span.doi")) {
563+
doi.parentNode.insertBefore(document.createElement("br"), doi);
564+
doi.parentNode.insertBefore(document.createTextNode("doi:\u00a0"), doi);
565+
566+
const prefix = "https://doi.org/";
567+
const url = prefix + doi.textContent.trim();
568+
569+
const label = document.createTextNode("url:\u00a0");
570+
const link = document.createElement("a");
571+
link.textContent = url;
572+
doi.parentNode.insertBefore(link, label.nextSibling);
573+
}
574+
545575
/* style links */
546576

547577
for(const u of sec.querySelectorAll("ul a")) {

0 commit comments

Comments
 (0)