Skip to content

Commit

Permalink
Markup: Fix lint issues that don't interfere with Prince
Browse files Browse the repository at this point in the history
  • Loading branch information
gesa committed Jun 14, 2024
1 parent 47d59b6 commit 0cf9b9a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
29 changes: 24 additions & 5 deletions js/print.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable no-undef */
'use strict';

Prince.trackBoxes = true;

const year = new Date().getFullYear();
Expand Down Expand Up @@ -86,7 +89,11 @@ function rebuildLi(li) {
* Generates link elements for table of contents items
* */
function renderTocLink(clauseID, clauseNumber, clauseTitle) {
const nonAnnexSections = ['sec-copyright-and-software-license', 'sec-colophon', 'sec-bibliography'];
const nonAnnexSections = [
'sec-copyright-and-software-license',
'sec-colophon',
'sec-bibliography',
];
const link = document.createElement('a');
link.setAttribute('href', '#' + clauseID);
link.setAttribute('title', clauseTitle);
Expand All @@ -99,7 +106,13 @@ function renderTocLink(clauseID, clauseNumber, clauseTitle) {

if (/^[A-Z]$/.test(clauseNumber)) {
const annexType = document.getElementById(clauseID).getAttribute('normative') || 'informative';
link.innerHTML = '<span class="secnum">Annex ' + clauseNumber + ' <span class="unbold">(' + annexType + ')</span></span> ' + clauseTitle;
link.innerHTML =
'<span class="secnum">Annex ' +
clauseNumber +
' <span class="unbold">(' +
annexType +
')</span></span> ' +
clauseTitle;

return link;
}
Expand All @@ -117,10 +130,15 @@ function renderTocLink(clauseID, clauseNumber, clauseTitle) {
* Loops through every clause/annex's h1 and improves the markup
* */
function improveSectionHeadings() {
// eslint-disable-next-line prettier/prettier
const sectionHeadings = Array.from(specContainer.querySelectorAll('emu-clause > h1, emu-annex > h1'));

/** these section IDs are emu-annex elements but not functionally annexes */
const nonAnnexSections = ["sec-copyright-and-software-license", 'sec-colophon', 'sec-bibliography']
const nonAnnexSections = [
'sec-copyright-and-software-license',
'sec-colophon',
'sec-bibliography',
];

sectionHeadings.forEach(h1 => {
const numElem = h1.firstChild;
Expand All @@ -135,7 +153,8 @@ function improveSectionHeadings() {
} else {
const annexType = parent.getAttribute('normative') || 'informative';

numElem.innerHTML = 'Annex ' + section + ' <br/><span class="unbold">(' + annexType + ')</span><br/>';
numElem.innerHTML =
'Annex ' + section + ' <br/><span class="unbold">(' + annexType + ')</span><br/>';
}
} else {
numElem.textContent = section;
Expand Down Expand Up @@ -217,7 +236,6 @@ function generateInsideCover() {
function generateEcmaCopyrightPage() {
const copyrightNotice = document.createElement('div');


copyrightNotice.classList.add('copyright-notice');
copyrightNotice.innerHTML =
'<p>COPYRIGHT NOTICE</p>\n\n<p>© ' +
Expand All @@ -233,6 +251,7 @@ function generateEcmaCopyrightPage() {
function ecma262fixes() {
const toc = document.getElementById('toc');

// eslint-disable-next-line prettier/prettier
specContainer.insertBefore(document.getElementById('sec-bibliography'), document.getElementById('sec-colophon'));
Array.from(toc.getElementsByTagName('a')).forEach(anchor => {
if (anchor.getAttribute('href') === '#sec-colophon') {
Expand Down
3 changes: 2 additions & 1 deletion src/Spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,8 @@ ${await utils.readFile(path.join(__dirname, '../js/multipage.js'))}
this.doc.head,
`https://cdnjs.cloudflare.com/ajax/libs/highlight.js/${
(hljs as any).versionString
}/styles/base16/solarized-light.min.css`);
}/styles/base16/solarized-light.min.css`,
);
}

private addStyle(head: HTMLHeadElement, href: string, media?: 'all' | 'print' | 'screen') {
Expand Down

0 comments on commit 0cf9b9a

Please sign in to comment.