testaro 69.0.3 → 69.2.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/package.json +1 -1
- package/procs/catalog.js +13 -5
package/package.json
CHANGED
package/procs/catalog.js
CHANGED
|
@@ -69,9 +69,14 @@ exports.getCatalog = async report => {
|
|
|
69
69
|
'startTag',
|
|
70
70
|
element.outerHTML?.replace(/^.*?</s, '<').replace(/>.*$/s, '>') ?? ''
|
|
71
71
|
);
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
const isTextable = element.closest('body')
|
|
73
|
+
&& ! element.closest('svg')
|
|
74
|
+
&& ! ['SCRIPT', 'STYLE', 'svg'].includes(element.tagName);
|
|
75
|
+
const innerText = isTextable
|
|
76
|
+
? element.innerText.trim() || (element.parentElement?.innerText?.trim() ?? '')
|
|
77
|
+
: '';
|
|
78
|
+
const segments = innerText?.split('\n') ?? [];
|
|
79
|
+
const tidySegments = segments.map(segment => segment.trim().replace(/\s+/g, ' '));
|
|
75
80
|
const neededSegments = tidySegments.filter(segment => segment.length);
|
|
76
81
|
neededSegments.splice(1, neededSegments.length - 2);
|
|
77
82
|
const text = addToCatalog(index, cat, 'text', neededSegments.join('\n'));
|
|
@@ -110,8 +115,11 @@ exports.getCatalog = async report => {
|
|
|
110
115
|
) {
|
|
111
116
|
// For each element that has it:
|
|
112
117
|
textElementIndexes.forEach(index => {
|
|
113
|
-
// If it is not in the head:
|
|
114
|
-
if (
|
|
118
|
+
// If it is not in the head, a script, a style, or a noscript element:
|
|
119
|
+
if (
|
|
120
|
+
! ['/head[1]', '/script[', '/style[', '/noscript[']
|
|
121
|
+
.some(excluder => cat.element[index].pathID.includes(excluder))
|
|
122
|
+
) {
|
|
115
123
|
// Mark it as linkable in the element data in the catalog.
|
|
116
124
|
cat.element[index].textLinkable = true;
|
|
117
125
|
}
|