strokes-js 0.1.2 → 0.1.3
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/dist/renderer.js +10 -2
- package/package.json +1 -1
package/dist/renderer.js
CHANGED
|
@@ -74,16 +74,24 @@ export function renderText(text, options = {}) {
|
|
|
74
74
|
const parts = splitText(text);
|
|
75
75
|
let delayOffset = 0;
|
|
76
76
|
const markup = [];
|
|
77
|
+
let pendingWhitespace = "";
|
|
77
78
|
for (const part of parts) {
|
|
78
79
|
if (/^\s+$/.test(part)) {
|
|
79
|
-
|
|
80
|
+
pendingWhitespace += part;
|
|
80
81
|
continue;
|
|
81
82
|
}
|
|
82
83
|
const word = part;
|
|
83
84
|
const { svg, letterCount } = renderWord(word, delayOffset, animate);
|
|
84
|
-
|
|
85
|
+
const space = pendingWhitespace
|
|
86
|
+
? `<span class="hw-space" aria-hidden="true" style="white-space: pre-wrap">${escapeHtml(pendingWhitespace)}</span>`
|
|
87
|
+
: "";
|
|
88
|
+
markup.push(`<span class="hw-token">${space}${svg}</span>`);
|
|
89
|
+
pendingWhitespace = "";
|
|
85
90
|
delayOffset += letterCount;
|
|
86
91
|
}
|
|
92
|
+
if (pendingWhitespace) {
|
|
93
|
+
markup.push(`<span class="hw-token"><span class="hw-space" aria-hidden="true" style="white-space: pre-wrap">${escapeHtml(pendingWhitespace)}</span></span>`);
|
|
94
|
+
}
|
|
87
95
|
return `<span class="hw-sentence" aria-label="${escapeAttr(text)}">${markup.join("")}</span>`;
|
|
88
96
|
}
|
|
89
97
|
function escapeAttr(value) {
|