diff --git a/css/print.css b/css/print.css
index a4f6180b..8bc3a18e 100644
--- a/css/print.css
+++ b/css/print.css
@@ -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;
@@ -476,7 +476,7 @@ table > figcaption {
caption-side: top;
color: #000;
font-weight: bold;
- margin-bottom: 1rem;
+ margin-bottom: 0.5lh;
text-align: center;
}
@@ -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;
@@ -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;
diff --git a/src/Clause.ts b/src/Clause.ts
index 842b7a1d..cb5349c0 100644
--- a/src/Clause.ts
+++ b/src/Clause.ts
@@ -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}.`;
+ }
+
if (node.hasAttribute('namespace')) {
this.namespace = node.getAttribute('namespace')!;
spec.biblio.createNamespace(this.namespace, parentNamespace);
diff --git a/src/Figure.ts b/src/Figure.ts
index 292a6c37..76313a46 100644
--- a/src/Figure.ts
+++ b/src/Figure.ts
@@ -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;
@@ -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) {
@@ -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);
+ }
}
}
diff --git a/src/Spec.ts b/src/Spec.ts
index 0d5325d6..b6ba7238 100644
--- a/src/Spec.ts
+++ b/src/Spec.ts
@@ -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[];
@@ -377,6 +378,7 @@ export default class Spec {
table: 0,
figure: 0,
};
+ this._figurePrefix = '';
this._xrefs = [];
this._ntRefs = [];
this._ntStringRefs = [];
diff --git a/test/baselines/generated-reference/abstract-methods.html b/test/baselines/generated-reference/abstract-methods.html
index c19532c1..4fccd9bc 100644
--- a/test/baselines/generated-reference/abstract-methods.html
+++ b/test/baselines/generated-reference/abstract-methods.html
@@ -17,7 +17,7 @@
Always single-page
Always multi-page
-
Table 1: Abstract Methods of Module Record
+Table 1 — Abstract Methods of Module Record
diff --git a/test/baselines/generated-reference/assets-inline.html b/test/baselines/generated-reference/assets-inline.html
index 3181389c..d84299b2 100644
--- a/test/baselines/generated-reference/assets-inline.html
+++ b/test/baselines/generated-reference/assets-inline.html
@@ -3623,7 +3623,7 @@
pre,
h1,
emu-production,
-emu-figure:has(> figure > img) figure,
+emu-figure,
#metadata-block {
break-inside: avoid;
border: unset;
@@ -3830,7 +3830,7 @@
caption-side: top;
color: #000;
font-weight: bold;
- margin-bottom: 1rem;
+ margin-bottom: 0.5lh;
text-align: center;
}
@@ -3843,6 +3843,15 @@
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;
@@ -3877,6 +3886,16 @@
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;
diff --git a/test/baselines/generated-reference/duplicate-ids.html b/test/baselines/generated-reference/duplicate-ids.html
index d5369f50..0ab286ad 100644
--- a/test/baselines/generated-reference/duplicate-ids.html
+++ b/test/baselines/generated-reference/duplicate-ids.html
@@ -31,7 +31,7 @@ 1.1 Sub A
2 Section A: Extras
- Table 1 (Informative): A Table Of Stuff
+ Table 1 (Informative) — A Table Of Stuff
Column 1 Column 2
Value Value 2
@@ -42,7 +42,7 @@ 2 Section A: Extras
3 Section A: Extras
- Table 2 (Informative): A Table Of Stuff
+ Table 2 (Informative) — A Table Of Stuff
Column 1 Column 2
Value Value 2
diff --git a/test/baselines/generated-reference/figure.html b/test/baselines/generated-reference/figure.html
index b482387a..8084bfb6 100644
--- a/test/baselines/generated-reference/figure.html
+++ b/test/baselines/generated-reference/figure.html
@@ -18,16 +18,16 @@
Always multi-page
-
Figure 1
+
this is a figure!
-
+Figure 1
-
Figure 2 (Informative): Informative figure
+
this is a figure!
-
+Figure 2 (Informative) — Informative figure
-
Table 1: An example table
+Table 1 — An example table
Column 1 Column 2
@@ -39,7 +39,7 @@
-Table 2 (Informative): An example table 2
+Table 2 (Informative) — An example table 2
Column 1 Column 2
Value Value 2
@@ -49,12 +49,12 @@
-Figure 3 (Informative): This is the caption
+
this is a figure!
-
+Figure 3 (Informative) — This is the caption
-Table 3: This is a table
+Table 3 — This is a table
-Table 4 (Informative): This is a second table
+Table 4 (Informative) — This is a second table
Column 1 Column 2
diff --git a/test/baselines/generated-reference/internal-methods.html b/test/baselines/generated-reference/internal-methods.html
index 1707a985..c366d98c 100644
--- a/test/baselines/generated-reference/internal-methods.html
+++ b/test/baselines/generated-reference/internal-methods.html
@@ -17,7 +17,7 @@
Always single-page
Always multi-page
-
Table 1: Internal Methods of Object
+Table 1 — Internal Methods of Object
diff --git a/test/baselines/generated-reference/xref.html b/test/baselines/generated-reference/xref.html
index 70ae4005..cd510240 100644
--- a/test/baselines/generated-reference/xref.html
+++ b/test/baselines/generated-reference/xref.html
@@ -101,11 +101,11 @@ 1.1 AbstractOp
And a third!
- Figure 1
+
this is a figure!
-
+ Figure 1
- Table 1: An example table
+ Table 1 — An example table