Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions css/print.css
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ emu-table td,
pre,
h1,
emu-production,
emu-figure:has(> figure > img) figure,
emu-figure,
#metadata-block {
break-inside: avoid;
border: unset;
Expand Down Expand Up @@ -476,7 +476,7 @@ table > figcaption {
caption-side: top;
color: #000;
font-weight: bold;
margin-bottom: 1rem;
margin-bottom: 0.5lh;
text-align: center;
}

Expand All @@ -489,6 +489,15 @@ table:not(:has(tr:nth-of-type(5))) {
break-inside: avoid-page;
}

table tr:first-of-type,
table tr:nth-of-type(2) {
break-after: avoid;
}

table tr:last-of-type {
break-before: avoid;
}

/* This inheritance looks weird—it's due to how Prince manages continuity in tables across pages */
table > figcaption {
display: table-caption;
Expand Down Expand Up @@ -523,6 +532,16 @@ emu-figure img {
height: auto;
}

figure figcaption {
color: var(--black);
text-align: center;
}

emu-figure figcaption,
emu-table figcaption {
margin-bottom: 0.5lh;
}

.attributes-tag {
break-before: avoid-page;
break-after: avoid-page;
Expand Down
7 changes: 7 additions & 0 deletions src/Clause.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ export default class Clause extends Builder {
parentNamespace = parent.namespace;
}

// Reset figure numbering for each Annex
if (this.isAnnex && !this.parentClause) {
spec._figureCounts.figure = 0;
spec._figureCounts.table = 0;
spec._figurePrefix = `${number}.`;
}
Comment on lines +114 to +119

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks the rendering of <emu-xref>, e.g. "The entries in Table 103 are added to Table 6" at B.2.1 Additional Properties of the Global Object becomes "The entries in Table 1 are added to Table 6" rather than "The entries in Table B.1 are added to Table 6".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seemed like a suspiciously easy fix. The figure biblio entries expect a number or a string, so I modified the prefix to be added at that point in the figure generation.


if (node.hasAttribute('namespace')) {
this.namespace = node.getAttribute('namespace')!;
spec.biblio.createNamespace(this.namespace, parentNamespace);
Expand Down
18 changes: 12 additions & 6 deletions src/Figure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Builder from './Builder';

export default class Figure extends Builder {
type: string;
number: number;
number: number | string;
id: string | null;
isInformative: boolean;
captionElem: HTMLElement | null;
Expand All @@ -16,21 +16,21 @@ export default class Figure extends Builder {
constructor(spec: Spec, node: HTMLElement) {
super(spec, node);
this.type = node.nodeName.split('-')[1].toLowerCase();
this.number = ++spec._figureCounts[this.type];
this.number = `${spec._figurePrefix}${++spec._figureCounts[this.type]}`;
this.id = node.getAttribute('id');

this.isInformative = node.hasAttribute('informative');
this.captionElem = node.querySelector('emu-caption');
this.caption = this.type.charAt(0).toUpperCase() + this.type.slice(1) + ' ' + this.number;
this.caption = `${this.type.charAt(0).toUpperCase()}${this.type.slice(1)} ${this.number}`;

if (this.isInformative) {
this.caption += ' (Informative)';
}

if (this.captionElem) {
this.caption += ': ' + this.captionElem.innerHTML;
this.caption += ' \u2014 ' + this.captionElem.innerHTML;
} else if (node.getAttribute('caption')) {
this.caption += ': ' + node.getAttribute('caption');
this.caption += ' \u2014 ' + node.getAttribute('caption');
}

if (this.id) {
Expand Down Expand Up @@ -60,6 +60,12 @@ export default class Figure extends Builder {

const captionElem = spec.doc.createElement('figcaption');
captionElem.innerHTML = figure.caption;
node.childNodes[0].insertBefore(captionElem, node.childNodes[0].firstChild);

// Captions go below figures but above tables etc. (per Ecma house style)
if (node.nodeName === 'EMU-FIGURE') {
ele.appendChild(captionElem);
} else {
ele.insertBefore(captionElem, ele.firstChild);
}
}
}
2 changes: 2 additions & 0 deletions src/Spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ export default class Spec {
readonly log: (msg: string) => void;
readonly warn: (err: Warning) => void | undefined;

/** @internal */ _figurePrefix: string;
/** @internal */ _figureCounts: { [type: string]: number };
/** @internal */ _xrefs: Xref[];
/** @internal */ _ntRefs: NonTerminal[];
Expand Down Expand Up @@ -377,6 +378,7 @@ export default class Spec {
table: 0,
figure: 0,
};
this._figurePrefix = '';
this._xrefs = [];
this._ntRefs = [];
this._ntStringRefs = [];
Expand Down
2 changes: 1 addition & 1 deletion test/baselines/generated-reference/abstract-methods.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 21 additions & 2 deletions test/baselines/generated-reference/assets-inline.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions test/baselines/generated-reference/duplicate-ids.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions test/baselines/generated-reference/figure.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/baselines/generated-reference/internal-methods.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions test/baselines/generated-reference/xref.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading