From e2bec7a3881513b0a02d034d9d6badd2989fc671 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Fri, 8 Nov 2024 14:47:34 -0800 Subject: [PATCH] move copyright/metadata --- css/print.css | 1 + js/print.js | 31 ----------------------------- src/Spec.ts | 54 +++++++++++++++++++++++++++++++++++---------------- 3 files changed, 38 insertions(+), 48 deletions(-) diff --git a/css/print.css b/css/print.css index 12e558b0..7c772636 100644 --- a/css/print.css +++ b/css/print.css @@ -245,6 +245,7 @@ emu-production, emu-figure:has(> figure > img) figure, #metadata-block { break-inside: avoid; + border: unset; } p:has(+ .math-display), diff --git a/js/print.js b/js/print.js index b151fcb5..237ddbcb 100644 --- a/js/print.js +++ b/js/print.js @@ -13,8 +13,6 @@ const specContainer = document.getElementById('spec-container'); const shortname = specContainer.querySelector('h1.shortname'); const version = specContainer.querySelector('h1.version'); -const title = specContainer.querySelector('h1.title'); -const year = version.getAttribute('data-year'); rearrangeTables(); @@ -25,22 +23,6 @@ PDF.title = document.title; PDF.author = 'Ecma International'; PDF.subject = shortname.innerHTML + ', ' + version.innerHTML; -Prince.registerPostLayoutFunc(() => { - /** - * Specific modifications for Ecma standards that don't apply to other - * usages of ecmarkup. In case idk a proposal has the need to publish a PDF. - * */ - if (/ECMA-/.test(shortname.innerHTML)) { - const metadataBlock = document.getElementById('metadata-block'); - const intro = document.getElementsByTagName('emu-intro')[0]; - const scope = document.getElementById('scope') || document.getElementById('sec-scope'); - - intro.parentNode.insertBefore(generateEcmaCopyrightPage(), scope); - intro.appendChild(metadataBlock); - specContainer.insertBefore(title.cloneNode(true), scope); - } -}); - /** * Sets up table captions and figcaptions for tables, which provides for * continuation table captions. @@ -61,19 +43,6 @@ function rearrangeTables() { }); } - -function generateEcmaCopyrightPage() { - const copyrightNotice = document.createElement('div'); - - copyrightNotice.classList.add('copyright-notice'); - copyrightNotice.innerHTML = - '

COPYRIGHT NOTICE

\n\n

© ' + - year + - ' Ecma International

\n\n

This document may be copied, published and distributed to others, and certain derivative works of it may be prepared, copied, published, and distributed, in whole or in part, provided that the above copyright notice and this Copyright License and Disclaimer are included on all such copies and derivative works. The only derivative works that are permissible under this Copyright License and Disclaimer are:

\n\n

(i) works which incorporate all or portion of this document for the purpose of providing commentary or explanation (such as an annotated version of the document),

\n\n

(ii) works which incorporate all or portion of this document for the purpose of incorporating features that provide accessibility,

\n\n

(iii) translations of this document into languages other than English and into different formats and

\n\n

(iv) works by making use of this specification in standard conformant products by implementing (e.g. by copy and paste wholly or partly) the functionality therein.

\n\n

However, the content of this document itself may not be modified in any way, including by removing the copyright notice or references to Ecma International, except as required to translate it into languages other than English or into a different format.

\n\n

The official version of an Ecma International document is the English language version on the Ecma International website. In the event of discrepancies between a translated version and the official version, the official version shall govern.

\n\n

The limited permissions granted above are perpetual and will not be revoked by Ecma International or its successors or assigns.

\n\n

This document and the information contained herein is provided on an “AS IS” basis and ECMA INTERNATIONAL DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.

'; - - return copyrightNotice; -} - /** * @typedef {Object} PrinceBox * @property {string} type diff --git a/src/Spec.ts b/src/Spec.ts index 8157eac0..18c92f6d 100644 --- a/src/Spec.ts +++ b/src/Spec.ts @@ -592,7 +592,16 @@ export default class Spec { const wrapper = this.buildSpecWrapper(); if (this.opts.printable) { - this.log('Building covers...'); + this.log('Building covers and applying other print tweaks...'); + const metadataEle = this.doc.querySelector('#metadata-block'); + if (metadataEle) { + this.doc.querySelector('emu-intro')!.appendChild(metadataEle); + } + const scopeEle = document.getElementById('scope') ?? document.getElementById('sec-scope'); + if (!scopeEle) { + throw new Error('--printable requires a scope'); + } + scopeEle.before(this.doc.querySelector('h1.title')!.cloneNode(true)); // front cover const frontCover = document.createElement('div'); @@ -620,6 +629,8 @@ export default class Spec { insideCover.innerHTML = '

Ecma International
Rue du Rhone 114 CH-1204 Geneva
Tel: +41 22 849 6000
Fax: +41 22 849 6001
Web: https://www.ecma-international.org
Ecma is the registered trademark of Ecma International.

'; frontCover.after(insideCover); + + } let commonEles: HTMLElement[] = []; @@ -1416,7 +1427,29 @@ ${this.opts.multipage ? `
  • Navigate to/from multipagem { + if (last) return false; + if (node.nodeName === 'EMU-CLAUSE' || node.nodeName === 'EMU-ANNEX') { + last = node as HTMLElement; + return false; + } + }); + + if (last && last.parentNode) { + last.parentNode.insertBefore(copyrightClause, last.nextSibling); + } else { + this.doc.body.appendChild(copyrightClause); + } + } } } @@ -1561,23 +1594,8 @@ ${this.opts.multipage ? `
  • Navigate to/from multipagem { - if (last) return false; - if (node.nodeName === 'EMU-CLAUSE' || node.nodeName === 'EMU-ANNEX') { - last = node as HTMLElement; - return false; - } - }); - copyrightClause = this.doc.createElement('emu-annex'); copyrightClause.setAttribute('id', 'sec-copyright-and-software-license'); - - if (last && last.parentNode) { - last.parentNode.insertBefore(copyrightClause, last.nextSibling); - } else { - this.doc.body.appendChild(copyrightClause); - } } copyrightClause.setAttribute('back-matter', ''); @@ -1589,6 +1607,8 @@ ${this.opts.multipage ? `
  • Navigate to/from multipagemSoftware License ${license} `; + + return copyrightClause; } private generateSDOMap() {