From 21e92d932af5be927ac3d4f179d6e37831d6cffb Mon Sep 17 00:00:00 2001 From: chelkyl <14041823+chelkyl@users.noreply.github.com> Date: Thu, 25 Apr 2024 23:10:52 -0500 Subject: [PATCH 1/3] fix: only look for whitespace at start to calculate indent --- packages/astro-remote/lib/utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/astro-remote/lib/utils.ts b/packages/astro-remote/lib/utils.ts index d72a7e5..20ff43f 100644 --- a/packages/astro-remote/lib/utils.ts +++ b/packages/astro-remote/lib/utils.ts @@ -39,8 +39,8 @@ export function createComponentProxy( } function getIndent(ln: string): string { - if (ln.trim() === ln) return ""; - return ln.slice(0, ln.length - ln.trim().length); + if (ln.trimStart() === ln) return ""; + return ln.slice(0, ln.length - ln.trimStart().length); } export function dedent(str: string): string { From 722fcab1513722ba448a87dd46f0a6bfd7faa732 Mon Sep 17 00:00:00 2001 From: chelkyl <14041823+chelkyl@users.noreply.github.com> Date: Thu, 25 Apr 2024 23:19:31 -0500 Subject: [PATCH 2/3] docs: add playground page for testing issue 27 --- packages/playground/src/pages/index.astro | 3 ++- .../playground/src/pages/test-issue27.astro | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 packages/playground/src/pages/test-issue27.astro diff --git a/packages/playground/src/pages/index.astro b/packages/playground/src/pages/index.astro index 728a4ef..dba53b1 100644 --- a/packages/playground/src/pages/index.astro +++ b/packages/playground/src/pages/index.astro @@ -14,6 +14,7 @@

Remote:

- \ No newline at end of file + diff --git a/packages/playground/src/pages/test-issue27.astro b/packages/playground/src/pages/test-issue27.astro new file mode 100644 index 0000000..e16de1f --- /dev/null +++ b/packages/playground/src/pages/test-issue27.astro @@ -0,0 +1,18 @@ +--- +import { Markdown } from "astro-remote"; +--- + + + + + + + + Astro + + + Highlighted word with no trailing space"} /> + Highlighted word with trailing space "} /> + Highlighted word with trailing spaces "} /> + + From 956acef48fd960af26a7b813d203cd77443aeb98 Mon Sep 17 00:00:00 2001 From: chelkyl <14041823+chelkyl@users.noreply.github.com> Date: Fri, 26 Apr 2024 00:10:40 -0500 Subject: [PATCH 3/3] chore: add changeset --- .changeset/selfish-radios-talk.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/selfish-radios-talk.md diff --git a/.changeset/selfish-radios-talk.md b/.changeset/selfish-radios-talk.md new file mode 100644 index 0000000..7874be8 --- /dev/null +++ b/.changeset/selfish-radios-talk.md @@ -0,0 +1,5 @@ +--- +"astro-remote": patch +--- + +Fixes an issue with internal `getIndent` function used for spacing corrections for `Markdown`