@@ -422,6 +422,55 @@ function insertBibliography(docMetadata) {
422422 h2 . innerText = "Bibliography" ;
423423}
424424
425+ const SMPTE_ELEMENTS_ID = "sec-elements" ;
426+
427+ function insertElementsAnnex ( docMetadata ) {
428+ const sec = document . getElementById ( SMPTE_ELEMENTS_ID ) ;
429+
430+ if ( sec === null )
431+ return ;
432+
433+ if ( sec . children . length !== 1 || sec . firstElementChild . tagName !== "OL" ) {
434+ logEvent ( `Elements section must contain a single <ol> element.` ) ;
435+ return ;
436+ }
437+
438+ sec . classList . add ( "annex" ) ;
439+
440+ const intro = document . createElement ( "p" ) ;
441+ intro . innerText = "This annex lists non-prose elements of this document."
442+ sec . insertBefore ( intro , sec . firstChild ) ;
443+
444+ const h2 = document . createElement ( "h2" ) ;
445+ h2 . innerText = "Additional elements" ;
446+ sec . insertBefore ( h2 , sec . firstChild ) ;
447+
448+ let counter = "a" . charCodeAt ( ) ;
449+
450+ for ( const e of sec . querySelectorAll ( "li > a" ) ) {
451+
452+ const headingNum = document . createElement ( "span" ) ;
453+ headingNum . className = "heading-number" ;
454+ headingNum . innerText = String . fromCharCode ( counter ++ ) ;
455+
456+ const headingLabel = document . createElement ( "span" ) ;
457+ headingLabel . className = "heading-label" ;
458+ headingLabel . appendChild ( headingNum ) ;
459+ headingLabel . appendChild ( document . createTextNode ( "." ) ) ;
460+
461+ e . parentElement . insertBefore ( headingLabel , e ) ;
462+
463+ e . innerText = "(link)" ;
464+
465+ if ( e . title ) {
466+ e . parentElement . insertBefore ( document . createTextNode ( " " + e . title + " " ) , e ) ;
467+ } else {
468+ logEvent ( "All links listed in the Elements Annex must have a title attribute." )
469+ }
470+
471+ }
472+ }
473+
425474const SMPTE_CONFORMANCE_ID = "sec-conformance" ;
426475
427476function insertConformance ( docMetadata ) {
@@ -727,6 +776,47 @@ function numberNotes() {
727776 }
728777}
729778
779+ function numberElements ( ) {
780+ let counter = 1 ;
781+
782+ for ( let e of document . querySelectorAll ( "#sec-elements li" ) ) {
783+
784+ let numPrefix = "" ;
785+
786+ if ( section . classList . contains ( "annex" ) ) {
787+ counter = 1 ;
788+ numPrefix = section . querySelector ( ".heading-number" ) . innerText + "." ;
789+ }
790+
791+ for ( let figure of section . querySelectorAll ( "figure" ) ) {
792+
793+ const figcaption = figure . querySelector ( "figcaption" ) ;
794+
795+ if ( figcaption === null ) {
796+ logEvent ( `Figure is missing a caption` ) ;
797+ continue ;
798+ }
799+
800+ const headingLabel = document . createElement ( "span" ) ;
801+ headingLabel . className = "heading-label" ;
802+
803+ const headingNumberElement = document . createElement ( "span" ) ;
804+ headingNumberElement . className = "heading-number" ;
805+ headingNumberElement . innerText = numPrefix + counter ;
806+
807+ headingLabel . appendChild ( document . createTextNode ( "Figure " ) ) ;
808+ headingLabel . appendChild ( headingNumberElement ) ;
809+ headingLabel . appendChild ( document . createTextNode ( " – " ) ) ;
810+
811+
812+ figcaption . insertBefore ( headingLabel , figcaption . firstChild ) ;
813+
814+ counter ++ ;
815+ }
816+
817+ }
818+ }
819+
730820function numberExamples ( ) {
731821
732822 for ( let section of document . querySelectorAll ( "section" ) ) {
@@ -888,6 +978,11 @@ function resolveLinks(docMetadata) {
888978 anchor . innerText = targetNumber ;
889979 }
890980
981+ } else if ( target . parentElement . parentElement . parentElement . id === "sec-elements" ) {
982+ /* element */
983+
984+ anchor . innerText = "Element " + target . parentElement . querySelector ( ".heading-number" ) . innerText ;
985+
891986 } else {
892987 logEvent ( `Anchor points to ambiguous #${ target_id } ` )
893988 anchor . innerText = "????" ;
@@ -929,6 +1024,7 @@ function render() {
9291024 insertNormativeReferences ( docMetadata ) ;
9301025 insertTermsAndDefinitions ( docMetadata ) ;
9311026
1027+ insertElementsAnnex ( docMetadata ) ;
9321028 insertBibliography ( docMetadata ) ;
9331029 numberSections ( document . body , "" ) ;
9341030 numberTables ( ) ;
0 commit comments