From 20404de75535ea185ff29574a96be5f524a0993a Mon Sep 17 00:00:00 2001 From: Jiminy Panoz Date: Mon, 23 Nov 2026 17:53:49 +0100 Subject: [PATCH 1/8] Read descriptions before content --- .../utterances.json | 56 ++-- .../utterances.json | 12 +- .../figure-aria-label-caption/utterances.json | 28 +- .../utterances.json | 260 +++++++++--------- fixtures/figure-describedby/utterances.json | 28 +- .../utterances.json | 96 +++---- .../utterances.json | 48 ++-- src/utterances/roles.ts | 4 +- src/utterances/walk.ts | 21 +- 9 files changed, 271 insertions(+), 282 deletions(-) diff --git a/fixtures/description-roleless-lone-child/utterances.json b/fixtures/description-roleless-lone-child/utterances.json index 309f580a..951d09e8 100644 --- a/fixtures/description-roleless-lone-child/utterances.json +++ b/fixtures/description-roleless-lone-child/utterances.json @@ -8,10 +8,10 @@ ], "utterances": [ { - "plain": "One." + "plain": "Sidebar" }, { - "plain": "Sidebar" + "plain": "One." } ] }, @@ -105,10 +105,10 @@ "language": "en" }, { - "plain": "One." + "plain": "Sidebar" }, { - "plain": "Sidebar" + "plain": "One." }, { "plain": "End of the list.", @@ -152,10 +152,10 @@ "plain": "Start of the list." }, { - "plain": "One." + "plain": "Sidebar" }, { - "plain": "Sidebar" + "plain": "One." }, { "plain": "End of the list." @@ -252,10 +252,10 @@ "language": "en" }, { - "plain": "One." + "plain": "Sidebar" }, { - "plain": "Sidebar" + "plain": "One." } ] }, @@ -295,10 +295,10 @@ "plain": "List item." }, { - "plain": "One." + "plain": "Sidebar" }, { - "plain": "Sidebar" + "plain": "One." } ] }, @@ -405,10 +405,10 @@ "language": "en" }, { - "plain": "One." + "plain": "Sidebar" }, { - "plain": "Sidebar" + "plain": "One." }, { "plain": "End of the list.", @@ -458,10 +458,10 @@ "plain": "List item." }, { - "plain": "One." + "plain": "Sidebar" }, { - "plain": "Sidebar" + "plain": "One." }, { "plain": "End of the list." @@ -476,10 +476,10 @@ ], "utterances": [ { - "ssml": "One." + "ssml": "Sidebar" }, { - "ssml": "Sidebar" + "ssml": "One." } ] }, @@ -573,10 +573,10 @@ "language": "en" }, { - "ssml": "One." + "ssml": "Sidebar" }, { - "ssml": "Sidebar" + "ssml": "One." }, { "ssml": "End of the list.", @@ -620,10 +620,10 @@ "ssml": "Start of the list." }, { - "ssml": "One." + "ssml": "Sidebar" }, { - "ssml": "Sidebar" + "ssml": "One." }, { "ssml": "End of the list." @@ -720,10 +720,10 @@ "language": "en" }, { - "ssml": "One." + "ssml": "Sidebar" }, { - "ssml": "Sidebar" + "ssml": "One." } ] }, @@ -763,10 +763,10 @@ "ssml": "List item." }, { - "ssml": "One." + "ssml": "Sidebar" }, { - "ssml": "Sidebar" + "ssml": "One." } ] }, @@ -873,10 +873,10 @@ "language": "en" }, { - "ssml": "One." + "ssml": "Sidebar" }, { - "ssml": "Sidebar" + "ssml": "One." }, { "ssml": "End of the list.", @@ -926,10 +926,10 @@ "ssml": "List item." }, { - "ssml": "One." + "ssml": "Sidebar" }, { - "ssml": "Sidebar" + "ssml": "One." }, { "ssml": "End of the list." diff --git a/fixtures/description-roleless-wrapper/utterances.json b/fixtures/description-roleless-wrapper/utterances.json index 11de356d..47e9bee0 100644 --- a/fixtures/description-roleless-wrapper/utterances.json +++ b/fixtures/description-roleless-wrapper/utterances.json @@ -8,13 +8,13 @@ ], "utterances": [ { - "plain": "One." + "plain": "Sidebar" }, { - "plain": "Two." + "plain": "One." }, { - "plain": "Sidebar" + "plain": "Two." } ] }, @@ -26,13 +26,13 @@ ], "utterances": [ { - "ssml": "One." + "ssml": "Sidebar" }, { - "ssml": "Two." + "ssml": "One." }, { - "ssml": "Sidebar" + "ssml": "Two." } ] } diff --git a/fixtures/figure-aria-label-caption/utterances.json b/fixtures/figure-aria-label-caption/utterances.json index cd1fc779..fbab5850 100644 --- a/fixtures/figure-aria-label-caption/utterances.json +++ b/fixtures/figure-aria-label-caption/utterances.json @@ -8,10 +8,10 @@ ], "utterances": [ { - "plain": "A cat" + "plain": "A cat face" }, { - "plain": "A cat face" + "plain": "A cat" } ] }, @@ -235,11 +235,11 @@ ], "utterances": [ { - "plain": "Image with a label: A cat", - "language": "en" + "plain": "A cat face" }, { - "plain": "A cat face" + "plain": "Image with a label: A cat", + "language": "en" } ] }, @@ -276,10 +276,10 @@ ], "utterances": [ { - "plain": "Image with a label: A cat" + "plain": "A cat face" }, { - "plain": "A cat face" + "plain": "Image with a label: A cat" } ] }, @@ -2187,10 +2187,10 @@ ], "utterances": [ { - "ssml": "A cat" + "ssml": "A cat face" }, { - "ssml": "A cat face" + "ssml": "A cat" } ] }, @@ -2414,11 +2414,11 @@ ], "utterances": [ { - "ssml": "Image with a label: A cat", - "language": "en" + "ssml": "A cat face" }, { - "ssml": "A cat face" + "ssml": "Image with a label: A cat", + "language": "en" } ] }, @@ -2455,10 +2455,10 @@ ], "utterances": [ { - "ssml": "Image with a label: A cat" + "ssml": "A cat face" }, { - "ssml": "A cat face" + "ssml": "Image with a label: A cat" } ] }, diff --git a/fixtures/figure-credit-nested-in-aria-labelledby-caption/utterances.json b/fixtures/figure-credit-nested-in-aria-labelledby-caption/utterances.json index 07a72de8..7aebf677 100644 --- a/fixtures/figure-credit-nested-in-aria-labelledby-caption/utterances.json +++ b/fixtures/figure-credit-nested-in-aria-labelledby-caption/utterances.json @@ -8,13 +8,13 @@ ], "utterances": [ { - "plain": "A metal-edged case with a red textured front panel." + "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" }, { - "plain": "Photo: Science Museum London, CC BY-SA 2.0." + "plain": "A metal-edged case with a red textured front panel." }, { - "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + "plain": "Photo: Science Museum London, CC BY-SA 2.0." } ] }, @@ -243,15 +243,15 @@ } ], "utterances": [ + { + "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "plain": "Image with a label: A metal-edged case with a red textured front panel.", "language": "en" }, { "plain": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -288,13 +288,13 @@ ], "utterances": [ { - "plain": "Image with a label: A metal-edged case with a red textured front panel." + "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" }, { - "plain": "Photo: Science Museum London, CC BY-SA 2.0." + "plain": "Image with a label: A metal-edged case with a red textured front panel." }, { - "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + "plain": "Photo: Science Museum London, CC BY-SA 2.0." } ] }, @@ -536,6 +536,9 @@ } ], "utterances": [ + { + "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "plain": "A metal-edged case with a red textured front panel." }, @@ -545,9 +548,6 @@ }, { "plain": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -583,6 +583,9 @@ } ], "utterances": [ + { + "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "plain": "A metal-edged case with a red textured front panel." }, @@ -591,9 +594,6 @@ }, { "plain": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -850,6 +850,9 @@ } ], "utterances": [ + { + "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "plain": "Image with a label: A metal-edged case with a red textured front panel.", "language": "en" @@ -860,9 +863,6 @@ }, { "plain": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -901,6 +901,9 @@ } ], "utterances": [ + { + "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "plain": "Image with a label: A metal-edged case with a red textured front panel." }, @@ -909,9 +912,6 @@ }, { "plain": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -1172,6 +1172,9 @@ } ], "utterances": [ + { + "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "plain": "A metal-edged case with a red textured front panel." }, @@ -1181,9 +1184,6 @@ }, { "plain": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -1219,6 +1219,9 @@ } ], "utterances": [ + { + "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "plain": "A metal-edged case with a red textured front panel." }, @@ -1227,9 +1230,6 @@ }, { "plain": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -1486,6 +1486,9 @@ } ], "utterances": [ + { + "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "plain": "Image with a label: A metal-edged case with a red textured front panel.", "language": "en" @@ -1496,9 +1499,6 @@ }, { "plain": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -1537,6 +1537,9 @@ } ], "utterances": [ + { + "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "plain": "Image with a label: A metal-edged case with a red textured front panel." }, @@ -1545,9 +1548,6 @@ }, { "plain": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -1817,6 +1817,9 @@ } ], "utterances": [ + { + "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "plain": "A metal-edged case with a red textured front panel." }, @@ -1830,9 +1833,6 @@ }, { "plain": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -1871,6 +1871,9 @@ } ], "utterances": [ + { + "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "plain": "A metal-edged case with a red textured front panel." }, @@ -1882,9 +1885,6 @@ }, { "plain": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -2169,6 +2169,9 @@ } ], "utterances": [ + { + "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "plain": "Image with a label: A metal-edged case with a red textured front panel.", "language": "en" @@ -2183,9 +2186,6 @@ }, { "plain": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -2227,6 +2227,9 @@ } ], "utterances": [ + { + "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "plain": "Image with a label: A metal-edged case with a red textured front panel." }, @@ -2238,9 +2241,6 @@ }, { "plain": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -7867,10 +7867,10 @@ ], "utterances": [ { - "plain": "Photo: Science Museum London, CC BY-SA 2.0." + "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" }, { - "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + "plain": "Photo: Science Museum London, CC BY-SA 2.0." } ] }, @@ -8430,15 +8430,15 @@ } ], "utterances": [ + { + "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "plain": "Caption.", "language": "en" }, { "plain": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -8524,13 +8524,13 @@ ], "utterances": [ { - "plain": "Caption." + "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" }, { - "plain": "Photo: Science Museum London, CC BY-SA 2.0." + "plain": "Caption." }, { - "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + "plain": "Photo: Science Museum London, CC BY-SA 2.0." } ] }, @@ -9121,15 +9121,15 @@ } ], "utterances": [ + { + "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "plain": "Credit.", "language": "en" }, { "plain": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -9215,13 +9215,13 @@ ], "utterances": [ { - "plain": "Credit." + "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" }, { - "plain": "Photo: Science Museum London, CC BY-SA 2.0." + "plain": "Credit." }, { - "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + "plain": "Photo: Science Museum London, CC BY-SA 2.0." } ] }, @@ -9830,6 +9830,9 @@ } ], "utterances": [ + { + "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "plain": "Caption.", "language": "en" @@ -9840,9 +9843,6 @@ }, { "plain": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -9933,6 +9933,9 @@ } ], "utterances": [ + { + "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "plain": "Caption." }, @@ -9941,9 +9944,6 @@ }, { "plain": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "plain": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -10344,13 +10344,13 @@ ], "utterances": [ { - "ssml": "A metal-edged case with a red textured front panel." + "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" }, { - "ssml": "Photo: Science Museum London, CC BY-SA 2.0." + "ssml": "A metal-edged case with a red textured front panel." }, { - "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + "ssml": "Photo: Science Museum London, CC BY-SA 2.0." } ] }, @@ -10579,15 +10579,15 @@ } ], "utterances": [ + { + "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "ssml": "Image with a label: A metal-edged case with a red textured front panel.", "language": "en" }, { "ssml": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -10624,13 +10624,13 @@ ], "utterances": [ { - "ssml": "Image with a label: A metal-edged case with a red textured front panel." + "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" }, { - "ssml": "Photo: Science Museum London, CC BY-SA 2.0." + "ssml": "Image with a label: A metal-edged case with a red textured front panel." }, { - "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + "ssml": "Photo: Science Museum London, CC BY-SA 2.0." } ] }, @@ -10872,6 +10872,9 @@ } ], "utterances": [ + { + "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "ssml": "A metal-edged case with a red textured front panel." }, @@ -10881,9 +10884,6 @@ }, { "ssml": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -10919,6 +10919,9 @@ } ], "utterances": [ + { + "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "ssml": "A metal-edged case with a red textured front panel." }, @@ -10927,9 +10930,6 @@ }, { "ssml": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -11186,6 +11186,9 @@ } ], "utterances": [ + { + "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "ssml": "Image with a label: A metal-edged case with a red textured front panel.", "language": "en" @@ -11196,9 +11199,6 @@ }, { "ssml": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -11237,6 +11237,9 @@ } ], "utterances": [ + { + "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "ssml": "Image with a label: A metal-edged case with a red textured front panel." }, @@ -11245,9 +11248,6 @@ }, { "ssml": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -11508,6 +11508,9 @@ } ], "utterances": [ + { + "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "ssml": "A metal-edged case with a red textured front panel." }, @@ -11517,9 +11520,6 @@ }, { "ssml": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -11555,6 +11555,9 @@ } ], "utterances": [ + { + "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "ssml": "A metal-edged case with a red textured front panel." }, @@ -11563,9 +11566,6 @@ }, { "ssml": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -11822,6 +11822,9 @@ } ], "utterances": [ + { + "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "ssml": "Image with a label: A metal-edged case with a red textured front panel.", "language": "en" @@ -11832,9 +11835,6 @@ }, { "ssml": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -11873,6 +11873,9 @@ } ], "utterances": [ + { + "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "ssml": "Image with a label: A metal-edged case with a red textured front panel." }, @@ -11881,9 +11884,6 @@ }, { "ssml": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -12153,6 +12153,9 @@ } ], "utterances": [ + { + "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "ssml": "A metal-edged case with a red textured front panel." }, @@ -12166,9 +12169,6 @@ }, { "ssml": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -12207,6 +12207,9 @@ } ], "utterances": [ + { + "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "ssml": "A metal-edged case with a red textured front panel." }, @@ -12218,9 +12221,6 @@ }, { "ssml": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -12505,6 +12505,9 @@ } ], "utterances": [ + { + "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "ssml": "Image with a label: A metal-edged case with a red textured front panel.", "language": "en" @@ -12519,9 +12522,6 @@ }, { "ssml": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -12563,6 +12563,9 @@ } ], "utterances": [ + { + "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "ssml": "Image with a label: A metal-edged case with a red textured front panel." }, @@ -12574,9 +12577,6 @@ }, { "ssml": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -18203,10 +18203,10 @@ ], "utterances": [ { - "ssml": "Photo: Science Museum London, CC BY-SA 2.0." + "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" }, { - "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + "ssml": "Photo: Science Museum London, CC BY-SA 2.0." } ] }, @@ -18766,15 +18766,15 @@ } ], "utterances": [ + { + "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "ssml": "Caption.", "language": "en" }, { "ssml": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -18860,13 +18860,13 @@ ], "utterances": [ { - "ssml": "Caption." + "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" }, { - "ssml": "Photo: Science Museum London, CC BY-SA 2.0." + "ssml": "Caption." }, { - "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + "ssml": "Photo: Science Museum London, CC BY-SA 2.0." } ] }, @@ -19457,15 +19457,15 @@ } ], "utterances": [ + { + "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "ssml": "Credit.", "language": "en" }, { "ssml": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -19551,13 +19551,13 @@ ], "utterances": [ { - "ssml": "Credit." + "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" }, { - "ssml": "Photo: Science Museum London, CC BY-SA 2.0." + "ssml": "Credit." }, { - "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + "ssml": "Photo: Science Museum London, CC BY-SA 2.0." } ] }, @@ -20166,6 +20166,9 @@ } ], "utterances": [ + { + "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "ssml": "Caption.", "language": "en" @@ -20176,9 +20179,6 @@ }, { "ssml": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, @@ -20269,6 +20269,9 @@ } ], "utterances": [ + { + "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" + }, { "ssml": "Caption." }, @@ -20277,9 +20280,6 @@ }, { "ssml": "Photo: Science Museum London, CC BY-SA 2.0." - }, - { - "ssml": "Computer and speech synthesiser housing used by Stephen Hawking in 1999" } ] }, diff --git a/fixtures/figure-describedby/utterances.json b/fixtures/figure-describedby/utterances.json index f81a97ee..fbf34acd 100644 --- a/fixtures/figure-describedby/utterances.json +++ b/fixtures/figure-describedby/utterances.json @@ -8,10 +8,10 @@ ], "utterances": [ { - "plain": "Sales chart" + "plain": "Full audio description: sales grew 12% year over year, driven primarily by the Q4 holiday season." }, { - "plain": "Full audio description: sales grew 12% year over year, driven primarily by the Q4 holiday season." + "plain": "Sales chart" } ] }, @@ -235,11 +235,11 @@ ], "utterances": [ { - "plain": "Image with a label: Sales chart", - "language": "en" + "plain": "Full audio description: sales grew 12% year over year, driven primarily by the Q4 holiday season." }, { - "plain": "Full audio description: sales grew 12% year over year, driven primarily by the Q4 holiday season." + "plain": "Image with a label: Sales chart", + "language": "en" } ] }, @@ -276,10 +276,10 @@ ], "utterances": [ { - "plain": "Image with a label: Sales chart" + "plain": "Full audio description: sales grew 12% year over year, driven primarily by the Q4 holiday season." }, { - "plain": "Full audio description: sales grew 12% year over year, driven primarily by the Q4 holiday season." + "plain": "Image with a label: Sales chart" } ] }, @@ -2187,10 +2187,10 @@ ], "utterances": [ { - "ssml": "Sales chart" + "ssml": "Full audio description: sales grew 12% year over year, driven primarily by the Q4 holiday season." }, { - "ssml": "Full audio description: sales grew 12% year over year, driven primarily by the Q4 holiday season." + "ssml": "Sales chart" } ] }, @@ -2414,11 +2414,11 @@ ], "utterances": [ { - "ssml": "Image with a label: Sales chart", - "language": "en" + "ssml": "Full audio description: sales grew 12% year over year, driven primarily by the Q4 holiday season." }, { - "ssml": "Full audio description: sales grew 12% year over year, driven primarily by the Q4 holiday season." + "ssml": "Image with a label: Sales chart", + "language": "en" } ] }, @@ -2455,10 +2455,10 @@ ], "utterances": [ { - "ssml": "Image with a label: Sales chart" + "ssml": "Full audio description: sales grew 12% year over year, driven primarily by the Q4 holiday season." }, { - "ssml": "Full audio description: sales grew 12% year over year, driven primarily by the Q4 holiday season." + "ssml": "Image with a label: Sales chart" } ] }, diff --git a/fixtures/language-describedby-shared/utterances.json b/fixtures/language-describedby-shared/utterances.json index 73d94c9e..7f644feb 100644 --- a/fixtures/language-describedby-shared/utterances.json +++ b/fixtures/language-describedby-shared/utterances.json @@ -15,13 +15,13 @@ "plain": "Katze", "language": "de" }, - { - "plain": "x", - "language": "fr" - }, { "plain": "Eine Katze", "language": "de" + }, + { + "plain": "x", + "language": "fr" } ] }, @@ -56,13 +56,13 @@ "plain": "Eine Katze", "language": "de" }, - { - "plain": "x", - "language": "fr" - }, { "plain": "Eine Katze", "language": "de" + }, + { + "plain": "x", + "language": "fr" } ] }, @@ -88,10 +88,10 @@ "plain": "Katze" }, { - "plain": "x" + "plain": "Eine Katze" }, { - "plain": "Eine Katze" + "plain": "x" } ] }, @@ -111,10 +111,10 @@ "plain": "Eine Katze" }, { - "plain": "x" + "plain": "Eine Katze" }, { - "plain": "Eine Katze" + "plain": "x" } ] }, @@ -369,6 +369,10 @@ "plain": "Katze", "language": "de" }, + { + "plain": "Eine Katze", + "language": "de" + }, { "plain": "Image with a label:", "language": "en" @@ -376,10 +380,6 @@ { "plain": "x", "language": "fr" - }, - { - "plain": "Eine Katze", - "language": "de" } ] }, @@ -419,6 +419,10 @@ } ], "utterances": [ + { + "plain": "Eine Katze", + "language": "de" + }, { "plain": "Eine Katze", "language": "de" @@ -430,10 +434,6 @@ { "plain": "x", "language": "fr" - }, - { - "plain": "Eine Katze", - "language": "de" } ] }, @@ -465,10 +465,10 @@ "plain": "Katze" }, { - "plain": "Image with a label: x" + "plain": "Eine Katze" }, { - "plain": "Eine Katze" + "plain": "Image with a label: x" } ] }, @@ -491,10 +491,10 @@ "plain": "Eine Katze" }, { - "plain": "Image with a label: x" + "plain": "Eine Katze" }, { - "plain": "Eine Katze" + "plain": "Image with a label: x" } ] }, @@ -2610,13 +2610,13 @@ "ssml": "Katze", "language": "de" }, - { - "ssml": "x", - "language": "fr" - }, { "ssml": "Eine Katze", "language": "de" + }, + { + "ssml": "x", + "language": "fr" } ] }, @@ -2651,13 +2651,13 @@ "ssml": "Eine Katze", "language": "de" }, - { - "ssml": "x", - "language": "fr" - }, { "ssml": "Eine Katze", "language": "de" + }, + { + "ssml": "x", + "language": "fr" } ] }, @@ -2683,10 +2683,10 @@ "ssml": "Katze" }, { - "ssml": "x" + "ssml": "Eine Katze" }, { - "ssml": "Eine Katze" + "ssml": "x" } ] }, @@ -2706,10 +2706,10 @@ "ssml": "Eine Katze" }, { - "ssml": "x" + "ssml": "Eine Katze" }, { - "ssml": "Eine Katze" + "ssml": "x" } ] }, @@ -2956,13 +2956,13 @@ "ssml": "Katze", "language": "de" }, - { - "ssml": "Image with a label: x", - "language": "en" - }, { "ssml": "Eine Katze", "language": "de" + }, + { + "ssml": "Image with a label: x", + "language": "en" } ] }, @@ -3006,13 +3006,13 @@ "ssml": "Eine Katze", "language": "de" }, - { - "ssml": "Image with a label: x", - "language": "en" - }, { "ssml": "Eine Katze", "language": "de" + }, + { + "ssml": "Image with a label: x", + "language": "en" } ] }, @@ -3044,10 +3044,10 @@ "ssml": "Katze" }, { - "ssml": "Image with a label: x" + "ssml": "Eine Katze" }, { - "ssml": "Eine Katze" + "ssml": "Image with a label: x" } ] }, @@ -3070,10 +3070,10 @@ "ssml": "Eine Katze" }, { - "ssml": "Image with a label: x" + "ssml": "Eine Katze" }, { - "ssml": "Eine Katze" + "ssml": "Image with a label: x" } ] }, diff --git a/fixtures/language-labelledby-target-aria-label/utterances.json b/fixtures/language-labelledby-target-aria-label/utterances.json index c682564e..bc6cfedd 100644 --- a/fixtures/language-labelledby-target-aria-label/utterances.json +++ b/fixtures/language-labelledby-target-aria-label/utterances.json @@ -8,11 +8,11 @@ ], "utterances": [ { - "plain": "x", + "plain": "Eine Katze", "language": "de" }, { - "plain": "Eine Katze", + "plain": "x", "language": "de" }, { @@ -45,10 +45,10 @@ ], "utterances": [ { - "plain": "x" + "plain": "Eine Katze" }, { - "plain": "Eine Katze" + "plain": "x" }, { "plain": "Eine Katze" @@ -141,11 +141,11 @@ ], "utterances": [ { - "plain": "x", + "plain": "Eine Katze", "language": "de" }, { - "plain": "Eine Katze", + "plain": "x", "language": "de" }, { @@ -191,10 +191,10 @@ ], "utterances": [ { - "plain": "x" + "plain": "Eine Katze" }, { - "plain": "Eine Katze" + "plain": "x" }, { "plain": "Image with a label: Eine Katze" @@ -395,11 +395,11 @@ ], "utterances": [ { - "plain": "x", + "plain": "Eine Katze", "language": "de" }, { - "plain": "Eine Katze", + "plain": "x", "language": "de" } ] @@ -474,10 +474,10 @@ ], "utterances": [ { - "plain": "x" + "plain": "Eine Katze" }, { - "plain": "Eine Katze" + "plain": "x" } ] }, @@ -489,11 +489,11 @@ ], "utterances": [ { - "ssml": "x", + "ssml": "Eine Katze", "language": "de" }, { - "ssml": "Eine Katze", + "ssml": "x", "language": "de" }, { @@ -526,10 +526,10 @@ ], "utterances": [ { - "ssml": "x" + "ssml": "Eine Katze" }, { - "ssml": "Eine Katze" + "ssml": "x" }, { "ssml": "Eine Katze" @@ -622,11 +622,11 @@ ], "utterances": [ { - "ssml": "x", + "ssml": "Eine Katze", "language": "de" }, { - "ssml": "Eine Katze", + "ssml": "x", "language": "de" }, { @@ -668,10 +668,10 @@ ], "utterances": [ { - "ssml": "x" + "ssml": "Eine Katze" }, { - "ssml": "Eine Katze" + "ssml": "x" }, { "ssml": "Image with a label: Eine Katze" @@ -872,11 +872,11 @@ ], "utterances": [ { - "ssml": "x", + "ssml": "Eine Katze", "language": "de" }, { - "ssml": "Eine Katze", + "ssml": "x", "language": "de" } ] @@ -951,10 +951,10 @@ ], "utterances": [ { - "ssml": "x" + "ssml": "Eine Katze" }, { - "ssml": "Eine Katze" + "ssml": "x" } ] } diff --git a/src/utterances/roles.ts b/src/utterances/roles.ts index c26d2ce2..a35e0e11 100644 --- a/src/utterances/roles.ts +++ b/src/utterances/roles.ts @@ -118,8 +118,8 @@ export const embeddedTargetRoles: GndRole[] = ["biblioref", "glossref", "noteref // Roles whose contextualization template folds `node.description` into its // own text (a labelled/unlabelled variant, `{{ description }}`, or both) -// instead of the node's description being spoken as a separate trailing -// utterance — see the `foldsDescription` check in `walkNode()`. +// instead of the node's description being spoken as a separate utterance +// before its content — see the `foldsDescription` check in `walkNode()`. export const descriptionFoldingRoles: GndRole[] = ["audio", "video", "image", "figure", "math", "table", "cover"]; // cell/rowheader's own contextualization template already embeds the diff --git a/src/utterances/walk.ts b/src/utterances/walk.ts index a223ec96..268ad22b 100644 --- a/src/utterances/walk.ts +++ b/src/utterances/walk.ts @@ -443,16 +443,12 @@ function walkNode( role !== "footnote" && role !== "pagebreak" && !textReferenceRoleSet.has(role) && !isDroppedByAnotherRole(role, roles, ctx), ); - // A description is supplementary/elaborating content (e.g. an extended - // audio description) for most roles, spoken after the primary content — - // but a table's is its label, spoken before its rows. Either way this - // is suppressed when a role that's actually firing already folded it - // into its own announcement (e.g. "Table: Team roster. 3 lines..."). + // Unless a firing role folded it into its own announcement (e.g. "Table: Team roster. 3 lines..."). const foldsDescription = roles.some((role) => descriptionFoldingRoleSet.has(role) && ctx.contextualize.has(role)); - const isTableCaption = roles.includes("table") && description !== undefined && !foldsDescription; - if (isTableCaption) { - const utterance = formatDescription(description!, node, ctx); - scopeToQuote(utterance, 0, description!, node, ctx); + if (description !== undefined && !foldsDescription) { + const utterance = formatDescription(description, node, ctx); + // Only a figure's or table's description is located, as a quote within it. + if (roles.includes("figure") || roles.includes("table")) scopeToQuote(utterance, 0, description, node, ctx); push(out, node, [utterance]); } @@ -550,13 +546,6 @@ function walkNode( out[beforeLength].blockStart = true; } - if (description !== undefined && !foldsDescription && !isTableCaption) { - const utterance = formatDescription(description, node, ctx); - // Only a figure's description is located, as a quote within the figure. - if (roles.includes("figure")) scopeToQuote(utterance, 0, description, node, ctx); - push(out, node, [utterance]); - } - for (const role of contextualizedRoles) { const { variantKey, params } = contextualizationParamsFor(role, node, ctx); pushRoleContextualization(out, node, ctx, role, "after", variantKey, params); From bdb43bd427a5f4a528bb5f0fb571f1b253284e60 Mon Sep 17 00:00:00 2001 From: Jiminy Panoz Date: Mon, 23 Nov 2026 18:24:08 +0100 Subject: [PATCH 2/8] Contextualize comics roles --- docs/UtteranceExtraction.md | 4 ++-- docs/Verbosity.md | 4 ++++ locales/en.json | 9 +++++++++ src/preferences/verbosityTables.ts | 5 ++++- src/utterances/contextualization.ts | 2 +- src/utterances/roles.ts | 15 ++++++++++++--- 6 files changed, 32 insertions(+), 7 deletions(-) diff --git a/docs/UtteranceExtraction.md b/docs/UtteranceExtraction.md index 749e61d8..fa7333e6 100644 --- a/docs/UtteranceExtraction.md +++ b/docs/UtteranceExtraction.md @@ -114,7 +114,7 @@ A node's `

` and `` are not kept in `ssml`: paragraphs come from GND roles, Drops a role and its whole subtree — content and announcement both — from the output. The exported [`skippableRoles`](#role-sets) lists the roles meant to be skipped. `skip` ignores the roles [`interruptions`](#interruptions) controls. -A role a more specific one on the same node drops isn't skipped either: skipping `aside` keeps `