From edf3200b12a8f09f6c41be38661216373b1d1ff9 Mon Sep 17 00:00:00 2001 From: Adam Matthiesen Date: Mon, 26 Feb 2024 14:02:02 -0800 Subject: [PATCH 1/5] okay some resolutions... not the best but it is working --- packages/astro-remote/lib/utils.ts | 17 +++++++------- packages/playground/src/pages/index.astro | 1 + .../playground/src/pages/test-issue7.astro | 22 +++++++++++++++++++ 3 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 packages/playground/src/pages/test-issue7.astro diff --git a/packages/astro-remote/lib/utils.ts b/packages/astro-remote/lib/utils.ts index 38d313c..e9d6248 100644 --- a/packages/astro-remote/lib/utils.ts +++ b/packages/astro-remote/lib/utils.ts @@ -44,15 +44,14 @@ function getIndent(ln: string): string { } export function dedent(str: string): string { - const lns = str.replace(/^[\r\n]+/, "").split("\n"); - let indent = getIndent(lns[0]); - if (indent.length === 0 && lns.length > 1) { - indent = getIndent(lns[1]); - } - return lns - .map((ln) => (ln.startsWith(indent) ? ln.slice(indent.length) : ln)) - .map((ln, i, { length }) => (i === length - 1 ? ln.trim() : ln)) - .join("\n"); + const lns = str.replace(/^[\r\n]+/, "").split("\n"); + let indent = getIndent(lns[0]); + if (indent.length === 0 && lns.length > 1) { + indent = getIndent(lns[1]); + } + return lns + .map((ln) => (indent.length > 1 && ln.startsWith(indent) ? ln.slice(indent.length) : ln)) + .join("\n"); } export interface HTMLOptions { diff --git a/packages/playground/src/pages/index.astro b/packages/playground/src/pages/index.astro index 57cf273..728a4ef 100644 --- a/packages/playground/src/pages/index.astro +++ b/packages/playground/src/pages/index.astro @@ -13,6 +13,7 @@

Local:

Remote: