@readium/guided-navigation 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/dist/a11y.js +1 -1
- package/dist/converter.js +1 -1
- package/dist/elementHandlers.js +1 -1
- package/dist/emptyPairs.js +1 -1
- package/dist/index.js +1 -1
- package/dist/object.js +1 -1
- package/dist/textrefFragment.js +1 -1
- package/fixtures/README.md +4 -4
- package/fixtures/ROLES_COVERAGE.md +3 -3
- package/fixtures/abbreviation-acronym-html-native/gnd.json +3 -5
- package/fixtures/abbreviation-before-formatting/gnd.json +3 -5
- package/fixtures/abbreviation-before-image/gnd.json +10 -14
- package/fixtures/abbreviation-html-native/gnd.json +3 -5
- package/fixtures/abbreviation-language/gnd.json +3 -5
- package/fixtures/abbreviation-line-break/gnd.json +3 -5
- package/fixtures/abbreviation-nested/gnd.json +3 -5
- package/fixtures/abbreviation-nested-emphasis/gnd.json +3 -5
- package/fixtures/abbreviation-nested-term/gnd.json +4 -8
- package/fixtures/abbreviation-nested-term-punctuation/gnd.json +4 -8
- package/fixtures/abbreviation-no-title/gnd.json +1 -3
- package/fixtures/abbreviation-period-mid-sentence/gnd.json +3 -5
- package/fixtures/abbreviation-period-sentence-end/gnd.json +3 -5
- package/fixtures/abbreviation-spanning-terms/gnd.json +3 -9
- package/fixtures/abbreviation-with-image/gnd.json +10 -14
- package/fixtures/abbreviation-with-svg-and-math/gnd.json +15 -21
- package/fixtures/abstract-epub-type/gnd.json +3 -7
- package/fixtures/abstract-role-aria/gnd.json +1 -3
- package/fixtures/accessible-name-labelledby-aria-hidden/gnd.json +2 -7
- package/fixtures/accessible-name-labelledby-hidden-attribute/gnd.json +2 -7
- package/fixtures/acknowledgments-epub-type/gnd.json +3 -7
- package/fixtures/acknowledgments-role-aria/gnd.json +1 -3
- package/fixtures/afterword-epub-type/gnd.json +3 -7
- package/fixtures/afterword-role-aria/gnd.json +1 -3
- package/fixtures/appendix-epub-type/gnd.json +3 -8
- package/fixtures/appendix-role-aria/gnd.json +1 -3
- package/fixtures/article-html-native/gnd.json +1 -3
- package/fixtures/article-role-aria/gnd.json +2 -4
- package/fixtures/aside-epub-type/gnd.json +3 -7
- package/fixtures/aside-html-native/gnd.json +1 -3
- package/fixtures/audio-html-native/gnd.json +3 -5
- package/fixtures/audio-no-description/gnd.json +2 -4
- package/fixtures/backlink-epub-type/gnd.json +3 -8
- package/fixtures/backlink-role-aria/gnd.json +2 -5
- package/fixtures/bibliography-epub-type/gnd.json +7 -18
- package/fixtures/bibliography-role-aria/gnd.json +4 -12
- package/fixtures/biblioref-epub-type/gnd.json +3 -8
- package/fixtures/biblioref-role-aria/gnd.json +2 -5
- package/fixtures/biblioref-target-descendant-ids/gnd.json +31 -49
- package/fixtures/biblioref-target-in-bibliography-role-aria/gnd.json +16 -29
- package/fixtures/biblioref-target-mixed-content/gnd.json +27 -36
- package/fixtures/blockquote-html-native/gnd.json +1 -3
- package/fixtures/blockquote-role-aria/gnd.json +2 -4
- package/fixtures/body-html-native/gnd.json +1 -3
- package/fixtures/chapter-epub-type/gnd.json +4 -11
- package/fixtures/chapter-role-aria/gnd.json +2 -7
- package/fixtures/colophon-epub-type/gnd.json +3 -7
- package/fixtures/colophon-role-aria/gnd.json +1 -3
- package/fixtures/complementary-role-aria/gnd.json +1 -3
- package/fixtures/conclusion-epub-type/gnd.json +3 -7
- package/fixtures/conclusion-role-aria/gnd.json +1 -3
- package/fixtures/cover-epub-type/gnd.json +5 -12
- package/fixtures/cover-role-aria/gnd.json +3 -6
- package/fixtures/credit-epub-type/gnd.json +4 -10
- package/fixtures/credit-role-aria/gnd.json +1 -3
- package/fixtures/credits-epub-type/gnd.json +9 -23
- package/fixtures/credits-role-aria/gnd.json +4 -14
- package/fixtures/dedication-epub-type/gnd.json +3 -7
- package/fixtures/dedication-role-aria/gnd.json +1 -3
- package/fixtures/definition-epub-type/gnd.json +4 -10
- package/fixtures/definition-html-native/gnd.json +1 -3
- package/fixtures/definition-role-aria/gnd.json +1 -3
- package/fixtures/description-roleless-lone-child/gnd.json +5 -9
- package/fixtures/description-roleless-wrapper/gnd.json +8 -12
- package/fixtures/details-html-native/gnd.json +1 -3
- package/fixtures/details-summary-html-native/gnd.json +2 -6
- package/fixtures/endnotes-epub-type/gnd.json +9 -26
- package/fixtures/endnotes-role-aria/gnd.json +4 -14
- package/fixtures/epigraph-epub-type/gnd.json +3 -7
- package/fixtures/epigraph-role-aria/gnd.json +1 -3
- package/fixtures/epilogue-epub-type/gnd.json +3 -7
- package/fixtures/epilogue-role-aria/gnd.json +1 -3
- package/fixtures/errata-epub-type/gnd.json +3 -7
- package/fixtures/errata-role-aria/gnd.json +1 -3
- package/fixtures/example-epub-type/gnd.json +5 -14
- package/fixtures/example-role-aria/gnd.json +1 -3
- package/fixtures/figure-aria-label-caption/gnd.json +19 -0
- package/fixtures/figure-aria-label-caption/input.html +1 -0
- package/fixtures/figure-aria-label-caption/meta.json +12 -0
- package/fixtures/figure-basic-html-native/gnd.json +4 -8
- package/fixtures/figure-basic-role-aria/gnd.json +4 -8
- package/fixtures/figure-caption-block-content/gnd.json +33 -0
- package/fixtures/figure-caption-block-content/input.html +7 -0
- package/fixtures/figure-caption-block-content/meta.json +14 -0
- package/fixtures/figure-caption-element-html-native/gnd.json +14 -8
- package/fixtures/figure-caption-element-html-native/meta.json +1 -1
- package/fixtures/figure-caption-element-role-aria/gnd.json +14 -8
- package/fixtures/figure-caption-element-role-aria/meta.json +1 -1
- package/fixtures/figure-caption-html-native/gnd.json +3 -5
- package/fixtures/figure-caption-role-aria/gnd.json +3 -5
- package/fixtures/figure-credit-nested-in-aria-labelledby-caption/gnd.json +13 -21
- package/fixtures/figure-credit-nested-in-caption/gnd.json +13 -21
- package/fixtures/figure-credit-nested-in-caption/meta.json +1 -1
- package/fixtures/figure-credit-role-aria/gnd.json +12 -18
- package/fixtures/figure-credit-role-aria/meta.json +1 -1
- package/fixtures/figure-describedby/gnd.json +4 -8
- package/fixtures/figure-epub-type/gnd.json +5 -11
- package/fixtures/figure-no-description/gnd.json +3 -7
- package/fixtures/footnote-epub-type/gnd.json +5 -14
- package/fixtures/footnote-role-aria/gnd.json +17 -31
- package/fixtures/foreword-epub-type/gnd.json +3 -7
- package/fixtures/foreword-role-aria/gnd.json +1 -3
- package/fixtures/glossary-epub-type/gnd.json +10 -22
- package/fixtures/glossary-role-aria/gnd.json +5 -15
- package/fixtures/glossref-epub-type/gnd.json +3 -8
- package/fixtures/glossref-role-aria/gnd.json +2 -5
- package/fixtures/glossref-role-aria-mid-sentence/gnd.json +5 -13
- package/fixtures/glossref-sole-content/gnd.json +11 -26
- package/fixtures/glossref-target-in-glossary-role-aria/gnd.json +17 -32
- package/fixtures/glossref-target-percent-encoded/gnd.json +17 -32
- package/fixtures/glossref-target-percent-encoded/meta.json +1 -1
- package/fixtures/header-html-native/gnd.json +1 -3
- package/fixtures/heading-html-native/gnd.json +6 -18
- package/fixtures/heading-role-aria/gnd.json +6 -18
- package/fixtures/heading-role-presentation/gnd.json +6 -12
- package/fixtures/hidden-aria-hidden-html-native/gnd.json +2 -6
- package/fixtures/hidden-attribute-html-native/gnd.json +2 -6
- package/fixtures/image-alt-html-native/gnd.json +3 -5
- package/fixtures/image-decorative-empty-alt/gnd.json +2 -6
- package/fixtures/image-decorative-role-presentation/gnd.json +2 -6
- package/fixtures/image-decorative-whitespace-alt/gnd.json +4 -8
- package/fixtures/image-no-description/gnd.json +2 -4
- package/fixtures/image-role-aria/gnd.json +3 -5
- package/fixtures/index-epub-type/gnd.json +11 -32
- package/fixtures/index-role-aria/gnd.json +10 -28
- package/fixtures/introduction-epub-type/gnd.json +3 -7
- package/fixtures/introduction-role-aria/gnd.json +1 -3
- package/fixtures/landmarks-epub-type/gnd.json +15 -43
- package/fixtures/language-alt-inherited/gnd.json +8 -12
- package/fixtures/language-alt-own-lang/gnd.json +8 -12
- package/fixtures/language-block/gnd.json +5 -11
- package/fixtures/language-block-empty-lang/gnd.json +1 -3
- package/fixtures/language-describedby-shared/gnd.json +19 -27
- package/fixtures/language-document/gnd.json +3 -7
- package/fixtures/language-empty-lang-stops-inheritance/gnd.json +6 -10
- package/fixtures/language-figcaption/gnd.json +13 -16
- package/fixtures/language-figcaption/meta.json +1 -1
- package/fixtures/language-figcaption-credit/gnd.json +17 -25
- package/fixtures/language-figcaption-credit/meta.json +1 -1
- package/fixtures/language-figcaption-switches/gnd.json +13 -15
- package/fixtures/language-figcaption-switches/meta.json +1 -1
- package/fixtures/language-figcaption-switches-throughout/gnd.json +13 -16
- package/fixtures/language-figcaption-switches-throughout/meta.json +1 -1
- package/fixtures/language-inline-case-insensitive/gnd.json +3 -5
- package/fixtures/language-inline-case-insensitive-ssml/gnd.json +3 -5
- package/fixtures/language-inline-empty-lang/gnd.json +3 -5
- package/fixtures/language-inline-empty-lang-formatted/gnd.json +1 -3
- package/fixtures/language-inline-empty-lang-only/gnd.json +1 -3
- package/fixtures/language-inline-empty-lang-undeclared/gnd.json +3 -5
- package/fixtures/language-inline-lang-attribute/gnd.json +3 -5
- package/fixtures/language-inline-nested/gnd.json +3 -5
- package/fixtures/language-inline-repeated/gnd.json +3 -5
- package/fixtures/language-inline-two-languages/gnd.json +3 -5
- package/fixtures/language-labelledby-target/gnd.json +8 -12
- package/fixtures/language-labelledby-target-aria-label/gnd.json +12 -16
- package/fixtures/language-labelledby-target-switches/gnd.json +6 -10
- package/fixtures/language-labelledby-targets-case/gnd.json +11 -17
- package/fixtures/language-labelledby-targets-differ/gnd.json +9 -15
- package/fixtures/language-link-switches/gnd.json +10 -13
- package/fixtures/language-pagebreak-label/gnd.json +10 -14
- package/fixtures/language-undeclared-description/gnd.json +4 -8
- package/fixtures/language-xml-lang-empty-html-inherits/gnd.json +8 -12
- package/fixtures/language-xml-lang-empty-html-lang-applies/gnd.json +8 -12
- package/fixtures/language-xml-lang-empty-xhtml/gnd.json +6 -10
- package/fixtures/language-xml-lang-over-lang/gnd.json +8 -12
- package/fixtures/link-containing-image/gnd.json +12 -17
- package/fixtures/link-containing-pagebreak/gnd.json +12 -17
- package/fixtures/link-content-conversion/gnd.json +14 -20
- package/fixtures/link-content-identity/gnd.json +7 -8
- package/fixtures/link-content-words/gnd.json +9 -14
- package/fixtures/list-aria-posinset-setsize/gnd.json +3 -7
- package/fixtures/list-epub-type/gnd.json +6 -14
- package/fixtures/list-html-native/gnd.json +4 -12
- package/fixtures/list-item-posinset-override/gnd.json +7 -15
- package/fixtures/list-item-value-override/gnd.json +7 -15
- package/fixtures/list-ordered-html-native/gnd.json +7 -15
- package/fixtures/list-ordered-reversed/gnd.json +7 -15
- package/fixtures/list-ordered-start/gnd.json +7 -15
- package/fixtures/list-role-aria/gnd.json +4 -12
- package/fixtures/listitem-role-presentation/gnd.json +5 -11
- package/fixtures/loa-epub-type/gnd.json +11 -32
- package/fixtures/loi-epub-type/gnd.json +11 -32
- package/fixtures/lot-epub-type/gnd.json +11 -32
- package/fixtures/lov-epub-type/gnd.json +11 -32
- package/fixtures/main-html-native/gnd.json +1 -3
- package/fixtures/main-role-aria/gnd.json +1 -3
- package/fixtures/manifest.json +51 -11
- package/fixtures/math-html-native/gnd.json +5 -7
- package/fixtures/math-inline/gnd.json +10 -14
- package/fixtures/math-no-description/gnd.json +3 -5
- package/fixtures/math-role-aria/gnd.json +5 -7
- package/fixtures/navigation-html-native/gnd.json +1 -3
- package/fixtures/navigation-role-aria/gnd.json +1 -3
- package/fixtures/nested-blockquote/gnd.json +3 -9
- package/fixtures/nested-section/gnd.json +3 -9
- package/fixtures/noteref-after-closing-straight-quote/gnd.json +13 -20
- package/fixtures/noteref-after-closing-straight-quote-split/gnd.json +12 -17
- package/fixtures/noteref-enclosed-across-formatting/gnd.json +13 -20
- package/fixtures/noteref-enclosed-adjacent-pairs/gnd.json +38 -62
- package/fixtures/noteref-enclosed-adjacent-text/gnd.json +16 -23
- package/fixtures/noteref-enclosed-before-formatting/gnd.json +16 -23
- package/fixtures/noteref-enclosed-guillemets-french/gnd.json +42 -63
- package/fixtures/noteref-enclosed-quotes-chinese/gnd.json +15 -25
- package/fixtures/noteref-enclosed-quotes-german/gnd.json +49 -75
- package/fixtures/noteref-enclosed-quotes-swedish/gnd.json +28 -42
- package/fixtures/noteref-enclosed-straight-quotes/gnd.json +13 -20
- package/fixtures/noteref-in-lone-block/gnd.json +12 -17
- package/fixtures/noteref-role-aria/gnd.json +1 -3
- package/fixtures/noteref-target-in-endnotes-epub-type/gnd.json +10 -29
- package/fixtures/noteref-target-in-endnotes-role-aria/gnd.json +9 -26
- package/fixtures/noteref-target-malformed-escape/gnd.json +13 -20
- package/fixtures/noteref-target-percent-encoded/gnd.json +13 -20
- package/fixtures/notice-epub-type/gnd.json +3 -7
- package/fixtures/notice-role-aria/gnd.json +1 -3
- package/fixtures/pagebreak-epub-type/gnd.json +6 -14
- package/fixtures/pagebreak-role-aria/gnd.json +5 -11
- package/fixtures/pagelist-epub-type/gnd.json +15 -43
- package/fixtures/pagelist-role-aria/gnd.json +14 -40
- package/fixtures/paragraph-basic/gnd.json +1 -3
- package/fixtures/part-epub-type/gnd.json +4 -11
- package/fixtures/part-role-aria/gnd.json +2 -7
- package/fixtures/preface-epub-type/gnd.json +3 -7
- package/fixtures/preface-role-aria/gnd.json +1 -3
- package/fixtures/preformatted-html-native/gnd.json +1 -3
- package/fixtures/presentation-role-aria/gnd.json +1 -3
- package/fixtures/prologue-epub-type/gnd.json +3 -7
- package/fixtures/prologue-role-aria/gnd.json +1 -3
- package/fixtures/pullquote-epub-type/gnd.json +3 -8
- package/fixtures/pullquote-role-aria/gnd.json +1 -3
- package/fixtures/qna-epub-type/gnd.json +3 -8
- package/fixtures/qna-role-aria/gnd.json +1 -3
- package/fixtures/redundant-role-body-chapter/gnd.json +3 -10
- package/fixtures/redundant-role-nested-chapter/gnd.json +4 -13
- package/fixtures/region-role-aria/gnd.json +1 -3
- package/fixtures/section-html-native/gnd.json +1 -3
- package/fixtures/separator-html-native/gnd.json +3 -9
- package/fixtures/separator-role-aria/gnd.json +3 -9
- package/fixtures/separator-with-glyphs/gnd.json +3 -9
- package/fixtures/subtitle-epub-type/gnd.json +3 -7
- package/fixtures/subtitle-role-aria/gnd.json +1 -3
- package/fixtures/summary-html-native/gnd.json +1 -3
- package/fixtures/table-aria-label-caption/gnd.json +27 -0
- package/fixtures/table-aria-label-caption/input.html +1 -0
- package/fixtures/table-aria-label-caption/meta.json +13 -0
- package/fixtures/table-caption/gnd.json +22 -42
- package/fixtures/table-caption/meta.json +1 -1
- package/fixtures/table-caption-aria-labelledby/gnd.json +28 -0
- package/fixtures/table-caption-aria-labelledby/input.html +1 -0
- package/fixtures/table-caption-aria-labelledby/meta.json +13 -0
- package/fixtures/table-caption-element-html-native/gnd.json +13 -22
- package/fixtures/table-caption-element-html-native/meta.json +1 -1
- package/fixtures/table-caption-role-aria/gnd.json +10 -15
- package/fixtures/table-cell-abbreviation/gnd.json +8 -16
- package/fixtures/table-cell-link/gnd.json +8 -19
- package/fixtures/table-cell-noteref/gnd.json +15 -25
- package/fixtures/table-colspan-html-native/gnd.json +9 -21
- package/fixtures/table-colspan-role-aria/gnd.json +9 -21
- package/fixtures/table-epub-type/gnd.json +7 -17
- package/fixtures/table-html-native/gnd.json +10 -30
- package/fixtures/table-in-role-none-wrapper/gnd.json +6 -18
- package/fixtures/table-nested-html-native/gnd.json +7 -19
- package/fixtures/table-nested-in-presentation-table/gnd.json +8 -24
- package/fixtures/table-nested-role-aria/gnd.json +7 -19
- package/fixtures/table-no-headers/gnd.json +11 -25
- package/fixtures/table-role-aria/gnd.json +10 -30
- package/fixtures/table-role-presentation-explicit-cell/gnd.json +4 -12
- package/fixtures/table-role-presentation-html-native/gnd.json +7 -17
- package/fixtures/table-role-presentation-role-aria/gnd.json +7 -17
- package/fixtures/table-rowgroup-role-aria/gnd.json +4 -10
- package/fixtures/table-rowspan-html-native/gnd.json +9 -21
- package/fixtures/table-rowspan-role-aria/gnd.json +9 -21
- package/fixtures/table-sectioning/gnd.json +10 -24
- package/fixtures/table-th-no-scope/gnd.json +11 -25
- package/fixtures/term-epub-type/gnd.json +4 -10
- package/fixtures/term-html-native/gnd.json +1 -3
- package/fixtures/term-role-aria/gnd.json +1 -3
- package/fixtures/term-span-in-dt/gnd.json +3 -9
- package/fixtures/tip-epub-type/gnd.json +3 -8
- package/fixtures/tip-role-aria/gnd.json +1 -3
- package/fixtures/toc-epub-type/gnd.json +15 -43
- package/fixtures/toc-role-aria/gnd.json +14 -40
- package/fixtures/video-html-native/gnd.json +3 -5
- package/fixtures/video-no-description/gnd.json +2 -4
- package/package.json +6 -2
- package/src/a11y.ts +3 -12
- package/src/converter.ts +10 -45
- package/src/elementHandlers.ts +3 -12
- package/src/emptyPairs.ts +35 -15
- package/src/index.ts +2 -1
- package/src/object.ts +4 -10
- package/src/textrefFragment.ts +7 -16
- package/types/src/a11y.d.ts +0 -2
- package/types/src/converter.d.ts +0 -2
- package/types/src/emptyPairs.d.ts +3 -0
- package/types/src/index.d.ts +2 -1
- package/types/src/textrefFragment.d.ts +0 -4
|
@@ -1,57 +1,29 @@
|
|
|
1
1
|
{
|
|
2
|
-
"role": [
|
|
3
|
-
"body"
|
|
4
|
-
],
|
|
2
|
+
"role": ["body"],
|
|
5
3
|
"children": [
|
|
6
4
|
{
|
|
7
|
-
"role": [
|
|
8
|
-
"navigation",
|
|
9
|
-
"toc"
|
|
10
|
-
],
|
|
5
|
+
"role": ["navigation", "toc"],
|
|
11
6
|
"children": [
|
|
12
7
|
{
|
|
13
|
-
"role": [
|
|
14
|
-
"list"
|
|
15
|
-
],
|
|
8
|
+
"role": ["list"],
|
|
16
9
|
"children": [
|
|
17
10
|
{
|
|
18
|
-
"role": [
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
{
|
|
23
|
-
"textref": "chapter1.xhtml",
|
|
24
|
-
"text": {
|
|
25
|
-
"plain": "Chapter One"
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
]
|
|
11
|
+
"role": ["listItem"],
|
|
12
|
+
"text": {
|
|
13
|
+
"plain": "Chapter One"
|
|
14
|
+
}
|
|
29
15
|
},
|
|
30
16
|
{
|
|
31
|
-
"role": [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
{
|
|
36
|
-
"textref": "chapter2.xhtml",
|
|
37
|
-
"text": {
|
|
38
|
-
"plain": "Chapter Two"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
]
|
|
17
|
+
"role": ["listItem"],
|
|
18
|
+
"text": {
|
|
19
|
+
"plain": "Chapter Two"
|
|
20
|
+
}
|
|
42
21
|
},
|
|
43
22
|
{
|
|
44
|
-
"role": [
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
{
|
|
49
|
-
"textref": "chapter3.xhtml",
|
|
50
|
-
"text": {
|
|
51
|
-
"plain": "Chapter Three"
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
]
|
|
23
|
+
"role": ["listItem"],
|
|
24
|
+
"text": {
|
|
25
|
+
"plain": "Chapter Three"
|
|
26
|
+
}
|
|
55
27
|
}
|
|
56
28
|
]
|
|
57
29
|
}
|
|
@@ -1,52 +1,26 @@
|
|
|
1
1
|
{
|
|
2
|
-
"role": [
|
|
3
|
-
"navigation",
|
|
4
|
-
"toc"
|
|
5
|
-
],
|
|
2
|
+
"role": ["navigation", "toc"],
|
|
6
3
|
"children": [
|
|
7
4
|
{
|
|
8
|
-
"role": [
|
|
9
|
-
"list"
|
|
10
|
-
],
|
|
5
|
+
"role": ["list"],
|
|
11
6
|
"children": [
|
|
12
7
|
{
|
|
13
|
-
"role": [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
{
|
|
18
|
-
"textref": "chapter1.xhtml",
|
|
19
|
-
"text": {
|
|
20
|
-
"plain": "Chapter One"
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
]
|
|
8
|
+
"role": ["listItem"],
|
|
9
|
+
"text": {
|
|
10
|
+
"plain": "Chapter One"
|
|
11
|
+
}
|
|
24
12
|
},
|
|
25
13
|
{
|
|
26
|
-
"role": [
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
{
|
|
31
|
-
"textref": "chapter2.xhtml",
|
|
32
|
-
"text": {
|
|
33
|
-
"plain": "Chapter Two"
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
]
|
|
14
|
+
"role": ["listItem"],
|
|
15
|
+
"text": {
|
|
16
|
+
"plain": "Chapter Two"
|
|
17
|
+
}
|
|
37
18
|
},
|
|
38
19
|
{
|
|
39
|
-
"role": [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
{
|
|
44
|
-
"textref": "chapter3.xhtml",
|
|
45
|
-
"text": {
|
|
46
|
-
"plain": "Chapter Three"
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
]
|
|
20
|
+
"role": ["listItem"],
|
|
21
|
+
"text": {
|
|
22
|
+
"plain": "Chapter Three"
|
|
23
|
+
}
|
|
50
24
|
}
|
|
51
25
|
]
|
|
52
26
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@readium/guided-navigation",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Guided Navigation document generation from HTML and XHTML content",
|
|
6
6
|
"author": "readium",
|
|
@@ -50,6 +50,8 @@
|
|
|
50
50
|
"@types/node": "^26.6.3",
|
|
51
51
|
"jest": "^30.2.0",
|
|
52
52
|
"jsdom": "^30.1.1",
|
|
53
|
+
"prettier": "^3.9.10",
|
|
54
|
+
"prettier-plugin-sort-json": "^4.2.0",
|
|
53
55
|
"rimraf": "^6.1.3",
|
|
54
56
|
"ts-jest": "^29.4.6",
|
|
55
57
|
"tslib": "^2.8.1",
|
|
@@ -59,7 +61,9 @@
|
|
|
59
61
|
"scripts": {
|
|
60
62
|
"clean": "rimraf types dist",
|
|
61
63
|
"build": "pnpm clean && tsc && vite build",
|
|
62
|
-
"test": "jest",
|
|
64
|
+
"test": "pnpm run format:fixtures:check && jest",
|
|
65
|
+
"format:fixtures": "prettier --write \"fixtures/**/gnd.json\"",
|
|
66
|
+
"format:fixtures:check": "prettier --check \"fixtures/**/gnd.json\"",
|
|
63
67
|
"generate-fixtures-manifest": "node scripts/build-fixtures-manifest.js"
|
|
64
68
|
}
|
|
65
69
|
}
|
package/src/a11y.ts
CHANGED
|
@@ -32,20 +32,11 @@ function nodeText(root: Node, excludeExplicitRoles: boolean, languages: Set<stri
|
|
|
32
32
|
return text;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
function normalizedText(root: Node, excludeExplicitRoles: boolean): NodeText {
|
|
36
|
-
const languages = new Set<string>();
|
|
37
|
-
const text = normalizeWhitespace(nodeText(root, excludeExplicitRoles, languages), true).trim();
|
|
38
|
-
return { text, language: sharedLanguage(languages) };
|
|
39
|
-
}
|
|
40
|
-
|
|
41
35
|
/** Normalized (whitespace-coalesced and trimmed) text content of a node's subtree, and its language. */
|
|
42
36
|
export function normalizedNodeText(el: Node): NodeText {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
/** Same as `normalizedNodeText`, excluding explicitly-role-bearing descendants. */
|
|
47
|
-
export function normalizedNodeTextExcludingExplicitRoles(el: Node): NodeText {
|
|
48
|
-
return normalizedText(el, true);
|
|
37
|
+
const languages = new Set<string>();
|
|
38
|
+
const text = normalizeWhitespace(nodeText(el, false, languages), true).trim();
|
|
39
|
+
return { text, language: sharedLanguage(languages) };
|
|
49
40
|
}
|
|
50
41
|
|
|
51
42
|
/**
|
package/src/converter.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { extractNodeRoles, hasExplicitRole } from "./roles.ts";
|
|
|
4
4
|
import {
|
|
5
5
|
extractNodeAria,
|
|
6
6
|
normalizedNodeText,
|
|
7
|
-
normalizedNodeTextExcludingExplicitRoles,
|
|
8
7
|
convertElementToSSMLTag,
|
|
9
8
|
skippedElements,
|
|
10
9
|
} from "./a11y.ts";
|
|
@@ -89,11 +88,6 @@ export class Converter {
|
|
|
89
88
|
private root = new NavObject();
|
|
90
89
|
private current = this.root;
|
|
91
90
|
|
|
92
|
-
// Captions whose text was already folded into a table's `description` —
|
|
93
|
-
// only these specific elements go silent, not the whole table (rows/cells
|
|
94
|
-
// still need their own text).
|
|
95
|
-
private foldedCaptions = new Set<Element>();
|
|
96
|
-
|
|
97
91
|
private segments: Segment[] = [];
|
|
98
92
|
private textAcc = "";
|
|
99
93
|
private currentCtx: SSMLContext = { lang: undefined, tag: "" };
|
|
@@ -180,12 +174,11 @@ export class Converter {
|
|
|
180
174
|
}
|
|
181
175
|
|
|
182
176
|
// An explicit-role descendant is content in its own right and skips
|
|
183
|
-
// inherited `noText` — except `caption`,
|
|
177
|
+
// inherited `noText` — except `caption`, which the figure's ARIA name replaces.
|
|
184
178
|
private descend(el: Element, roles: GndRole[]) {
|
|
185
179
|
const node = new NavObject();
|
|
186
180
|
node.el = el;
|
|
187
|
-
node.noText =
|
|
188
|
-
this.foldedCaptions.has(el) || ((!hasExplicitRole(el) || roles.includes("caption")) && this.current.noText);
|
|
181
|
+
node.noText = (!hasExplicitRole(el) || roles.includes("caption")) && this.current.noText;
|
|
189
182
|
this.current.children.push(node);
|
|
190
183
|
this.current.hasChildBlock = true;
|
|
191
184
|
this.current = node;
|
|
@@ -261,12 +254,11 @@ export class Converter {
|
|
|
261
254
|
return true;
|
|
262
255
|
}
|
|
263
256
|
if (tagName === "a" && el.getAttribute("href")) {
|
|
264
|
-
// Any other link — a backlink, or a plain navigational
|
|
265
|
-
//
|
|
266
|
-
//
|
|
267
|
-
//
|
|
268
|
-
//
|
|
269
|
-
// embedded object.
|
|
257
|
+
// Any other link — a backlink, or a plain navigational link with no
|
|
258
|
+
// specific role (e.g. a TOC entry). When it's the sole content of its
|
|
259
|
+
// enclosing block (the usual case for list items), the hoist rule
|
|
260
|
+
// promotes it onto that block; otherwise it becomes an inline SSML
|
|
261
|
+
// placeholder like any other embedded object.
|
|
270
262
|
link(this, el, roles, aria, ariaLanguage);
|
|
271
263
|
return true;
|
|
272
264
|
}
|
|
@@ -328,26 +320,6 @@ export class Converter {
|
|
|
328
320
|
if (roles.includes("figure")) {
|
|
329
321
|
this.current.noText = true;
|
|
330
322
|
}
|
|
331
|
-
} else if (roles.includes("figure")) {
|
|
332
|
-
const caption = this.implicitCaptionOf(el);
|
|
333
|
-
if (caption) {
|
|
334
|
-
// Not suppressed — walked normally so a nested explicit-role
|
|
335
|
-
// descendant (e.g. a credit) still speaks.
|
|
336
|
-
const { text, language } = normalizedNodeTextExcludingExplicitRoles(caption);
|
|
337
|
-
if (text) {
|
|
338
|
-
setDescription(cur, text, language);
|
|
339
|
-
this.current.noText = true;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
} else if (roles.includes("table")) {
|
|
343
|
-
const caption = this.implicitCaptionOf(el);
|
|
344
|
-
if (caption) {
|
|
345
|
-
const { text, language } = normalizedNodeTextExcludingExplicitRoles(caption);
|
|
346
|
-
if (text) {
|
|
347
|
-
setDescription(cur, text, language);
|
|
348
|
-
this.foldedCaptions.add(caption);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
323
|
}
|
|
352
324
|
const id = el.getAttribute("id");
|
|
353
325
|
if (id) cur.id = id;
|
|
@@ -355,16 +327,6 @@ export class Converter {
|
|
|
355
327
|
return false;
|
|
356
328
|
}
|
|
357
329
|
|
|
358
|
-
// HTML-AAM implicit name: a table/figure with no explicit ARIA name folds
|
|
359
|
-
// its native/ARIA caption child's text in as its own description instead
|
|
360
|
-
// of speaking that child separately.
|
|
361
|
-
private implicitCaptionOf(el: Element): Element | null {
|
|
362
|
-
for (let c = el.firstElementChild; c; c = c.nextElementSibling) {
|
|
363
|
-
if (extractNodeRoles(c).includes("caption") && !c.getAttribute("aria-labelledby")) return c;
|
|
364
|
-
}
|
|
365
|
-
return null;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
330
|
private tail(el: Element, wasSkip: boolean, parent: NavObject) {
|
|
369
331
|
if (wasSkip) return;
|
|
370
332
|
const tagName = el.tagName.toLowerCase();
|
|
@@ -563,6 +525,9 @@ export class Converter {
|
|
|
563
525
|
// `words`: the object's pieces of plain text when they're part of the sentence it sits in, e.g. a link's.
|
|
564
526
|
placeholder(el: Element, tag: string, object: ObjBuilder, { candidateID, words }: { candidateID?: string; words?: Segment[] } = {}) {
|
|
565
527
|
if (isEmptyObj(object)) return;
|
|
528
|
+
if (!object.textref && this.selectorPredicate?.(object.role ?? [])) {
|
|
529
|
+
object.textref = textrefForSelector(selectorForElement(el, this.selectorRoot, this.selectorRootAnchor), el);
|
|
530
|
+
}
|
|
566
531
|
const child = new NavObject();
|
|
567
532
|
child.el = el;
|
|
568
533
|
child.object = object;
|
package/src/elementHandlers.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { hasElementChild, isAncestorOf } from "./dom.ts";
|
|
|
11
11
|
import { nodeLanguage } from "./language.ts";
|
|
12
12
|
import { Converter, type Segment } from "./converter.ts";
|
|
13
13
|
import { selectorForElement, textrefForSelector } from "./selectorGenerator.ts";
|
|
14
|
-
import { decodeIdFragment
|
|
14
|
+
import { decodeIdFragment } from "./textrefFragment.ts";
|
|
15
15
|
|
|
16
16
|
// Returns true if el's children should still be descended into (a
|
|
17
17
|
// pagebreak with element children of its own, in HTML parsing).
|
|
@@ -61,7 +61,7 @@ export function noteref(converter: Converter, el: Element, roles: GndRole[]): vo
|
|
|
61
61
|
// The target's own id already carries its meaning via this
|
|
62
62
|
// noteref's own id — repeating it on the embedded content would
|
|
63
63
|
// be redundant.
|
|
64
|
-
for (const c of children)
|
|
64
|
+
for (const c of children) delete c.id;
|
|
65
65
|
obj.children = children;
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -130,22 +130,13 @@ function linkObject(
|
|
|
130
130
|
obj.children = content;
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
const href = el.getAttribute("href");
|
|
134
|
-
if (href) obj.textref = href;
|
|
135
133
|
return { obj, words };
|
|
136
134
|
}
|
|
137
135
|
|
|
138
|
-
function removeId(obj: ObjBuilder) {
|
|
139
|
-
const id = obj.id;
|
|
140
|
-
if (id === undefined) return;
|
|
141
|
-
delete obj.id;
|
|
142
|
-
detachSelfTextref(obj, id);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
136
|
// Removes the ids a copy repeats from its original, keeping placeholders', allocated unique and referenced by their parent's SSML.
|
|
146
137
|
function removeCopiedIds(objs: ObjBuilder[], parent?: ObjBuilder) {
|
|
147
138
|
for (const obj of objs) {
|
|
148
|
-
if (obj.id === undefined || !parent?.text?.ssml.includes(`id="${ssmlAttrEscape(obj.id)}"`))
|
|
139
|
+
if (obj.id === undefined || !parent?.text?.ssml.includes(`id="${ssmlAttrEscape(obj.id)}"`)) delete obj.id;
|
|
149
140
|
if (obj.children) removeCopiedIds(obj.children, obj);
|
|
150
141
|
}
|
|
151
142
|
}
|
package/src/emptyPairs.ts
CHANGED
|
@@ -48,28 +48,48 @@ export function bindsToPrevious(text: string, lang: string | undefined): boolean
|
|
|
48
48
|
return !(marksFor(lang).opening.has(text[0]) && text.length > 1 && !/[\s\p{P}]/u.test(text[1]));
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
/**
|
|
52
|
-
*
|
|
53
|
-
export function
|
|
51
|
+
/** Which characters of plain text in `lang` `removeDropped` takes out, as a mask of the same length.
|
|
52
|
+
* A collapsed pair owns its marks and fillers; where spaces collapse to one, the first space is the one kept. */
|
|
53
|
+
export function droppedMask(plain: string, lang: string | undefined): boolean[] {
|
|
54
54
|
const { pairs, opening, closing } = marksFor(lang);
|
|
55
|
-
|
|
55
|
+
let text = plain;
|
|
56
|
+
// Indices in `plain` behind each character of `text`.
|
|
57
|
+
const sources: number[][] = Array.from({ length: plain.length }, (_, i) => [i]);
|
|
58
|
+
for (let i = text.indexOf(DROPPED); i !== -1; i = text.indexOf(DROPPED, i + 1)) {
|
|
56
59
|
let start = i;
|
|
57
60
|
let end = i + 1;
|
|
58
|
-
while (start > 0 && FILLER.test(
|
|
59
|
-
while (end <
|
|
60
|
-
const open =
|
|
61
|
-
const close =
|
|
61
|
+
while (start > 0 && FILLER.test(text[start - 1])) start--;
|
|
62
|
+
while (end < text.length && FILLER.test(text[end])) end++;
|
|
63
|
+
const open = text[start - 1];
|
|
64
|
+
const close = text[end];
|
|
62
65
|
if (open === undefined || close === undefined || !pairs.has(open + close)) continue;
|
|
63
66
|
// A mark that both opens and closes must be placed as the one it is here.
|
|
64
|
-
if (closing.has(open) && start > 1 && !/[\s\p{Ps}\p{Pi}\p{Pd}]/u.test(
|
|
65
|
-
if (opening.has(close) && end <
|
|
67
|
+
if (closing.has(open) && start > 1 && !/[\s\p{Ps}\p{Pi}\p{Pd}]/u.test(text[start - 2])) continue;
|
|
68
|
+
if (opening.has(close) && end < text.length - 1 && !/[\s\p{P}]/u.test(text[end + 1])) continue;
|
|
66
69
|
// The pair becomes one dropped object, which may leave an enclosing pair empty in turn.
|
|
67
|
-
|
|
70
|
+
text = text.slice(0, start - 1) + DROPPED + text.slice(end + 1);
|
|
71
|
+
sources.splice(start - 1, end - start + 2, sources.slice(start - 1, end + 1).flat());
|
|
68
72
|
i = start - 2;
|
|
69
73
|
}
|
|
74
|
+
const mask: boolean[] = new Array(plain.length).fill(false);
|
|
70
75
|
// A space is kept only where there was one around the dropped objects, and never before binding punctuation.
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
76
|
+
for (const match of text.matchAll(/ *\u0000[\u0000 ]*/g)) {
|
|
77
|
+
const offset = match.index;
|
|
78
|
+
const end = offset + match[0].length;
|
|
79
|
+
const rest = text.slice(end);
|
|
80
|
+
const kept = offset > 0 && rest !== "" && match[0].includes(" ") && !bindsToPrevious(rest, lang) ? text.indexOf(" ", offset) : -1;
|
|
81
|
+
for (let j = offset; j < end; j++) {
|
|
82
|
+
if (j !== kept) for (const source of sources[j]) mask[source] = true;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return mask;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Takes each `DROPPED` out of plain text in `lang`, with any bracket or quote pair left enclosing only fillers (spaces, commas, other `DROPPED`).
|
|
89
|
+
* Spaces around what's removed collapse to one, dropped at either end of the text and before binding punctuation; no space is added where there was none. */
|
|
90
|
+
export function removeDropped(plain: string, lang: string | undefined): string {
|
|
91
|
+
const mask = droppedMask(plain, lang);
|
|
92
|
+
let result = "";
|
|
93
|
+
for (let i = 0; i < plain.length; i++) if (!mask[i]) result += plain[i];
|
|
94
|
+
return result;
|
|
75
95
|
}
|
package/src/index.ts
CHANGED
|
@@ -13,4 +13,5 @@ export {
|
|
|
13
13
|
} from "./textrefFragment.ts";
|
|
14
14
|
export type { DomRangeJSON, DecodedTextref } from "./textrefFragment.ts";
|
|
15
15
|
export { isAriaSubstituted, substitutedOwnSelector } from "./object.ts";
|
|
16
|
-
export {
|
|
16
|
+
export { extractNodeRoles } from "./roles.ts";
|
|
17
|
+
export { DROPPED, droppedMask, removeDropped } from "./emptyPairs.ts";
|
package/src/object.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { GuidedNavigationDescription, GuidedNavigationObject, GuidedNavigationTe
|
|
|
2
2
|
import type { GndRole } from "./types.ts";
|
|
3
3
|
import { nonSelfNestingRoles } from "./roles.ts";
|
|
4
4
|
import { type TextBuilder, textIsEmpty, finalizeText } from "./text.ts";
|
|
5
|
-
import { detachSelfTextref } from "./textrefFragment.ts";
|
|
6
5
|
|
|
7
6
|
export interface ObjBuilder {
|
|
8
7
|
id?: string;
|
|
@@ -33,8 +32,7 @@ const contentFreeRoles: readonly GndRole[] = ["math", "separator"];
|
|
|
33
32
|
export const ariaSubstitutedBuilders = new WeakSet<ObjBuilder>();
|
|
34
33
|
const ariaSubstitutedNodes = new WeakSet<GuidedNavigationObject>();
|
|
35
34
|
|
|
36
|
-
// A substituted link's own CSS selector
|
|
37
|
-
// never resolves to an on-page location, so this is its fallback box (set only by link()).
|
|
35
|
+
// A substituted link's own CSS selector, its box when no textref locates it (set only by link()).
|
|
38
36
|
export const substitutedOwnSelectorBuilders = new WeakMap<ObjBuilder, string>();
|
|
39
37
|
const substitutedOwnSelectorNodes = new WeakMap<GuidedNavigationObject, string>();
|
|
40
38
|
|
|
@@ -79,11 +77,11 @@ function isChildrenOnly(o: ObjBuilder): boolean {
|
|
|
79
77
|
// A lone child with no role/id/ref of its own: its text is hoisted into the
|
|
80
78
|
// parent object directly, e.g. a paragraph wrapping plain emphasis becomes
|
|
81
79
|
// {role, text} rather than nesting an anonymous child. A child carrying its
|
|
82
|
-
// own ref
|
|
83
|
-
//
|
|
84
|
-
// whichever of the two textrefs isn't kept.
|
|
80
|
+
// own ref is never hoisted: merging would discard one of the two refs.
|
|
81
|
+
// Substituted text isn't on the page, so it never becomes its parent's text.
|
|
85
82
|
export function isHoistable(o: ObjBuilder): boolean {
|
|
86
83
|
return (
|
|
84
|
+
!ariaSubstitutedBuilders.has(o) &&
|
|
87
85
|
!(o.role && o.role.length > 0) &&
|
|
88
86
|
!o.id &&
|
|
89
87
|
!o.description &&
|
|
@@ -141,10 +139,6 @@ export class NavObject {
|
|
|
141
139
|
const textref = selfTextref(this.el);
|
|
142
140
|
if (textref) result.textref = textref;
|
|
143
141
|
}
|
|
144
|
-
// An object given another id than its element's references that element by selector.
|
|
145
|
-
const ownId = this.el?.getAttribute("id");
|
|
146
|
-
if (ownId && result.id !== ownId) detachSelfTextref(result, ownId);
|
|
147
|
-
|
|
148
142
|
return result;
|
|
149
143
|
}
|
|
150
144
|
}
|
package/src/textrefFragment.ts
CHANGED
|
@@ -15,14 +15,6 @@ export function encodeCssSelectorFragment(selector: string): string {
|
|
|
15
15
|
return `${CSS_PREFIX}${encodeURIComponent(selector)}${CSS_SUFFIX}`;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
// Without id as its own, node's bare "#id" textref would decode as a link, so it's re-expressed as that id's selector.
|
|
19
|
-
export function detachSelfTextref(node: { textref?: string }, id: string) {
|
|
20
|
-
const fragment = `#${encodeURIComponent(id)}`;
|
|
21
|
-
if (node.textref === fragment || node.textref?.startsWith(`${fragment}:~:`)) {
|
|
22
|
-
node.textref = encodeCssSelectorFragment(`#${CSS.escape(id)}`) + node.textref.slice(fragment.length);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
18
|
export function decodeCssSelectorFragment(textref: string | undefined): string | undefined {
|
|
27
19
|
if (!textref || !textref.startsWith(CSS_PREFIX) || !textref.endsWith(CSS_SUFFIX)) return undefined;
|
|
28
20
|
return decodeURIComponent(textref.slice(CSS_PREFIX.length, -CSS_SUFFIX.length));
|
|
@@ -148,14 +140,12 @@ export function decodeIdFragment(base: string): string | undefined {
|
|
|
148
140
|
}
|
|
149
141
|
}
|
|
150
142
|
|
|
151
|
-
// Decodes a
|
|
152
|
-
// navigational textref (link href, noteref target). A textref is
|
|
143
|
+
// Decodes a textref, which always references the node's own content. A textref is
|
|
153
144
|
// "[href]#fragment", the href naming the resource when present (e.g.
|
|
154
|
-
// "chapter.xhtml#css(...)")
|
|
155
|
-
//
|
|
156
|
-
// own id. A ":~:text=..." suffix can accompany any of the above, or stand
|
|
145
|
+
// "chapter.xhtml#css(...)"); the fragment is "#css(...)", "#domrange(...)" or a
|
|
146
|
+
// bare "#id". A ":~:text=..." suffix can accompany any of the above, or stand
|
|
157
147
|
// alone, so it's decoded separately and merged into the result.
|
|
158
|
-
export function decodeTextref(node: {
|
|
148
|
+
export function decodeTextref(node: { textref?: string } | undefined): DecodedTextref | undefined {
|
|
159
149
|
const textref = node?.textref;
|
|
160
150
|
if (!textref) return undefined;
|
|
161
151
|
|
|
@@ -175,8 +165,9 @@ export function decodeTextref(node: { id?: string; textref?: string } | undefine
|
|
|
175
165
|
const decoded = decodeCssSelectorFragment(fragment);
|
|
176
166
|
if (decoded !== undefined) {
|
|
177
167
|
cssSelector = decoded;
|
|
178
|
-
} else
|
|
179
|
-
|
|
168
|
+
} else {
|
|
169
|
+
const id = decodeIdFragment(fragment);
|
|
170
|
+
if (id) cssSelector = `#${CSS.escape(id)}`;
|
|
180
171
|
}
|
|
181
172
|
}
|
|
182
173
|
|
package/types/src/a11y.d.ts
CHANGED
|
@@ -4,8 +4,6 @@ export interface NodeText {
|
|
|
4
4
|
}
|
|
5
5
|
/** Normalized (whitespace-coalesced and trimmed) text content of a node's subtree, and its language. */
|
|
6
6
|
export declare function normalizedNodeText(el: Node): NodeText;
|
|
7
|
-
/** Same as `normalizedNodeText`, excluding explicitly-role-bearing descendants. */
|
|
8
|
-
export declare function normalizedNodeTextExcludingExplicitRoles(el: Node): NodeText;
|
|
9
7
|
/**
|
|
10
8
|
* Computes the text that becomes a node's `GuidedNavigationObject.description`, and
|
|
11
9
|
* whether the node is visible in the first place. Follows the AccName
|
package/types/src/converter.d.ts
CHANGED
|
@@ -34,7 +34,6 @@ export declare class Converter {
|
|
|
34
34
|
copy: boolean;
|
|
35
35
|
private root;
|
|
36
36
|
private current;
|
|
37
|
-
private foldedCaptions;
|
|
38
37
|
private segments;
|
|
39
38
|
private textAcc;
|
|
40
39
|
private currentCtx;
|
|
@@ -58,7 +57,6 @@ export declare class Converter {
|
|
|
58
57
|
private appendChild;
|
|
59
58
|
private walk;
|
|
60
59
|
private head;
|
|
61
|
-
private implicitCaptionOf;
|
|
62
60
|
private tail;
|
|
63
61
|
private applyTextref;
|
|
64
62
|
private text;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export declare const DROPPED = "\0";
|
|
2
2
|
export declare function bindsToPrevious(text: string, lang: string | undefined): boolean;
|
|
3
|
+
/** Which characters of plain text in `lang` `removeDropped` takes out, as a mask of the same length.
|
|
4
|
+
* A collapsed pair owns its marks and fillers; where spaces collapse to one, the first space is the one kept. */
|
|
5
|
+
export declare function droppedMask(plain: string, lang: string | undefined): boolean[];
|
|
3
6
|
/** Takes each `DROPPED` out of plain text in `lang`, with any bracket or quote pair left enclosing only fillers (spaces, commas, other `DROPPED`).
|
|
4
7
|
* Spaces around what's removed collapse to one, dropped at either end of the text and before binding punctuation; no space is added where there was none. */
|
|
5
8
|
export declare function removeDropped(plain: string, lang: string | undefined): string;
|
package/types/src/index.d.ts
CHANGED
|
@@ -6,4 +6,5 @@ export type { GndGenerationOptions, TextrefOptions } from "./options.ts";
|
|
|
6
6
|
export { encodeCssSelectorFragment, decodeCssSelectorFragment, encodeDomRangeFragment, decodeDomRangeFragment, decodeTextref, combineDomRangeTextrefs, } from "./textrefFragment.ts";
|
|
7
7
|
export type { DomRangeJSON, DecodedTextref } from "./textrefFragment.ts";
|
|
8
8
|
export { isAriaSubstituted, substitutedOwnSelector } from "./object.ts";
|
|
9
|
-
export {
|
|
9
|
+
export { extractNodeRoles } from "./roles.ts";
|
|
10
|
+
export { DROPPED, droppedMask, removeDropped } from "./emptyPairs.ts";
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
export declare function encodeCssSelectorFragment(selector: string): string;
|
|
2
|
-
export declare function detachSelfTextref(node: {
|
|
3
|
-
textref?: string;
|
|
4
|
-
}, id: string): void;
|
|
5
2
|
export declare function decodeCssSelectorFragment(textref: string | undefined): string | undefined;
|
|
6
3
|
export interface DomRangeJSON {
|
|
7
4
|
start: {
|
|
@@ -40,6 +37,5 @@ export interface DecodedTextref {
|
|
|
40
37
|
export declare function combineDomRangeTextrefs(first: DecodedTextref, last: DecodedTextref): DecodedTextref | undefined;
|
|
41
38
|
export declare function decodeIdFragment(base: string): string | undefined;
|
|
42
39
|
export declare function decodeTextref(node: {
|
|
43
|
-
id?: string;
|
|
44
40
|
textref?: string;
|
|
45
41
|
} | undefined): DecodedTextref | undefined;
|