Skip to content

Commit bc38bdb

Browse files
fix: terminal animation newlines escaped by Zola HTML minifier
Zola's minify_html converts '\n' inside JS strings to '\\n', producing literal backslash-n instead of newlines. Use String.fromCharCode(10) via a NL variable to avoid minifier interference.
1 parent 8f8d063 commit bc38bdb

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

templates/index.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,7 @@ <h3>Discussions</h3>
12261226
];
12271227

12281228
let sceneIndex = 0;
1229+
const NL = String.fromCharCode(10);
12291230

12301231
function typeScene(scene, onDone) {
12311232
let lineIndex = 0;
@@ -1272,18 +1273,18 @@ <h3>Discussions</h3>
12721273

12731274
const line = lines[lineIndex];
12741275
const plainLen = stripTags(line).length;
1275-
const prev = lines.slice(0, lineIndex).join('\n');
1276+
const prev = lines.slice(0, lineIndex).join(NL);
12761277

12771278
if (!isCommand(line)) {
12781279
// Output lines: print instantly
1279-
el.innerHTML = (prev ? prev + '\n' : '') + line;
1280+
el.innerHTML = (prev ? prev + NL : '') + line;
12801281
lineIndex++;
12811282
charIndex = 0;
12821283
setTimeout(tick, 30);
12831284
} else if (charIndex <= plainLen) {
12841285
const partial = getPartialHtml(line, charIndex);
12851286
const cursor = charIndex < plainLen ? '<span class="hero-terminal__cursor">_</span>' : '';
1286-
el.innerHTML = (prev ? prev + '\n' : '') + partial + cursor;
1287+
el.innerHTML = (prev ? prev + NL : '') + partial + cursor;
12871288
charIndex++;
12881289
const isComment = stripTags(line).startsWith('#');
12891290
setTimeout(tick, isComment ? 25 : 18);

0 commit comments

Comments
 (0)