From 063a9e1c0609d7a03e64891fb651ee77e3513b98 Mon Sep 17 00:00:00 2001 From: Araozu Date: Sun, 19 May 2024 21:30:11 -0500 Subject: [PATCH] Minimal Alpine interactivity --- src/components/InteractiveCode.astro | 29 +++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/components/InteractiveCode.astro b/src/components/InteractiveCode.astro index 2ab92d1..0975b33 100644 --- a/src/components/InteractiveCode.astro +++ b/src/components/InteractiveCode.astro @@ -75,10 +75,10 @@ function trimAndDedent(input: string): Array { function highlightCode(lines: Array): string { let outLines: Array = []; - for (const line of lines) { + for (const [idx, line] of lines.entries()) { const tokens = lex(line); const lineArray = [ - "
" + `
` ]; for (const token of tokens) { @@ -99,16 +99,14 @@ function highlightCode(lines: Array): string { const codeHtml = highlightCode(trimAndDedent(code)); --- -
+
thp code
stdout
- aaaa -
- bbbb +
@@ -119,19 +117,36 @@ const codeHtml = highlightCode(trimAndDedent(code));
-