Skip to content

Commit 689c819

Browse files
authored
fix: errant slice for trailing whitespace (#28)
1 parent c29a49b commit 689c819

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

.changeset/selfish-radios-talk.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"astro-remote": patch
3+
---
4+
5+
Fixes an issue with internal `getIndent` function used for spacing corrections for `Markdown`

packages/astro-remote/lib/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ export function createComponentProxy(
3939
}
4040

4141
function getIndent(ln: string): string {
42-
if (ln.trim() === ln) return "";
43-
return ln.slice(0, ln.length - ln.trim().length);
42+
if (ln.trimStart() === ln) return "";
43+
return ln.slice(0, ln.length - ln.trimStart().length);
4444
}
4545

4646
export function dedent(str: string): string {

packages/playground/src/pages/index.astro

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
<ul>
1515
<li><a href="/test-md-local">Test Local Markdown "< Markdown >"</a></li>
1616
<li><a href="/test-issue7">Test Issue #7</a></li>
17+
<li><a href="/test-issue27">Test Issue #27</a></li>
1718
</ul>
1819
<h2>Remote:</h2>
1920
<ul>
2021
<li><a href="/test-html">Test Remote HTML "< Markup >"</a></li>
2122
<li><a href="/test-md-remote">Test Remote Markdown "< Markdown >"</a></li>
2223
</ul>
2324
</body>
24-
</html>
25+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
import { Markdown } from "astro-remote";
3+
---
4+
5+
<html lang="en">
6+
<head>
7+
<meta charset="utf-8" />
8+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
9+
<meta name="viewport" content="width=device-width" />
10+
<meta name="generator" content={Astro.generator} />
11+
<title>Astro</title>
12+
</head>
13+
<body>
14+
<Markdown content={"<mark>Highlighted word</mark> with no trailing space"} />
15+
<Markdown content={"<mark>Highlighted word</mark> with trailing space "} />
16+
<Markdown content={"Non-initial <mark>Highlighted word</mark> with trailing spaces "} />
17+
</body>
18+
</html>

0 commit comments

Comments
 (0)