Skip to content

Commit

Permalink
fix: errant slice for trailing whitespace (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
chelkyl authored May 2, 2024
1 parent c29a49b commit 689c819
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/selfish-radios-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro-remote": patch
---

Fixes an issue with internal `getIndent` function used for spacing corrections for `Markdown`
4 changes: 2 additions & 2 deletions packages/astro-remote/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion packages/playground/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
<ul>
<li><a href="/test-md-local">Test Local Markdown "< Markdown >"</a></li>
<li><a href="/test-issue7">Test Issue #7</a></li>
<li><a href="/test-issue27">Test Issue #27</a></li>
</ul>
<h2>Remote:</h2>
<ul>
<li><a href="/test-html">Test Remote HTML "< Markup >"</a></li>
<li><a href="/test-md-remote">Test Remote Markdown "< Markdown >"</a></li>
</ul>
</body>
</html>
</html>
18 changes: 18 additions & 0 deletions packages/playground/src/pages/test-issue27.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
import { Markdown } from "astro-remote";
---

<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width" />
<meta name="generator" content={Astro.generator} />
<title>Astro</title>
</head>
<body>
<Markdown content={"<mark>Highlighted word</mark> with no trailing space"} />
<Markdown content={"<mark>Highlighted word</mark> with trailing space "} />
<Markdown content={"Non-initial <mark>Highlighted word</mark> with trailing spaces "} />
</body>
</html>

0 comments on commit 689c819

Please sign in to comment.