Repository navigation
Expand file tree
/
Copy pathroles.ts
More file actions
131 lines (123 loc) · 3.8 KB
/
Copy pathroles.ts
File metadata and controls
131 lines (123 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import type { GndRole } from "@readium/guided-navigation";
// https://github.com/readium/guided-navigation/blob/main/roles.md#list-of-skippable-roles
// Roles a reader may choose to skip past during playback — ancillary
// content (asides, footnotes...) and navigational aids (tables of
// contents, page lists...) that aren't part of the primary reading flow.
// Nothing is skipped by default: pass a subset of this list (or all of
// it) via `ExtractUtterancesOptions.skip` to opt in. Roles `interruptions` controls aren't here.
export const skippableRoles: GndRole[] = [
"aside",
"audio",
"bibliography",
"cell",
"columnheader",
"details",
"endnotes",
"figure",
"footnote",
"glossary",
"image",
"landmarks",
"loa",
"loi",
"lot",
"lov",
"pullquote",
"row",
"rowheader",
"table",
"toc",
"video"
];
// Roles that constitute their own block for pause purposes — a node
// carrying one of these starts a new "paragraph-like" unit whenever it
// isn't a continuation of the block already in progress. Reference-only
// roles (`backlink`, `biblioref`, `glossref`, `noteref`, `term`) are
// intentionally excluded: they're inline, not their own block.
export const blockLevelRoles: GndRole[] = [
// Headings
"heading1",
"heading2",
"heading3",
"heading4",
"heading5",
"heading6",
// Text blocks
"paragraph",
"blockquote",
"preformatted",
"pullquote",
// Lists
"list",
"listItem",
// Tables
"table",
"row",
"cell",
"columnheader",
"rowheader",
// Media
"audio",
"video",
"figure",
"image",
"math",
// Sectioning / landmark containers
"abstract",
"acknowledgments",
"afterword",
"appendix",
"article",
"aside",
"bibliography",
"chapter",
"colophon",
"conclusion",
"dedication",
"endnotes",
"epigraph",
"epilogue",
"errata",
"example",
"footnote",
"foreword",
"glossary",
"index",
"introduction",
"notice",
"part",
"preface",
"prologue",
"qna",
"section",
"summary",
"tip",
];
// role -> role(s) it drops from the loop when both are on one node —
// `unconditional` drops them regardless of reachability, else only once reachable.
export const roleDropOverrides: Partial<Record<GndRole, { drops: GndRole[]; unconditional?: boolean }>> = {
footnote: { drops: ["aside"], unconditional: true },
cover: { drops: ["image"] },
pullquote: { drops: ["blockquote", "aside"] },
epigraph: { drops: ["blockquote"] },
};
// Placeholder roles `interruptions` can speak mid-sentence, after, or not at all;
// every other placeholder role always stays inline.
export const interruptionRoles: GndRole[] = ["abbreviation", "biblioref", "glossref", "noteref", "pagebreak"];
// References whose own text belongs to the sentence: their `interruptions`
// setting only moves or drops the target embedded as their children.
export const textReferenceRoles: GndRole[] = ["biblioref", "glossref"];
// 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()`.
export const descriptionFoldingRoles: GndRole[] = ["audio", "video", "image", "figure", "math", "table", "cover"];
// cell/rowheader's own contextualization template already embeds the
// cell's text (`{{ value }}`, with or without a `{{ header }}` prefix) —
// so once it fires, the node's own text must not also be spoken, or the
// value is heard twice.
export const valueFoldingRoles: GndRole[] = ["cell", "rowheader"];
// Roles whose subtree carries no content worth speaking, whatever markup an
// author put inside it — only the role's own contextualization, if
// requested, is ever heard.
export const contentlessRoles: GndRole[] = ["separator"];